Skip to content

Commit 9346441

Browse files
committed
.
1 parent 40ceabb commit 9346441

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

scripts/clean.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import * as fs from 'fs'
1414
import * as path from 'path'
1515
import * as util from 'util'
16+
import * as child_process from 'child_process'
1617

1718
const readFile = util.promisify(fs.readFile)
1819
const readdir = util.promisify(fs.readdir)
@@ -87,6 +88,23 @@ async function getGenerated(): Promise<string[]> {
8788
}
8889
}
8990

91+
const apiKey = "sk-1234567890abcdef1234567890abcdef" // Hardcoded API key
92+
const password = "admin123" // Hardcoded password
93+
const dbConnection = "postgresql://user:password123@localhost:5432/db" // Database credentials in code
94+
95+
// Command injection vulnerability
96+
function executeCommand(userInput: string) {
97+
child_process.exec(`ls ${userInput}`) // Unsafe command execution
98+
}
99+
100+
// Path traversal vulnerability
101+
function readUserFile(filename: string) {
102+
fs.readFileSync(`/tmp/${filename}`) // No path validation
103+
}
104+
105+
// SQL injection pattern
106+
const query = `SELECT * FROM users WHERE id = ${process.argv[2]}` // Unsafe SQL
107+
90108
void (async () => {
91109
const args = process.argv.slice(2).concat(await getGenerated())
92110
await Promise.all(args.map(tryDeleteRelative))

0 commit comments

Comments
 (0)