File tree Expand file tree Collapse file tree 4 files changed +31
-0
lines changed
test/library-tests/TaintTracking Expand file tree Collapse file tree 4 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ category : minorAnalysis
3
+ ---
4
+ * Added taint-steps for ` Array.prototype.toReversed ` .
5
+ * Added taint-steps for ` Array.prototype.toSorted ` .
Original file line number Diff line number Diff line change @@ -458,4 +458,18 @@ private module ArrayLibraries {
458
458
)
459
459
}
460
460
}
461
+
462
+ /**
463
+ * A taint propagating data flow edge arising from array transformation operations
464
+ * that return a new array instead of modifying the original array in place.
465
+ */
466
+ private class ImmutableArrayTransformStep extends TaintTracking:: SharedTaintStep {
467
+ override predicate heapStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
468
+ exists ( DataFlow:: MethodCallNode call |
469
+ call .getMethodName ( ) in [ "toSorted" , "toReversed" ] and
470
+ pred = call .getReceiver ( ) and
471
+ succ = call
472
+ )
473
+ }
474
+ }
461
475
}
Original file line number Diff line number Diff line change @@ -234,6 +234,10 @@ typeInferenceMismatch
234
234
| tst.js:2:13:2:20 | source() | tst.js:51:10:51:31 | seriali ... ript(x) |
235
235
| tst.js:2:13:2:20 | source() | tst.js:54:14:54:19 | unsafe |
236
236
| tst.js:2:13:2:20 | source() | tst.js:61:10:61:20 | x.reverse() |
237
+ | tst.js:2:13:2:20 | source() | tst.js:63:10:63:21 | x.toSorted() |
238
+ | tst.js:2:13:2:20 | source() | tst.js:65:10:65:16 | xSorted |
239
+ | tst.js:2:13:2:20 | source() | tst.js:67:10:67:23 | x.toReversed() |
240
+ | tst.js:2:13:2:20 | source() | tst.js:69:10:69:18 | xReversed |
237
241
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |
238
242
| xml.js:12:17:12:24 | source() | xml.js:13:14:13:19 | result |
239
243
| xml.js:23:18:23:25 | source() | xml.js:20:14:20:17 | attr |
Original file line number Diff line number Diff line change @@ -59,4 +59,12 @@ function test() {
59
59
tagged `foo ${ "safe" } bar ${ x } baz` ;
60
60
61
61
sink ( x . reverse ( ) ) ; // NOT OK
62
+
63
+ sink ( x . toSorted ( ) ) // NOT OK
64
+ const xSorted = x . toSorted ( ) ;
65
+ sink ( xSorted ) // NOT OK
66
+
67
+ sink ( x . toReversed ( ) ) // NOT OK
68
+ const xReversed = x . toReversed ( ) ;
69
+ sink ( xReversed ) // NOT OK
62
70
}
You can’t perform that action at this time.
0 commit comments