Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b095fe2

Browse files
committed
JS: Fix some bugs in a test case
'args' was a redeclared block-level variable, and 'myArgs' was not used when clearly intended to be used
1 parent 22c218d commit b095fe2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

javascript/ql/test/query-tests/Security/CWE-078/CommandInjection/child_process-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ var server = http.createServer(function(req, res) {
4343
args[1] = cmd;
4444
cp.execFile("/bin/bash", args); // $ Alert
4545

46-
let args = [];
46+
args = [];
4747
args[0] = "-c";
4848
args[1] = cmd;
4949
run("sh", args);
5050

51-
let args = [];
51+
args = [];
5252
args[0] = `-` + "c";
5353
args[1] = cmd;
5454
cp.execFile(`/bin` + "/bash", args); // $ Alert
5555

5656
cp.spawn('cmd.exe', ['/C', 'foo'].concat(["bar", cmd])); // $ Alert
5757
cp.spawn('cmd.exe', ['/C', 'foo'].concat(cmd)); // $ Alert
5858

59-
let myArgs = [];
59+
let myArgs = [];
6060
myArgs.push(`-` + "c");
6161
myArgs.push(cmd);
62-
cp.execFile(`/bin` + "/bash", args); // $ MISSING: Alert - no support for `[].push()` for indirect arguments
62+
cp.execFile(`/bin` + "/bash", myArgs); // $ MISSING: Alert - no support for `[].push()` for indirect arguments
6363

6464
});
6565

0 commit comments

Comments
 (0)