Skip to content

Commit fc7e9eb

Browse files
committed
add test for non-tracked aliasing
1 parent b8ba31a commit fc7e9eb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ nodes
164164
| lib/lib.js:272:22:272:24 | obj |
165165
| lib/lib.js:272:22:272:32 | obj.version |
166166
| lib/lib.js:272:22:272:32 | obj.version |
167+
| lib/lib.js:276:8:276:11 | opts |
168+
| lib/lib.js:276:8:276:11 | opts |
169+
| lib/lib.js:277:23:277:26 | opts |
170+
| lib/lib.js:277:23:277:30 | opts.bla |
171+
| lib/lib.js:277:23:277:30 | opts.bla |
167172
edges
168173
| lib/lib2.js:3:28:3:31 | name | lib/lib2.js:4:22:4:25 | name |
169174
| lib/lib2.js:3:28:3:31 | name | lib/lib2.js:4:22:4:25 | name |
@@ -364,6 +369,10 @@ edges
364369
| lib/lib.js:268:22:268:24 | obj | lib/lib.js:268:22:268:32 | obj.version |
365370
| lib/lib.js:272:22:272:24 | obj | lib/lib.js:272:22:272:32 | obj.version |
366371
| lib/lib.js:272:22:272:24 | obj | lib/lib.js:272:22:272:32 | obj.version |
372+
| lib/lib.js:276:8:276:11 | opts | lib/lib.js:277:23:277:26 | opts |
373+
| lib/lib.js:276:8:276:11 | opts | lib/lib.js:277:23:277:26 | opts |
374+
| lib/lib.js:277:23:277:26 | opts | lib/lib.js:277:23:277:30 | opts.bla |
375+
| lib/lib.js:277:23:277:26 | opts | lib/lib.js:277:23:277:30 | opts.bla |
367376
#select
368377
| lib/lib2.js:4:10:4:25 | "rm -rf " + name | lib/lib2.js:3:28:3:31 | name | lib/lib2.js:4:22:4:25 | name | $@ based on libary input is later used in $@. | lib/lib2.js:4:10:4:25 | "rm -rf " + name | String concatenation | lib/lib2.js:4:2:4:26 | cp.exec ... + name) | shell command |
369378
| lib/lib2.js:8:10:8:25 | "rm -rf " + name | lib/lib2.js:7:32:7:35 | name | lib/lib2.js:8:22:8:25 | name | $@ based on libary input is later used in $@. | lib/lib2.js:8:10:8:25 | "rm -rf " + name | String concatenation | lib/lib2.js:8:2:8:26 | cp.exec ... + name) | shell command |
@@ -414,3 +423,4 @@ edges
414423
| lib/lib.js:261:11:261:33 | "rm -rf ... + name | lib/lib.js:257:35:257:38 | name | lib/lib.js:261:30:261:33 | name | $@ based on libary input is later used in $@. | lib/lib.js:261:11:261:33 | "rm -rf ... + name | String concatenation | lib/lib.js:261:3:261:34 | cp.exec ... + name) | shell command |
415424
| lib/lib.js:268:10:268:32 | "rm -rf ... version | lib/lib.js:267:46:267:48 | obj | lib/lib.js:268:22:268:32 | obj.version | $@ based on libary input is later used in $@. | lib/lib.js:268:10:268:32 | "rm -rf ... version | String concatenation | lib/lib.js:268:2:268:33 | cp.exec ... ersion) | shell command |
416425
| lib/lib.js:272:10:272:32 | "rm -rf ... version | lib/lib.js:267:46:267:48 | obj | lib/lib.js:272:22:272:32 | obj.version | $@ based on libary input is later used in $@. | lib/lib.js:272:10:272:32 | "rm -rf ... version | String concatenation | lib/lib.js:272:2:272:33 | cp.exec ... ersion) | shell command |
426+
| lib/lib.js:277:11:277:30 | "rm -rf " + opts.bla | lib/lib.js:276:8:276:11 | opts | lib/lib.js:277:23:277:30 | opts.bla | $@ based on libary input is later used in $@. | lib/lib.js:277:11:277:30 | "rm -rf " + opts.bla | String concatenation | lib/lib.js:277:3:277:31 | cp.exec ... ts.bla) | shell command |

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,14 @@ module.exports.sanitizerProperty = function (obj) {
270270
obj.version = "";
271271

272272
cp.exec("rm -rf " + obj.version); // OK - but FP
273+
}
274+
275+
module.exports.Foo = class Foo {
276+
start(opts) {
277+
cp.exec("rm -rf " + opts.bla); // NOT OK
278+
this.opts = {};
279+
this.opts.bla = opts.bla
280+
281+
cp.exec("rm -rf " + this.opts.bla); // NOT OK - but FN
282+
}
273283
}

0 commit comments

Comments
 (0)