File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
javascript/ql/test/library-tests/TaintBarriers Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1
1
import javascript
2
2
3
+ DataFlow:: Node sourceVariable ( ) { result .asExpr ( ) .( VarRef ) .getName ( ) = "sourceVariable" }
4
+
5
+ StringOps:: ConcatenationRoot sinkConcatenation ( ) {
6
+ result .getConstantStringParts ( ) .matches ( "<sink>%</sink>" )
7
+ }
8
+
3
9
class ExampleConfiguration extends TaintTracking:: Configuration {
4
10
ExampleConfiguration ( ) { this = "ExampleConfiguration" }
5
11
6
12
override predicate isSource ( DataFlow:: Node source ) {
7
13
source .asExpr ( ) .( CallExpr ) .getCalleeName ( ) = "SOURCE"
14
+ or
15
+ source = sourceVariable ( )
8
16
}
9
17
10
18
override predicate isSink ( DataFlow:: Node sink ) {
11
19
exists ( CallExpr callExpr |
12
20
callExpr .getCalleeName ( ) = "SINK" and
13
21
DataFlow:: valueNode ( callExpr .getArgument ( 0 ) ) = sink
14
22
)
23
+ or
24
+ sink = sinkConcatenation ( )
15
25
}
16
26
27
+ override predicate isSanitizerIn ( DataFlow:: Node node ) { node = sourceVariable ( ) }
28
+
29
+ override predicate isSanitizerOut ( DataFlow:: Node node ) { node = sinkConcatenation ( ) }
30
+
17
31
override predicate isSanitizer ( DataFlow:: Node node ) {
18
32
exists ( CallExpr callExpr |
19
33
callExpr .getCalleeName ( ) = "SANITIZE" and
Original file line number Diff line number Diff line change
1
+ import 'dummy' ;
2
+
3
+ function barrierIn ( ) {
4
+ var sourceVariable = 123 ;
5
+ SINK ( sourceVariable ) ; // NOT OK
6
+
7
+ flowWithSourceParam ( sourceVariable ) ;
8
+ }
9
+
10
+ function barrierInParameter ( sourceVariable ) {
11
+ SINK ( sourceVariable ) ; // NOT OK, but only report the parameter as the source
12
+ }
13
+
14
+ function barrierOut ( ) {
15
+ let taint = SOURCE ( ) ;
16
+ taint = "<sink>" + taint + "</sink>" ; // NOT OK
17
+ taint = "<sink>" + taint + "</sink>" ; // OK - only report first instance
18
+ }
Original file line number Diff line number Diff line change @@ -133,6 +133,9 @@ sanitizingGuard
133
133
| tst.js:399:16:399:41 | o.hasOw ... "p.q"]) | tst.js:399:33:399:40 | v["p.q"] | true |
134
134
| tst.js:401:16:401:34 | Object.hasOwn(o, v) | tst.js:401:33:401:33 | v | true |
135
135
taintedSink
136
+ | sanitizer-in-out.js:5:10:5:23 | sourceVariable | sanitizer-in-out.js:5:10:5:23 | sourceVariable |
137
+ | sanitizer-in-out.js:11:10:11:23 | sourceVariable | sanitizer-in-out.js:11:10:11:23 | sourceVariable |
138
+ | sanitizer-in-out.js:15:17:15:24 | SOURCE() | sanitizer-in-out.js:16:13:16:40 | "<sink> ... /sink>" |
136
139
| tst.js:2:13:2:20 | SOURCE() | tst.js:3:10:3:10 | v |
137
140
| tst.js:2:13:2:20 | SOURCE() | tst.js:8:14:8:14 | v |
138
141
| tst.js:2:13:2:20 | SOURCE() | tst.js:12:14:12:14 | v |
You can’t perform that action at this time.
0 commit comments