@@ -81,12 +81,23 @@ module ArrayTaintTracking {
8181 pred = call .getArgument ( any ( int i | i >= 2 ) ) and
8282 succ .( DataFlow:: SourceNode ) .getAMethodCall ( "splice" ) = call
8383 or
84+ // `array.toSpliced(x, y, source())`: if `source()` is tainted, then so is the result of `toSpliced`, but not the original array.
85+ call .( DataFlow:: MethodCallNode ) .getMethodName ( ) = "toSpliced" and
86+ pred = call .getArgument ( any ( int i | i >= 2 ) ) and
87+ succ = call
88+ or
8489 // `array.splice(i, del, ...e)`: if `e` is tainted, then so is `array`.
8590 pred = call .getASpreadArgument ( ) and
8691 succ .( DataFlow:: SourceNode ) .getAMethodCall ( "splice" ) = call
8792 or
93+ // `array.toSpliced(i, del, ...e)`: if `e` is tainted, then so is the result of `toSpliced`, but not the original array.
94+ pred = call .getASpreadArgument ( ) and
95+ call .( DataFlow:: MethodCallNode ) .getMethodName ( ) = "toSpliced" and
96+ succ = call
97+ or
8898 // `e = array.pop()`, `e = array.shift()`, or similar: if `array` is tainted, then so is `e`.
89- call .( DataFlow:: MethodCallNode ) .calls ( pred , [ "pop" , "shift" , "slice" , "splice" , "at" ] ) and
99+ call .( DataFlow:: MethodCallNode )
100+ .calls ( pred , [ "pop" , "shift" , "slice" , "splice" , "at" , "toSpliced" ] ) and
90101 succ = call
91102 or
92103 // `e = Array.from(x)`: if `x` is tainted, then so is `e`.
@@ -283,7 +294,7 @@ private module ArrayDataFlow {
283294 private class ArraySpliceStep extends PreCallGraphStep {
284295 override predicate storeStep ( DataFlow:: Node element , DataFlow:: SourceNode obj , string prop ) {
285296 exists ( DataFlow:: MethodCallNode call |
286- call .getMethodName ( ) = "splice" and
297+ call .getMethodName ( ) = [ "splice" , "toSpliced" ] and
287298 prop = arrayElement ( ) and
288299 element = call .getArgument ( any ( int i | i >= 2 ) ) and
289300 call = obj .getAMethodCall ( )
@@ -297,7 +308,7 @@ private module ArrayDataFlow {
297308 toProp = arrayElement ( ) and
298309 // `array.splice(i, del, ...arr)` variant
299310 exists ( DataFlow:: MethodCallNode mcn |
300- mcn .getMethodName ( ) = "splice" and
311+ mcn .getMethodName ( ) = [ "splice" , "toSpliced" ] and
301312 pred = mcn .getASpreadArgument ( ) and
302313 succ = mcn .getReceiver ( ) .getALocalSource ( )
303314 )
@@ -320,12 +331,12 @@ private module ArrayDataFlow {
320331 }
321332
322333 /**
323- * A step for modeling that elements from an array `arr` also appear in the result from calling `slice`/`splice`/`filter`.
334+ * A step for modeling that elements from an array `arr` also appear in the result from calling `slice`/`splice`/`filter`/`toSpliced` .
324335 */
325336 private class ArraySliceStep extends PreCallGraphStep {
326337 override predicate loadStoreStep ( DataFlow:: Node pred , DataFlow:: SourceNode succ , string prop ) {
327338 exists ( DataFlow:: MethodCallNode call |
328- call .getMethodName ( ) = [ "slice" , "splice" , "filter" ] and
339+ call .getMethodName ( ) = [ "slice" , "splice" , "filter" , "toSpliced" ] and
329340 prop = arrayElement ( ) and
330341 pred = call .getReceiver ( ) and
331342 succ = call
0 commit comments