Nixify and start frontend update

This commit is contained in:
2025-03-07 01:23:15 +01:00
parent 4a3c022958
commit 5682777bfe
38 changed files with 5299 additions and 10976 deletions

View File

@@ -1,3 +0,0 @@
> 1%
last 2 versions
not dead

View File

@@ -1,7 +0,0 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100

View File

@@ -1,20 +0,0 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/essential',
'@vue/airbnb',
'@vue/typescript/recommended',
'prettier'
],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'implicit-arrow-linebreak': 'warn',
},
};

View File

@@ -1,23 +0,0 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -1,24 +0,0 @@
# vue-frontend
## Project setup
```
yarn install
```
### Compiles and hot-reloads for development
```
yarn serve
```
### Compiles and minifies for production
```
yarn build
```
### Lints and fixes files
```
yarn lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@@ -1,5 +0,0 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
],
};

View File

@@ -1,50 +0,0 @@
{
"name": "apiary-frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@fontsource/rubik": "^4.2.2",
"@fontsource/secular-one": "^4.2.2",
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"bootstrap-vue": "^2.21.2",
"chart.js": "^3.0.2",
"core-js": "^3.6.5",
"d3": "^6.6.2",
"d3-svg-legend": "^2.25.6",
"faker": "^5.5.2",
"randomcolor": "^0.6.2",
"s-ago": "^2.2.0",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.1"
},
"devDependencies": {
"@types/chart.js": "^2.9.32",
"@types/d3": "^6.3.0",
"@types/faker": "^5.5.1",
"@types/randomcolor": "^0.5.5",
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-airbnb": "^5.0.2",
"@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"typescript": "~4.1.5",
"vue-template-compiler": "^2.6.11"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,22 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Stats about logins, usernames and passwords received by the SSH honeypot.">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>apiary.t-juice.club</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@@ -1,75 +0,0 @@
<template>
<div id="app">
<div id="apiary-navbar">
<b-navbar toggleable="md" type="dark" variant="dark">
<b-navbar-brand href="#">
<img
alt="logo"
src="logo192.png"
width="29"
height="29"
class="d-inline-block align-top"
/>
apiary.t-juice.club
</b-navbar-brand>
<b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
<b-collapse id="nav-collapse" is-nav>
<b-navbar-nav class="mr-auto">
<b-nav-item :to="'/'">Home</b-nav-item>
<b-nav-item :to="'/stats'">Stats</b-nav-item>
<b-nav-item :to="'/attempts'">Attempts</b-nav-item>
<b-nav-item :to="'/search'">Search</b-nav-item>
</b-navbar-nav>
</b-collapse>
</b-navbar>
</div>
<b-container id="main-content-container" fluid="md">
<router-view></router-view>
</b-container>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import AttemptList from '@/components/AttemptList.vue';
import Stats from '@/components/Stats.vue';
import Home from '@/components/Home.vue';
@Component({
components: {
AttemptList,
Stats,
Home,
},
})
export default class App extends Vue {}
</script>
<style lang="scss">
$font-stack-header: 'Secular One', sans-serif;
$font-stack-content: 'Rubik', sans-serif;
#app {
font-family: $font-stack-content;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 0;
}
.navbar-brand {
font-family: $font-stack-header;
}
.navbar-nav a {
font-family: $font-stack-content;
}
h1 h2 h3 {
font-family: $font-stack-header;
}
#main-content-container {
margin-top: 50px;
text-align: center;
display: inline-block;
}
</style>

View File

@@ -1,8 +0,0 @@
import { ApiaryAPI, LoginAttempt } from "@/apiary/apiary";
export class ApiaryDummyClient implements ApiaryAPI {
streamLoginAttempts(): any {
return 'a';
}
}

View File

@@ -1,35 +0,0 @@
import FakerStatic from 'faker';
export interface LoginAttempt {
readonly date: string;
readonly remoteIP: string;
readonly username: string;
readonly password: string;
readonly sshClientVersion: string;
readonly connectionUUID: string;
}
export interface StatResult {
name: string;
count: number;
}
export interface ApiaryAPI {
streamLoginAttempts(): ReadableStream<LoginAttempt>;
}
export function fakeAttempt(): LoginAttempt {
return {
date: FakerStatic.date.recent().toLocaleDateString(),
remoteIP: FakerStatic.internet.ip(),
username: FakerStatic.internet.userName(),
password: FakerStatic.internet.password(),
sshClientVersion: FakerStatic.lorem.words(2),
connectionUUID: FakerStatic.datatype.uuid(),
};
}
export function fakeAttemptStream(): EventSource {
const es = new EventSource('/stream');
return es;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -1,79 +0,0 @@
<template>
<div class="attemptlist">
<h1>Live Attempts</h1>
<p>
<b-table
responsive="md"
striped
hover
:items="attempts"
:fields="fields"
/>
</p>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { BvTableFieldArray, BvTableFormatterCallback } from 'bootstrap-vue';
import { LoginAttempt } from '@/apiary/apiary';
@Component
export default class AttemptList extends Vue {
@Prop() private items!: LoginAttempt[];
attempts: LoginAttempt[];
fields: BvTableFieldArray = [
{
key: 'date',
sortable: true,
formatter: (value: string): string => {
const d = new Date(value);
// This seems stupid...
return d.toTimeString().split(' ')[0];
},
sortByFormatted: false,
},
{
key: 'username',
},
{
key: 'password',
},
{
key: 'remoteIP',
sortable: true,
},
{
key: 'country',
},
];
constructor() {
super();
this.attempts = [];
}
mounted(): void {
/**
console.log(this);
const at: LoginAttempt[] = [];
for (let i = 0; i < 5; i += 1) {
at.push(fakeAttempt());
}
setInterval(() => {
at.push(fakeAttempt());
}, 1000);
*/
const attemptStream = new EventSource('/api/stream');
attemptStream.addEventListener('message', (ev: MessageEvent<string>) => {
const parsed: LoginAttempt = JSON.parse(ev.data);
this.attempts.unshift(parsed);
});
}
}
</script>

View File

@@ -1,145 +0,0 @@
<template>
<div class="home">
<b-container v-if="ready">
<b-row>
<b-col class="total-title">
<h2>Total login attempts</h2>
</b-col>
<b-col class="total-count">
<h2>{{ totalLoginAttempts }}</h2>
</b-col>
</b-row>
<b-row>
<b-col class="total-title">
<h2>Unique passwords</h2>
</b-col>
<b-col class="total-count">
<h2>{{ uniquePasswords }}</h2>
</b-col>
</b-row>
<b-row>
<b-col class="total-title">
<h2>Unique usernames</h2>
</b-col>
<b-col class="total-count">
<h2>{{ uniqueUsernames }}</h2>
</b-col>
</b-row>
<b-row>
<b-col class="total-title">
<h2>Unique IPs</h2>
</b-col>
<b-col class="total-count">
<h2>{{ uniqueIPs }}</h2>
</b-col>
</b-row>
</b-container>
</div>
</template>
<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator';
import axios from 'axios';
type TotalStatsHeaders =
| 'UniquePasswords'
| 'UniqueUsernames'
| 'UniqueIPs'
| 'UniqueCountries'
| 'TotalLoginAttempts';
interface TotalStatsResult {
name: TotalStatsHeaders;
count: number;
}
@Component
export default class Home extends Vue {
totalLoginAttempts: number;
uniquePasswords: number;
uniqueUsernames: number;
uniqueIPs: number;
uniqueCountries: number;
private updaterHandle?: number;
ready = false;
constructor() {
super();
this.totalLoginAttempts = 0;
this.uniquePasswords = 0;
this.uniqueUsernames = 0;
this.uniqueIPs = 0;
this.uniqueCountries = 0;
}
updateStats(): void {
const url = `/api/stats?type=total`;
axios
.get<TotalStatsResult[]>(url)
.then((resp) => {
const totals = resp.data.find((e) => e.name === 'TotalLoginAttempts')
?.count;
if (totals) {
this.totalLoginAttempts = totals;
}
const passwords = resp.data.find((e) => e.name === 'UniquePasswords')
?.count;
if (passwords) {
this.uniquePasswords = passwords;
}
const usernames = resp.data.find((e) => e.name === 'UniqueUsernames')
?.count;
if (usernames) {
this.uniqueUsernames = usernames;
}
const ips = resp.data.find((e) => e.name === 'UniqueIPs')?.count;
if (ips) {
this.uniqueIPs = ips;
}
const countries = resp.data.find((e) => e.name === 'UniqueCountries')
?.count;
if (countries) {
this.uniqueCountries = countries;
}
this.ready = true;
})
.catch((e) => {
console.log(e);
});
}
created(): void {
this.updateStats();
this.updaterHandle = setInterval(() => {
this.updateStats();
}, 5000);
}
beforeDestroy(): void {
clearInterval(this.updaterHandle);
}
}
</script>
<style scoped lang="scss">
.home {
text-align: left;
}
.total-title {
text-align: right;
}
.total-count {
text-align: left;
}
</style>

View File

@@ -1,81 +0,0 @@
<template>
<div class="search-result-container">
<h1>Search</h1>
<b-form @submit="onSubmit">
<b-form-input v-model="searchString" placeholder="" />
</b-form>
<b-table
class="search-results-table"
responsive="md"
striped
hover
:items="attempts"
:fields="fields"
/>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { LoginAttempt } from '@/apiary/apiary';
import { BvTableFieldArray, BvTableFormatterCallback } from 'bootstrap-vue';
import Axios from 'axios';
@Component
export default class SearchResult extends Vue {
attempts: LoginAttempt[];
searchString: string;
constructor() {
super();
this.attempts = [];
this.searchString = '';
}
fields: BvTableFieldArray = [
{
key: 'date',
sortable: true,
formatter: (value: string): string => {
const d = new Date(value);
// This seems stupid...
return d.toTimeString().split(' ')[0];
},
sortByFormatted: false,
},
{
key: 'username',
},
{
key: 'password',
},
{
key: 'remoteIP',
sortable: true,
},
{
key: 'country',
},
];
onSubmit(event: Event) {
event.preventDefault();
console.log(this.searchString);
const resp = Axios.get<LoginAttempt[]>(
`/api/query?query=${this.searchString}`,
);
resp.then((r) => {
this.attempts = r.data;
});
}
}
</script>
<style lang="scss" scoped>
.search-results-table {
margin-top: 50px;
}
</style>

View File

@@ -1,52 +0,0 @@
<template>
<div class="stats">
<h1>Login Stats</h1>
<b-card no-body>
<b-tabs card>
<b-tab title="Totals">
<b-card-body>
<home></home>
</b-card-body>
</b-tab>
<b-tab title="Usernames">
<b-card-body>
<stats-pie statType="username" />
</b-card-body>
</b-tab>
<b-tab title="Passwords">
<b-card-body>
<stats-pie statType="password"></stats-pie>
</b-card-body>
</b-tab>
<b-tab title="Countries">
<b-card-body>
<stats-pie statType="country"></stats-pie>
</b-card-body>
</b-tab>
<b-tab title="IPs">
<b-card-body>
<stats-pie statType="ip"></stats-pie>
</b-card-body>
</b-tab>
</b-tabs>
</b-card>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import StatsUsername from '@/components/StatsUsername.vue';
import StatsPie from '@/components/StatsPie.vue';
import Home from '@/components/Home.vue';
@Component({
components: {
StatsUsername,
StatsPie,
Home,
},
})
export default class Stats extends Vue {}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -1,187 +0,0 @@
<template>
<div class="stats-container" :class="containerClass">
<h2>
{{ title() }}
<b-icon :id="chartSettingsID()" icon="gear-fill"></b-icon>
</h2>
<div class="chart-container">
<canvas :id="chartID()" width="300" height="300"></canvas>
</div>
<b-popover
:target="chartSettingsID()"
triggers="click"
:show.sync="settingsShow"
placement="auto"
container="stats-container"
ref="popover"
@show="onShow"
>
<template #title>
<b-button @click="onClose" class="close" aria-label="Close">
<span class="d-inline-block" aria-hidden="true">&times;</span>
</b-button>
Settings
</template>
<div>
<b-form-group
label="Limit"
label-for="limitinput"
label-cols="3"
class="mb-1"
description="Limit number of items"
invalid-feedback="This field is required"
>
<b-form-input
ref="limitinput"
id="limitinput"
v-model="limitState"
type="number"
size="sm"
></b-form-input>
</b-form-group>
<b-button @click="onClose" size="sm" variant="danger">Cancel</b-button>
<b-button @click="onOk" size="sm" variant="primary">Ok</b-button>
</div>
</b-popover>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
import { StatResult } from '@/apiary/apiary';
import axios from 'axios';
import { Chart, ArcElement, Legend, DoughnutController, Title } from 'chart.js';
import randomColor from 'randomcolor';
export type StatType = 'username' | 'password' | 'ip' | 'country' | 'total';
Chart.register(ArcElement, Legend, DoughnutController, Title);
@Component
export default class StatsPie extends Vue {
@Prop() private statType!: StatType;
limit: number;
limitState: number;
settingsShow = false;
stats: StatResult[];
chart?: Chart;
constructor() {
super();
this.stats = [];
this.limit = 10;
this.limitState = 10;
}
title(): string {
switch (this.statType) {
case 'password':
return `Top ${this.limit} Passwords`;
case 'username':
return `Top ${this.limit} Usernames`;
case 'ip':
return `Top ${this.limit} IPs`;
case 'country':
return `Top ${this.limit} Countries`;
case 'total':
return 'Totals';
// Why doesn't eslint know that this switch is exhaustive?
default:
return 'Top 10 Passwords';
}
}
containerClass(): string {
return `stats-container-${this.statType}`;
}
chartID(): string {
return `chart-${this.statType}`;
}
chartSettingsID(): string {
return `chartsettings-${this.statType}`;
}
settingsID(): string {
return `settings-${this.statType}`;
}
onClose(): void {
this.settingsShow = false;
}
onOk(): void {
if (this.limitState) {
this.limit = this.limitState;
this.settingsShow = false;
}
}
onShow(): void {
// This is called just before the popover is shown
// Reset our popover form variables
this.limitState = this.limit;
}
@Watch('limit')
limitChanged(value: number, oldValue: number): void {
this.fetchData();
}
fetchData(): void {
const url = `/api/stats?type=${this.statType}&limit=${this.limit}`;
axios.get<StatResult[]>(url).then((resp) => {
this.stats = resp.data;
this.renderPie();
});
}
mounted(): void {
this.fetchData();
}
renderPie(): void {
const elem = document.getElementById(this.chartID()) as HTMLCanvasElement;
const ctx = elem.getContext('2d') as CanvasRenderingContext2D;
const sortedStats = this.stats.sort();
const values = sortedStats.map((s) => s.count);
const headers = sortedStats.map((s) => s.name);
const colors = sortedStats.map(() => randomColor());
if (this.chart) {
this.chart.destroy();
}
this.chart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: headers,
datasets: [
{
data: values,
backgroundColor: colors,
},
],
},
});
}
}
</script>
<style lang="scss" scoped>
canvas {
width: 70%;
height: auto;
max-height: 60vmin;
}
.stats-container {
align-content: center;
}
</style>

View File

@@ -1,67 +0,0 @@
<template>
<div class="stats-container">
<h2>Top 10 usernames</h2>
<div class="chart-container">
<canvas id="chart" widht="400" height="400"></canvas>
</div>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { StatResult } from '@/apiary/apiary';
import axios from 'axios';
import Chart from 'chart.js/auto';
import randomColor from 'randomcolor';
@Component
export default class StatsUsername extends Vue {
@Prop() private msg!: string;
stats: StatResult[];
constructor() {
super();
this.stats = [];
}
mounted(): void {
axios
.get<StatResult[]>('/api/stats?type=username&limit=10')
.then((resp) => {
this.stats = resp.data;
this.renderPie();
});
}
renderPie(): void {
const elem = document.getElementById('chart') as HTMLCanvasElement;
const ctx = elem.getContext('2d') as CanvasRenderingContext2D;
const sortedStats = this.stats.sort();
const values = sortedStats.map((s) => s.count);
const headers = sortedStats.map((s) => s.name);
const colors = sortedStats.map(() => randomColor());
const chart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: headers,
options: {},
datasets: [
{
data: values,
backgroundColor: colors,
},
],
},
});
}
}
</script>
<style lang="scss" scoped>
.chart-container {
max-width: 500px;
max-height: 500px;
}
</style>

View File

@@ -1,58 +0,0 @@
import Vue from 'vue';
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue';
import VueRouter, { RouteConfig } from 'vue-router';
import AttemptList from '@/components/AttemptList.vue';
import Home from '@/components/Home.vue';
import Stats from '@/components/Stats.vue';
import SearchResult from '@/components/SearchResult.vue';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap-vue/dist/bootstrap-vue.css';
import '@fontsource/rubik';
import '@fontsource/secular-one';
import App from './App.vue';
Vue.config.productionTip = false;
// Make BootstrapVue available throughout your project
Vue.use(BootstrapVue);
// Optionally install the BootstrapVue icon components plugin
Vue.use(IconsPlugin);
Vue.use(VueRouter);
const routes: Array<RouteConfig> = [
{
path: '/',
name: 'Home',
component: Home,
alias: '/home',
},
{
path: '/attempts',
name: 'Attempt List',
component: AttemptList,
props: {
// items: testAttempts,
},
},
{
path: '/stats',
name: 'Stats',
component: Stats,
},
{
path: '/search',
name: 'Search',
component: SearchResult,
}
];
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes,
});
new Vue({
router,
render: (h) => h(App),
}).$mount('#app');

View File

@@ -1,13 +0,0 @@
import Vue, { VNode } from 'vue';
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
}
}
}

View File

@@ -1,5 +0,0 @@
declare module '*.vue' {
import Vue from 'vue';
export default Vue;
}

View File

@@ -1,40 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}

File diff suppressed because it is too large Load Diff