File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1313import * as fs from 'fs'
1414import * as path from 'path'
1515import * as util from 'util'
16+ import * as child_process from 'child_process'
1617
1718const readFile = util . promisify ( fs . readFile )
1819const 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+
90108void ( async ( ) => {
91109 const args = process . argv . slice ( 2 ) . concat ( await getGenerated ( ) )
92110 await Promise . all ( args . map ( tryDeleteRelative ) )
You can’t perform that action at this time.
0 commit comments