File tree Expand file tree Collapse file tree 5 files changed +396
-137
lines changed
javascript/ql/test/library-tests/Arrays Expand file tree Collapse file tree 5 files changed +396
-137
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ import javascript
3
3
class ArrayFlowConfig extends DataFlow:: Configuration {
4
4
ArrayFlowConfig ( ) { this = "ArrayFlowConfig" }
5
5
6
- override predicate isSource ( DataFlow:: Node source ) { source .asExpr ( ) .getStringValue ( ) = "source" }
6
+ override predicate isSource ( DataFlow:: Node source ) {
7
+ source .asExpr ( ) .getStringValue ( ) = "source" or
8
+ source .( DataFlow:: CallNode ) .getCalleeName ( ) = "source"
9
+ }
7
10
8
11
override predicate isSink ( DataFlow:: Node sink ) {
9
12
sink = any ( DataFlow:: CallNode call | call .getCalleeName ( ) = "sink" ) .getAnArgument ( )
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:133:10:133:17 | element1 |
39
+ | arrays.js:137:17:137:24 | source() | arrays.js:139:10:139:17 | element1 |
Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ import javascript
3
3
class ArrayTaintFlowConfig extends TaintTracking:: Configuration {
4
4
ArrayTaintFlowConfig ( ) { this = "ArrayTaintFlowConfig" }
5
5
6
- override predicate isSource ( DataFlow:: Node source ) { source .asExpr ( ) .getStringValue ( ) = "source" }
6
+ override predicate isSource ( DataFlow:: Node source ) {
7
+ source .asExpr ( ) .getStringValue ( ) = "source" or
8
+ source .( DataFlow:: CallNode ) .getCalleeName ( ) = "source"
9
+ }
7
10
8
11
override predicate isSink ( DataFlow:: Node sink ) {
9
12
sink = any ( DataFlow:: CallNode call | call .getCalleeName ( ) = "sink" ) .getAnArgument ( )
Original file line number Diff line number Diff line change 127
127
const element = list . findLastIndex ( ( item ) => sink ( item ) ) ; // NOT OK
128
128
sink ( element ) ; // OK
129
129
}
130
+ {
131
+ const arr = source ( ) ;
132
+ const element1 = arr . find ( ( item ) => sink ( item ) ) ; // NOT OK - only found with taint-tracking.
133
+ sink ( element1 ) ; // NOT OK
134
+ }
135
+
136
+ {
137
+ const arr = source ( ) ;
138
+ const element1 = arr . findLast ( ( item ) => sink ( item ) ) ; // NOT OK - only found with taint-tracking.
139
+ sink ( element1 ) ; // NOT OK
140
+ }
141
+
142
+ {
143
+ const arr = source ( ) ;
144
+ const element1 = arr . findLastIndex ( ( item ) => sink ( item ) ) ; // NOT OK - only found with taint-tracking.
145
+ sink ( element1 ) ; // OK
146
+ }
130
147
} ) ;
You can’t perform that action at this time.
0 commit comments