-
Notifications
You must be signed in to change notification settings - Fork 44
Add_vulnerable_code #10
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
base: master
Are you sure you want to change the base?
Changes from all commits
718581c
0c49fe9
1def41f
b0dea43
f6e0b72
879c598
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,96 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var express = require('express'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var router = express.Router(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const path = require("path"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var dateTime = require('node-datetime'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fs = require('fs'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const AdmZip = require('adm-zip'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var JSZip = require("jszip"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| router.get('/:batchId/:source', function (req, res, next) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var batchId = req.params.batchId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var source = req.params.source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var MergedFileName = "MergedBatchFile_" + batchId + ".pdf"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (source.includes('..') || batchId.includes('..')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return res.status(400).json({ status: 'N', msg: 'Invalid input parameters' }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var mergedFiledpath = path.join(__basedir, './public/batchFiles/' + dateTime.create().format('Y-m-d') + `/${source}` + "/" + batchId + "/MergeFile",MergedFileName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Path construction combines date formatting, template literals, globals, and filename assembly in one expression. Split into named intermediate variables to improve readability. Details✨ AI Reasoning 🔧 How do I fix it? Reply
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AikidoSec ignore: reason to ignore the issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Based on your feedback, we ignored this isssue because of the following reason:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var fileName = "MergedBatchFile_" + batchId + ".zip"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var FileLocation = path.join(__basedir, './public/batchFiles/' + dateTime.create().format('Y-m-d') + `/${source}` + "/" + batchId + "/" + fileName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Building FileLocation mixes date formatting and complex path templating on one line. Break into interim variables (date, sourcePath, fileName) to simplify and improve readability.
Suggested change
Details✨ AI Reasoning Reply |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*res.download(FileLocation, fileName, function (err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| });*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const zip = new AdmZip(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /*for(i=0;i<mergedFiledpath.length;i++){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zip.addLocalFile(mergedFiledpath+"/"+mergedFiledpath[i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zip.addLocalFile(mergedFiledpath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const data = zip.toBuffer(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zip.writeZip(FileLocation); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| res.status(200).json({ status: 'Y', msg: 'File Downloaded Successfully' }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const config = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| db: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| user: "admin", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| password: Buffer.from("c3VwZXJTZWNyZXQxMjMh", "base64").toString("utf-8"), // Decodes to "superSecret123!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| host: "db.example.com", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| port: 5432 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| api: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key: atob("YXBpS2V5LTQ1NkFBQkM="), // Decodes to "apiKey-456AABC" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| token: (() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const encoded = ["ZXZlbnRz", "LWFwaS0xMjM0"]; // ["events", "-api-1234"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return encoded.join(""); // "events-api-1234" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Module-level Show fix
Suggested change
Details✨ AI Reasoning Reply |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const express = require('express'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Details✨ AI Reasoning Reply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will fix the Eliminate obvious within-file duplication issue detected on line: 2. Show FixAikido AutoFix Patch Suggestion - low confidence
Suggested change
Reply |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const os = require('os'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const helmet = require('helmet'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const app = express(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.use(helmet()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const port = 3000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.get('/', (req, res) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const uid = os.userInfo().uid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| res.send(`Hello World! UID: ${uid}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+64
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid returning internal system details (UID) in responses; remove or restrict this debug output. Details✨ AI Reasoning 🔧 How do I fix it? Reply Show FixRemediation - low confidence
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AikidoSec feedback: Debug logging and console.log statements are acceptable in our troubleshooting-utils repository as these are CLI tools designed for debugging production issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 We were not able to create a custom learning from your feedback.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.listen(port, () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`Example app listening at http://localhost:${port}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+69
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove or gate the startup console.log; use structured logging or conditional dev-only logging instead. Details✨ AI Reasoning 🔧 How do I fix it? Reply Show FixRemediation - low confidence
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AikidoSec ignore: false positive There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Based on your feedback, we ignored this isssue because of the following reason:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function addingEventListenerToFetchData() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Details✨ AI Reasoning 🔧 How do I fix it? Reply |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .getElementById("fetchDetails") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
dejarno marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .addEventListener("click", function () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * getUrlForVulnerabilityLevel() method provides url to call the Vulnerability Level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * of Sample Vulnerability. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * e.g. /VulnerableApp/SampleVulnerability/LEVEL_1 for LEVEL_1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let url = getUrlForVulnerabilityLevel(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * doGetAjaxCall() method is used to do the ajax get call to the Vulnerability Level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| doGetAjaxCall(fetchDataCallback, url + "?name=dummyInput", true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Used to register event on the button or any other component | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| addingEventListenerToFetchData(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will fix the Detect contradictory or impossible logic issue detected on line: 73. Show FixAikido AutoFix Patch Suggestion - low confidence
Suggested change
Reply |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //Callback function to handle the response and render in the UI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function fetchDataCallback(data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.getElementById("response").innerHTML = data.content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CVE-2020-7746 in chart.js - critical severity Remediation Aikido suggests bumping this package to version 2.9.4 to resolve this issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @johan-aikido ignore: not interested in this version as we plan to deprecate the entire project |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate Express initialization: require('express') and related router/app setup are repeated. Consolidate into a single Express instance and unified routing.
Details
✨ AI Reasoning
The diff adds two separate imports/uses of Express that instantiate distinct HTTP handling (router vs app) within the same file. This repeats the same library initialization and server setup logic. Maintaining both means the same responsibility is handled in two places, increasing maintenance burden and risk of inconsistent changes. Consolidating Express initialization and routing would reduce duplication and potential for bugs when modifying server behavior.
🔧 How do I fix it?
Delete extra code. Extract repeated code sequences into reusable functions or methods. Use loops or data structures to eliminate repetitive patterns.
Reply
@AikidoSec feedback: [FEEDBACK]to get better review comments in the future.Reply
@AikidoSec ignore: [REASON]to ignore this issue.More info