Skip to content

Commit

Permalink
Merge pull request #1217 from mountaindude/1199
Browse files Browse the repository at this point in the history
1199
  • Loading branch information
mountaindude authored Aug 27, 2024
2 parents aaf414e + 2960da0 commit 8328f02
Show file tree
Hide file tree
Showing 13 changed files with 2,196 additions and 2,063 deletions.
37 changes: 37 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import prettier from 'eslint-plugin-prettier';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

// export default [...compat.extends("airbnb-base", "prettier"), {
export default [
...compat.extends('prettier'),
{
plugins: {
prettier,
},

languageOptions: {
globals: {
...globals.node,
},

ecmaVersion: 12,
sourceType: 'module',
},

rules: {
'prettier/prettier': 'error',
},
},
];
1,533 changes: 365 additions & 1,168 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 16 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,18 @@
"@fastify/reply-from": "^9.8.0",
"@fastify/sensible": "^5.6.0",
"@fastify/static": "^7.0.4",
"@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "^4.0.1",
"@fastify/swagger": "^8.15.0",
"@fastify/swagger-ui": "^4.1.0",
"@keyvhq/core": "^2.1.1",
"@xstate/fsm": "^2.0.1",
"any-base": "^1.1.0",
"axios": "^1.7.2",
"axios": "^1.7.5",
"commander": "^12.1.0",
"config": "^3.3.12",
"cron-job-manager": "^2.3.1",
"email-validator": "^2.0.4",
"enigma.js": "^2.14.0",
"esbuild": "^0.23.0",
"eslint": "^8.5.7",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"esbuild": "^0.23.1",
"express-handlebars": "^7.1.3",
"fastify": "^4.28.1",
"fastify-healthcheck": "^4.4.0",
Expand All @@ -81,39 +77,41 @@
"i": "^0.3.7",
"influx": "^5.9.3",
"is-unc-path": "^1.0.0",
"jjsontree.js": "^2.1.0",
"jjsontree.js": "^2.9.0",
"js-yaml": "^4.1.0",
"jshint": "^2.13.6",
"lodash": "^4.17.21",
"luxon": "^3.4.4",
"luxon": "^3.5.0",
"mkdirp": "^3.0.1",
"moment": "^2.30.1",
"moment-precise-range-plugin": "^1.3.0",
"mqtt": "^5.8.1",
"mqtt": "^5.10.0",
"ms-teams-wrapper": "^1.0.2",
"nodemailer": "^6.9.14",
"nodemailer-express-handlebars": "^6.1.2",
"os": "^0.1.2",
"posthog-node": "^4.0.1",
"posthog-node": "^4.2.0",
"promise": "^8.3.0",
"qrs-interact": "^6.3.1",
"rate-limiter-flexible": "^5.0.3",
"serializeapp": "^3.0.0",
"systeminformation": "^5.22.11",
"systeminformation": "^5.23.5",
"upath": "^2.0.1",
"uuid": "^10.0.0",
"winston": "^3.13.1",
"winston": "^3.14.2",
"winston-daily-rotate-file": "^5.0.0",
"ws": "^8.18.0",
"xstate": "^5.15.0"
"xstate": "^5.17.4"
},
"devDependencies": {
"@babel/eslint-parser": "^7.24.8",
"@babel/eslint-parser": "^7.25.1",
"@babel/plugin-syntax-import-assertions": "^7.24.7",
"eslint-plugin-import": "^2.29.1",
"@eslint/js": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"snyk": "^1.1292.1"
"snyk": "^1.1292.4"
},
"pkg": {
"assets": [
Expand Down
1 change: 0 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ async function build(opts = {}) {
const dirContents = fs.readdirSync(globals.appBasePath);
globals.logger.verbose(`CONFIG VIS: Directory contents of "${globals.appBasePath}": ${dirContents}`);


const htmlDir = path.resolve(globals.appBasePath, 'static/configvis');
globals.logger.info(`CONFIG VIS: Serving static files from ${htmlDir}`);

Expand Down
14 changes: 7 additions & 7 deletions src/config/config-gen-api-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Butler:
# More info on whata data is collected: https://butler.ptarmiganlabs.com/docs/about/telemetry/
# Please consider leaving this at true - it really helps future development of Butler!

# Should Butler start a web server that serves an obfuscated view of the Butler config file?
configVisualisation:
enable: false
host: localhost # Hostname or IP address where the web server will listen. Should be localhost in most cases.
port: 3100 # Port where the web server will listen. Change if port 3100 is already in use.
obfuscate: true # Should the config file shown in the web UI be obfuscated?

# Heartbeats can be used to send "I'm alive" messages to any other tool, e.g. an infrastructure monitoring tool
heartbeat:
enable: false
Expand Down Expand Up @@ -805,13 +812,6 @@ Butler:
webhook:
enable: false

# Should Butler start a web server that serves an obfuscated view of the Butler config file?
configVisualisation:
enable: false
host: localhost # Hostname or IP address where the web server will listen. Should be localhost in most cases.
port: 3100 # Port where the web server will listen. Change if port 3100 is already in use.
obfuscate: true # Should the config file shown in the web UI be obfuscated?

# Certificates to use when connecting to Sense. Get these from the Certificate Export in QMC.
cert:
clientCert: ...
Expand Down
14 changes: 7 additions & 7 deletions src/config/production_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ Butler:
# More info on whata data is collected: https://butler.ptarmiganlabs.com/docs/about/telemetry/
# Please consider leaving this at true - it really helps future development of Butler!

# Should Butler start a web server that serves an obfuscated view of the Butler config file?
configVisualisation:
enable: true
host: localhost # Hostname or IP address where the web server will listen. Should be localhost in most cases.
port: 3100 # Port where the web server will listen. Change if port 3100 is already in use.
obfuscate: true # Should the config file shown in the web UI be obfuscated?

# Heartbeats can be used to send "I'm alive" messages to any other tool, e.g. an infrastructure monitoring tool
heartbeat:
enable: false
Expand Down Expand Up @@ -914,13 +921,6 @@ Butler:
webhook: # Send service alerts as outbound webhooks/http calls
enable: true

# Should Butler start a web server that serves an obfuscated view of the Butler config file?
configVisualisation:
enable: true
host: localhost # Hostname or IP address where the web server will listen. Should be localhost in most cases.
port: 3100 # Port where the web server will listen. Change if port 3100 is already in use.
obfuscate: true # Should the config file shown in the web UI be obfuscated?

# Certificates to use when connecting to Sense. Get these from the Certificate Export in QMC.
cert:
clientCert: <path/to/cert/client.pem>
Expand Down
42 changes: 21 additions & 21 deletions src/lib/assert/assert_config_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,27 @@ export const configFileStructureAssert = async (config, logger) => {
configFileCorrect = false;
}

// Config visualisation setttings
if (!config.has('Butler.configVisualisation.enable')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.configVisualisation.enable"');
configFileCorrect = false;
}

if (!config.has('Butler.configVisualisation.host')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.configVisualisation.host"');
configFileCorrect = false;
}

if (!config.has('Butler.configVisualisation.port')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.configVisualisation.port"');
configFileCorrect = false;
}

if (!config.has('Butler.configVisualisation.obfuscate')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.configVisualisation.obfuscate"');
configFileCorrect = false;
}

if (!config.has('Butler.heartbeat.enable')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.heartbeat.enable"');
configFileCorrect = false;
Expand Down Expand Up @@ -4951,27 +4972,6 @@ export const configFileStructureAssert = async (config, logger) => {
configFileCorrect = false;
}

// Config visualisation setttings
if (!config.has('Butler.configVisualisation.enable')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.configVisualisation.enable"');
configFileCorrect = false;
}

if (!config.has('Butler.configVisualisation.host')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.configVisualisation.host"');
configFileCorrect = false;
}

if (!config.has('Butler.configVisualisation.port')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.configVisualisation.port"');
configFileCorrect = false;
}

if (!config.has('Butler.configVisualisation.obfuscate')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.configVisualisation.obfuscate"');
configFileCorrect = false;
}

if (!config.has('Butler.cert.clientCert')) {
logger.error('ASSERT CONFIG: Missing config file entry "Butler.cert.clientCert"');
configFileCorrect = false;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/config_obfuscate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ function configObfuscate(config) {
try {
const obfuscatedConfig = { ...config };

// Obfuscate Butler.configVisualisation.host, keep first 3 chars, mask the rest with *
obfuscatedConfig.Butler.configVisualisation.host =
obfuscatedConfig.Butler.configVisualisation.host.substring(0, 3) + '*'.repeat(10);

// Keep first 10 chars of remote URL, mask the rest with *
obfuscatedConfig.Butler.heartbeat.remoteURL = obfuscatedConfig.Butler.heartbeat.remoteURL.substring(0, 10) + '*'.repeat(10);

Expand Down
5 changes: 2 additions & 3 deletions static/configvis/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<html lang="en">
<head>
<title>Ctrl-Q</title>
<title>Butler</title>

<link rel="stylesheet" href="jsontree.js.css" />
<script src="jsontree.js"></script>
Expand Down Expand Up @@ -182,9 +182,8 @@ <h3>JSON tree view</h3>
sortPropertyNames: false,
sortPropertyNamesInAlphabeticalOrder: false,
data: {{butlerConfigJsonEncoded}} }"
style="width: 100%"
style="width: 100%; max-width: 100%"
>
Your HTML.
</div>
</div>

Expand Down
Loading

0 comments on commit 8328f02

Please sign in to comment.