File tree Expand file tree Collapse file tree 6 files changed +47
-0
lines changed
src/semmle/javascript/dataflow
test/library-tests/TaintBarriers Expand file tree Collapse file tree 6 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1010
1111* Modelling of taint flow through the array operations ` map ` and ` join ` has been improved. This may give additional results for the security queries.
1212
13+ * The taint tracking library now recognizes additional sanitization patterns. This may give fewer false-positive results for the security queries.
14+
1315* Support for popular libraries has been improved. Consequently, queries may produce more results on code bases that use the following libraries:
1416 - [ bluebird] ( http://bluebirdjs.com )
1517 - [ browserid-crypto] ( https://github.com/mozilla/browserid-crypto )
Original file line number Diff line number Diff line change @@ -612,6 +612,26 @@ module TaintTracking {
612612
613613 }
614614
615+ /** A check of the form `if(~o.indexOf(x))`, which sanitizes `x` in its "then" branch. */
616+ class BitwiseIndexOfSanitizer extends AdditionalSanitizerGuardNode , DataFlow:: ValueNode {
617+ MethodCallExpr indexOf ;
618+ override BitNotExpr astNode ;
619+
620+ BitwiseIndexOfSanitizer ( ) {
621+ astNode .getOperand ( ) = indexOf and
622+ indexOf .getMethodName ( ) = "indexOf"
623+ }
624+
625+ override predicate sanitizes ( boolean outcome , Expr e ) {
626+ outcome = true and
627+ e = indexOf .getArgument ( 0 )
628+ }
629+
630+ override predicate appliesTo ( Configuration cfg ) {
631+ any ( )
632+ }
633+
634+ }
615635
616636 /** A check of the form `if(x == 'some-constant')`, which sanitizes `x` in its "then" branch. */
617637 class ConstantComparison extends AdditionalSanitizerGuardNode , DataFlow:: ValueNode {
Original file line number Diff line number Diff line change 2929| tst.js:160:9:160:30 | v === " ... sted-1" | ExampleConfiguration | true | tst.js:160:9:160:9 | v |
3030| tst.js:160:35:160:56 | v === " ... sted-2" | ExampleConfiguration | true | tst.js:160:35:160:35 | v |
3131| tst.js:166:9:166:16 | v == !!0 | ExampleConfiguration | true | tst.js:166:9:166:9 | v |
32+ | tst.js:184:9:184:21 | ~o.indexOf(v) | ExampleConfiguration | true | tst.js:184:20:184:20 | v |
33+ | tst.js:190:10:190:22 | ~o.indexOf(v) | ExampleConfiguration | true | tst.js:190:21:190:21 | v |
Original file line number Diff line number Diff line change 2525| tst.js:155:14:155:14 | v | tst.js:145:13:145:20 | SOURCE() |
2626| tst.js:163:14:163:14 | v | tst.js:145:13:145:20 | SOURCE() |
2727| tst.js:169:14:169:14 | v | tst.js:145:13:145:20 | SOURCE() |
28+ | tst.js:182:10:182:10 | v | tst.js:181:13:181:20 | SOURCE() |
29+ | tst.js:187:14:187:14 | v | tst.js:181:13:181:20 | SOURCE() |
30+ | tst.js:191:14:191:14 | v | tst.js:181:13:181:20 | SOURCE() |
Original file line number Diff line number Diff line change 2222| tst.js:160:35:160:56 | v | ExampleConfiguration |
2323| tst.js:167:14:167:14 | v | ExampleConfiguration |
2424| tst.js:176:18:176:18 | v | ExampleConfiguration |
25+ | tst.js:185:14:185:14 | v | ExampleConfiguration |
26+ | tst.js:193:14:193:14 | v | ExampleConfiguration |
Original file line number Diff line number Diff line change @@ -176,3 +176,21 @@ function customSanitizer() {
176176 v = SANITIZE ( v ) ;
177177 SINK ( v ) ;
178178}
179+
180+ function BitwiseIndexOfCheckSanitizer ( ) {
181+ var v = SOURCE ( ) ;
182+ SINK ( v ) ;
183+
184+ if ( ~ o . indexOf ( v ) ) {
185+ SINK ( v ) ;
186+ } else {
187+ SINK ( v ) ;
188+ }
189+
190+ if ( ! ~ o . indexOf ( v ) ) {
191+ SINK ( v ) ;
192+ } else {
193+ SINK ( v ) ;
194+ }
195+
196+ }
You can’t perform that action at this time.
0 commit comments