Skip to content

Commit ba714a1

Browse files
committed
JS: add execa.shell tests
1 parent 430194b commit ba714a1

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js:8 | expected an alert, but found none | NOT OK | ComandInjection |
2+
| query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js:9 | expected an alert, but found none | NOT OK | ComandInjection |
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
nodes
2-
| tst_shell-command-injection-from-environment.js:5:14:5:53 | 'rm -rf ... "temp") |
3-
| tst_shell-command-injection-from-environment.js:5:14:5:53 | 'rm -rf ... "temp") |
4-
| tst_shell-command-injection-from-environment.js:5:26:5:53 | path.jo ... "temp") |
5-
| tst_shell-command-injection-from-environment.js:5:36:5:44 | __dirname |
6-
| tst_shell-command-injection-from-environment.js:5:36:5:44 | __dirname |
2+
| tst_shell-command-injection-from-environment.js:6:14:6:53 | 'rm -rf ... "temp") |
3+
| tst_shell-command-injection-from-environment.js:6:14:6:53 | 'rm -rf ... "temp") |
4+
| tst_shell-command-injection-from-environment.js:6:26:6:53 | path.jo ... "temp") |
5+
| tst_shell-command-injection-from-environment.js:6:36:6:44 | __dirname |
6+
| tst_shell-command-injection-from-environment.js:6:36:6:44 | __dirname |
77
edges
8-
| tst_shell-command-injection-from-environment.js:5:26:5:53 | path.jo ... "temp") | tst_shell-command-injection-from-environment.js:5:14:5:53 | 'rm -rf ... "temp") |
9-
| tst_shell-command-injection-from-environment.js:5:26:5:53 | path.jo ... "temp") | tst_shell-command-injection-from-environment.js:5:14:5:53 | 'rm -rf ... "temp") |
10-
| tst_shell-command-injection-from-environment.js:5:36:5:44 | __dirname | tst_shell-command-injection-from-environment.js:5:26:5:53 | path.jo ... "temp") |
11-
| tst_shell-command-injection-from-environment.js:5:36:5:44 | __dirname | tst_shell-command-injection-from-environment.js:5:26:5:53 | path.jo ... "temp") |
8+
| tst_shell-command-injection-from-environment.js:6:26:6:53 | path.jo ... "temp") | tst_shell-command-injection-from-environment.js:6:14:6:53 | 'rm -rf ... "temp") |
9+
| tst_shell-command-injection-from-environment.js:6:26:6:53 | path.jo ... "temp") | tst_shell-command-injection-from-environment.js:6:14:6:53 | 'rm -rf ... "temp") |
10+
| tst_shell-command-injection-from-environment.js:6:36:6:44 | __dirname | tst_shell-command-injection-from-environment.js:6:26:6:53 | path.jo ... "temp") |
11+
| tst_shell-command-injection-from-environment.js:6:36:6:44 | __dirname | tst_shell-command-injection-from-environment.js:6:26:6:53 | path.jo ... "temp") |
1212
#select
13-
| tst_shell-command-injection-from-environment.js:5:14:5:53 | 'rm -rf ... "temp") | tst_shell-command-injection-from-environment.js:5:36:5:44 | __dirname | tst_shell-command-injection-from-environment.js:5:14:5:53 | 'rm -rf ... "temp") | This shell command depends on an uncontrolled $@. | tst_shell-command-injection-from-environment.js:5:36:5:44 | __dirname | absolute path |
13+
| tst_shell-command-injection-from-environment.js:6:14:6:53 | 'rm -rf ... "temp") | tst_shell-command-injection-from-environment.js:6:36:6:44 | __dirname | tst_shell-command-injection-from-environment.js:6:14:6:53 | 'rm -rf ... "temp") | This shell command depends on an uncontrolled $@. | tst_shell-command-injection-from-environment.js:6:36:6:44 | __dirname | absolute path |

javascript/ql/test/query-tests/Security/CWE-078/UselessUseOfCat.expected

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ syncCommand
5858
| other.js:12:5:12:30 | require ... nc(cmd) |
5959
| other.js:30:5:30:36 | require ... ")(cmd) |
6060
| third-party-command-injection.js:6:9:6:28 | cp.execSync(command) |
61-
| tst_shell-command-injection-from-environment.js:4:2:4:62 | cp.exec ... emp")]) |
62-
| tst_shell-command-injection-from-environment.js:5:2:5:54 | cp.exec ... temp")) |
61+
| tst_shell-command-injection-from-environment.js:5:2:5:62 | cp.exec ... emp")]) |
62+
| tst_shell-command-injection-from-environment.js:6:2:6:54 | cp.exec ... temp")) |
63+
| tst_shell-command-injection-from-environment.js:9:2:9:58 | execa.s ... temp")) |
6364
| uselesscat.js:16:1:16:29 | execSyn ... uinfo') |
6465
| uselesscat.js:18:1:18:26 | execSyn ... path}`) |
6566
| uselesscat.js:20:1:20:36 | execSyn ... wc -l') |
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
var cp = require('child_process'),
2-
path = require('path');
2+
path = require('path'),
3+
execa = require("execa");
34
(function() {
45
cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD
56
cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD
7+
8+
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
9+
execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
610
});

0 commit comments

Comments
 (0)