File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed
test/library-tests/Arrays Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -483,4 +483,18 @@ private module ArrayLibraries {
483
483
)
484
484
}
485
485
}
486
+
487
+ /**
488
+ * Defines a data flow step that tracks the flow of data through callback functions in arrays.
489
+ */
490
+ private class ArrayCallBackDataFlowStep extends PreCallGraphStep {
491
+ override predicate loadStep ( DataFlow:: Node obj , DataFlow:: Node element , string prop ) {
492
+ exists ( DataFlow:: MethodCallNode call |
493
+ call .getMethodName ( ) = [ "findLast" , "find" , "findLastIndex" ] and
494
+ prop = arrayLikeElement ( ) and
495
+ obj = call .getReceiver ( ) and
496
+ element = call .getCallback ( 0 ) .getParameter ( 0 )
497
+ )
498
+ }
499
+ }
486
500
}
Original file line number Diff line number Diff line change 26
26
| arrays.js:53:4:53:11 | "source" | arrays.js:54:10:54:18 | ary.pop() |
27
27
| arrays.js:99:31:99:38 | "source" | arrays.js:100:8:100:17 | arr8.pop() |
28
28
| arrays.js:103:55:103:62 | "source" | arrays.js:105:8:105:25 | arr8_variant.pop() |
29
+ | arrays.js:114:19:114:26 | "source" | arrays.js:115:50:115:53 | item |
29
30
| arrays.js:114:19:114:26 | "source" | arrays.js:116:10:116:16 | element |
31
+ | arrays.js:120:19:120:26 | "source" | arrays.js:121:46:121:49 | item |
30
32
| arrays.js:120:19:120:26 | "source" | arrays.js:122:10:122:16 | element |
33
+ | arrays.js:126:19:126:26 | "source" | arrays.js:127:55:127:58 | item |
Original file line number Diff line number Diff line change 30
30
| arrays.js:96:9:96:16 | "source" | arrays.js:96:8:96:36 | ["sourc ... => !!x) |
31
31
| arrays.js:99:31:99:38 | "source" | arrays.js:100:8:100:17 | arr8.pop() |
32
32
| arrays.js:103:55:103:62 | "source" | arrays.js:105:8:105:25 | arr8_variant.pop() |
33
+ | arrays.js:114:19:114:26 | "source" | arrays.js:115:50:115:53 | item |
33
34
| arrays.js:114:19:114:26 | "source" | arrays.js:116:10:116:16 | element |
35
+ | arrays.js:120:19:120:26 | "source" | arrays.js:121:46:121:49 | item |
34
36
| arrays.js:120:19:120:26 | "source" | arrays.js:122:10:122:16 | element |
37
+ | arrays.js:126:19:126:26 | "source" | arrays.js:127:55:127:58 | item |
Original file line number Diff line number Diff line change 112
112
113
113
{ // Test for findLast function
114
114
const list = [ "source" ] ;
115
- const element = list . findLast ( ( item ) => sink ( item ) ) ; // NOT OK -- Not caught, currently missing dataflow tracking.
115
+ const element = list . findLast ( ( item ) => sink ( item ) ) ; // NOT OK
116
116
sink ( element ) ; // NOT OK
117
117
}
118
118
119
119
{ // Test for find function
120
120
const list = [ "source" ] ;
121
- const element = list . find ( ( item ) => sink ( item ) ) ; // NOT OK -- Not caught, currently missing dataflow tracking.
121
+ const element = list . find ( ( item ) => sink ( item ) ) ; // NOT OK
122
122
sink ( element ) ; // NOT OK
123
123
}
124
124
125
125
{ // Test for findLastIndex function
126
126
const list = [ "source" ] ;
127
- const element = list . findLastIndex ( ( item ) => sink ( item ) ) ; // NOT OK -- Not caught, currently missing dataflow tracking.
127
+ const element = list . findLastIndex ( ( item ) => sink ( item ) ) ; // NOT OK
128
128
sink ( element ) ; // OK
129
129
}
130
130
} ) ;
You can’t perform that action at this time.
0 commit comments