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 {
492
492
exists ( DataFlow:: MethodCallNode call |
493
493
call .getMethodName ( ) = [ "findLast" , "find" , "findLastIndex" ] and
494
494
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
496
509
element = call .getCallback ( 0 ) .getParameter ( 0 )
497
510
)
498
511
}
Original file line number Diff line number Diff line change 35
35
| arrays.js:120:19:120:26 | "source" | arrays.js:121:46:121:49 | item |
36
36
| arrays.js:120:19:120:26 | "source" | arrays.js:122:10:122:16 | element |
37
37
| 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 |
38
39
| 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 |
39
41
| 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 129
129
}
130
130
{
131
131
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
133
133
sink ( element1 ) ; // NOT OK
134
134
}
135
135
136
136
{
137
137
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
139
139
sink ( element1 ) ; // NOT OK
140
140
}
141
141
142
142
{
143
143
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
145
145
sink ( element1 ) ; // OK
146
146
}
147
147
} ) ;
You can’t perform that action at this time.
0 commit comments