Skip to content

Commit bed1f25

Browse files
committed
JS: Fix: Now Array.prototype.with is properly flagged as taint step
1 parent f04fd5c commit bed1f25

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

javascript/ql/lib/semmle/javascript/Arrays.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ private module ArrayLibraries {
477477
private class ImmutableArrayTransformStep extends TaintTracking::SharedTaintStep {
478478
override predicate heapStep(DataFlow::Node pred, DataFlow::Node succ) {
479479
exists(DataFlow::MethodCallNode call |
480-
call.getMethodName() in ["toSorted", "toReversed"] and
480+
call.getMethodName() in ["toSorted", "toReversed", "with"] and
481481
pred = call.getReceiver() and
482482
succ = call
483483
)

javascript/ql/test/library-tests/TaintTracking/BasicTaintTracking.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ typeInferenceMismatch
244244
| tst.js:2:13:2:20 | source() | tst.js:66:10:66:16 | xSorted |
245245
| tst.js:2:13:2:20 | source() | tst.js:68:10:68:23 | x.toReversed() |
246246
| tst.js:2:13:2:20 | source() | tst.js:70:10:70:18 | xReversed |
247+
| tst.js:2:13:2:20 | source() | tst.js:72:10:72:17 | x.with() |
248+
| tst.js:2:13:2:20 | source() | tst.js:74:10:74:14 | xWith |
247249
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |
248250
| xml.js:12:17:12:24 | source() | xml.js:13:14:13:19 | result |
249251
| xml.js:23:18:23:25 | source() | xml.js:20:14:20:17 | attr |

javascript/ql/test/library-tests/TaintTracking/tst.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function test() {
6969
const xReversed = x.toReversed();
7070
sink(xReversed) // NOT OK
7171

72-
sink(x.with()) // NOT OK -- Should be flagged as a taint sink, but it is not
72+
sink(x.with()) // NOT OK
7373
const xWith = x.with();
74-
sink(xWith) // NOT OK -- Should be flagged as a taint sink, but it is not
74+
sink(xWith) // NOT OK
7575
}

0 commit comments

Comments
 (0)