File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
test/library-tests/Arrays Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -492,7 +492,20 @@ private module ArrayLibraries {
492492 exists ( DataFlow:: MethodCallNode call |
493493 call .getMethodName ( ) = [ "findLast" , "find" , "findLastIndex" ] and
494494 prop = arrayLikeElement ( ) and
495- obj = call .getReceiver ( ) and
495+ obj = call .getReceiver ( ) .getALocalSource ( ) and
496+ element = call .getCallback ( 0 ) .getParameter ( 0 )
497+ )
498+ }
499+ }
500+
501+ /**
502+ * This step models the propagation of data from the array to the callback function's parameter.
503+ */
504+ private class ArrayCallBackDataTaintStep extends TaintTracking:: SharedTaintStep {
505+ override predicate step ( DataFlow:: Node obj , DataFlow:: Node element ) {
506+ exists ( DataFlow:: MethodCallNode call |
507+ call .getMethodName ( ) = [ "findLast" , "find" , "findLastIndex" ] and
508+ obj = call .getReceiver ( ) .getALocalSource ( ) and
496509 element = call .getCallback ( 0 ) .getParameter ( 0 )
497510 )
498511 }
Original file line number Diff line number Diff line change 3535| arrays.js:120:19:120:26 | "source" | arrays.js:121:46:121:49 | item |
3636| arrays.js:120:19:120:26 | "source" | arrays.js:122:10:122:16 | element |
3737| arrays.js:126:19:126:26 | "source" | arrays.js:127:55:127:58 | item |
38+ | arrays.js:131:17:131:24 | source() | arrays.js:132:46:132:49 | item |
3839| arrays.js:131:17:131:24 | source() | arrays.js:133:10:133:17 | element1 |
40+ | arrays.js:137:17:137:24 | source() | arrays.js:138:50:138:53 | item |
3941| arrays.js:137:17:137:24 | source() | arrays.js:139:10:139:17 | element1 |
42+ | arrays.js:143:17:143:24 | source() | arrays.js:144:55:144:58 | item |
Original file line number Diff line number Diff line change 129129 }
130130 {
131131 const arr = source ( ) ;
132- const element1 = arr . find ( ( item ) => sink ( item ) ) ; // NOT OK - only found with taint-tracking.
132+ const element1 = arr . find ( ( item ) => sink ( item ) ) ; // NOT OK
133133 sink ( element1 ) ; // NOT OK
134134 }
135135
136136 {
137137 const arr = source ( ) ;
138- const element1 = arr . findLast ( ( item ) => sink ( item ) ) ; // NOT OK - only found with taint-tracking.
138+ const element1 = arr . findLast ( ( item ) => sink ( item ) ) ; // NOT OK
139139 sink ( element1 ) ; // NOT OK
140140 }
141141
142142 {
143143 const arr = source ( ) ;
144- const element1 = arr . findLastIndex ( ( item ) => sink ( item ) ) ; // NOT OK - only found with taint-tracking.
144+ const element1 = arr . findLastIndex ( ( item ) => sink ( item ) ) ; // NOT OK
145145 sink ( element1 ) ; // OK
146146 }
147147} ) ;
You can’t perform that action at this time.
0 commit comments