JS: Fix: Now Array.prototype.with is properly flagged as taint step

This commit is contained in:
Napalys
2024-11-15 10:35:34 +01:00
parent f04fd5cdcc
commit bed1f25b3f
3 changed files with 5 additions and 3 deletions

View File

@@ -477,7 +477,7 @@ private module ArrayLibraries {
private class ImmutableArrayTransformStep extends TaintTracking::SharedTaintStep {
override predicate heapStep(DataFlow::Node pred, DataFlow::Node succ) {
exists(DataFlow::MethodCallNode call |
call.getMethodName() in ["toSorted", "toReversed"] and
call.getMethodName() in ["toSorted", "toReversed", "with"] and
pred = call.getReceiver() and
succ = call
)

View File

@@ -244,6 +244,8 @@ typeInferenceMismatch
| tst.js:2:13:2:20 | source() | tst.js:66:10:66:16 | xSorted |
| tst.js:2:13:2:20 | source() | tst.js:68:10:68:23 | x.toReversed() |
| tst.js:2:13:2:20 | source() | tst.js:70:10:70:18 | xReversed |
| tst.js:2:13:2:20 | source() | tst.js:72:10:72:17 | x.with() |
| tst.js:2:13:2:20 | source() | tst.js:74:10:74:14 | xWith |
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |
| xml.js:12:17:12:24 | source() | xml.js:13:14:13:19 | result |
| xml.js:23:18:23:25 | source() | xml.js:20:14:20:17 | attr |

View File

@@ -69,7 +69,7 @@ function test() {
const xReversed = x.toReversed();
sink(xReversed) // NOT OK
sink(x.with()) // NOT OK -- Should be flagged as a taint sink, but it is not
sink(x.with()) // NOT OK
const xWith = x.with();
sink(xWith) // NOT OK -- Should be flagged as a taint sink, but it is not
sink(xWith) // NOT OK
}