Skip to content

Commit 9457bc3

Browse files
authored
Merge pull request #17993 from Napalys/napalys/ES2023-array-protype-with
JS: Added support for Array.prototype.with() ES2023 feature
2 parents fa52d03 + a238509 commit 9457bc3

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
Added taint-steps for `Array.prototype.with`.

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,8 @@ function test() {
6868
sink(x.toReversed()) // NOT OK
6969
const xReversed = x.toReversed();
7070
sink(xReversed) // NOT OK
71+
72+
sink(x.with()) // NOT OK
73+
const xWith = x.with();
74+
sink(xWith) // NOT OK
7175
}

0 commit comments

Comments
 (0)