Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

859 #864

Merged
merged 8 commits into from
Aug 20, 2024
Merged

859 #864

merged 8 commits into from
Aug 20, 2024

Conversation

mountaindude
Copy link
Collaborator

No description provided.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5 Security Hotspots
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@mountaindude mountaindude merged commit 9ed54b0 into ptarmiganlabs:master Aug 20, 2024
2 of 3 checks passed
Comment on lines +72 to +109
configVisServer.get('/', async (request, reply) => {
// Obfuscate the config object before sending it to the client
// First get clean copy of the config object
let newConfig = JSON.parse(JSON.stringify(globals.config));

if (globals.config.get('Butler-SOS.configVisualisation.obfuscate')) {
// Obfuscate config file before presenting it to the user
// This is done to avoid leaking sensitive information
// to users who should not have access to it.
// The obfuscation is done by replacing parts of the
// config file with masked strings.
newConfig = configObfuscate(newConfig);
}

// Convert the (potentially obfuscated) config object to YAML format (=string)
const butlerConfigYaml = yaml.dump(newConfig);

// Read index.html from disk
// dirname points to the directory where this file (app.js) is located, taking into account
// if the app is running as a packaged app or as a Node.js app.
globals.logger.verbose(`----------------3: ${globals.appBasePath}`);
const filePath = path.resolve(globals.appBasePath, 'static/configvis', 'index.html');
const template = fs.readFileSync(filePath, 'utf8');

// Compile handlebars template
const compiledTemplate = handlebars.compile(template);

// Get config as HTML encoded JSON string
const butlerConfigJsonEncoded = JSON.stringify(newConfig);

// Render the template
const renderedText = compiledTemplate({ butlerConfigJsonEncoded, butlerConfigYaml });

globals.logger.debug(`CONFIG VIS: Rendered text: ${renderedText}`);

// Send reply as HTML
reply.code(200).header('Content-Type', 'text/html; charset=utf-8').send(renderedText);
});

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a file system access
, but is not rate-limited.
tokenize: function (e, n) {
var t = n.rest;
if (t) {
for (var r in t) n[r] = t[r];

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
user controlled input
.
var t = n.rest;
if (t) {
for (var r in t) n[r] = t[r];
delete n.rest;

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
user controlled input
.
@mountaindude mountaindude deleted the 859 branch September 20, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant