@@ -164,9 +164,7 @@ class NonConstantTimeComparisonSink extends DataFlow::Node {
164
164
165
165
/** Holds if remote user input was used in the comparison. */
166
166
predicate includesUserInput ( ) {
167
- exists ( UserInputInComparisonConfig config |
168
- config .hasFlowTo ( DataFlow2:: exprNode ( anotherParameter ) )
169
- )
167
+ UserInputInComparisonFlow:: flowTo ( DataFlow2:: exprNode ( anotherParameter ) )
170
168
}
171
169
}
172
170
@@ -177,9 +175,7 @@ class SecretSource extends DataFlow::Node {
177
175
SecretSource ( ) { secret = this .asExpr ( ) }
178
176
179
177
/** Holds if the secret was deliverd by remote user. */
180
- predicate includesUserInput ( ) {
181
- exists ( UserInputSecretConfig config | config .hasFlowTo ( DataFlow2:: exprNode ( secret ) ) )
182
- }
178
+ predicate includesUserInput ( ) { UserInputSecretFlow:: flowTo ( DataFlow2:: exprNode ( secret ) ) }
183
179
}
184
180
185
181
/** A string for `match` that identifies strings that look like they represent secret data. */
@@ -267,23 +263,21 @@ private string sensitiveheaders() {
267
263
/**
268
264
* A config that tracks data flow from remote user input to Variable that hold sensitive info
269
265
*/
270
- class UserInputSecretConfig extends TaintTracking :: Configuration {
271
- UserInputSecretConfig ( ) { this = "UserInputSecretConfig" }
266
+ module UserInputSecretConfig implements DataFlow :: ConfigSig {
267
+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
272
268
273
- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
274
-
275
- override predicate isSink ( DataFlow:: Node sink ) { sink .asExpr ( ) instanceof CredentialExpr }
269
+ predicate isSink ( DataFlow:: Node sink ) { sink .asExpr ( ) instanceof CredentialExpr }
276
270
}
277
271
272
+ module UserInputSecretFlow = TaintTracking:: Global< UserInputSecretConfig > ;
273
+
278
274
/**
279
275
* A config that tracks data flow from remote user input to Equality test
280
276
*/
281
- class UserInputInComparisonConfig extends TaintTracking2 :: Configuration {
282
- UserInputInComparisonConfig ( ) { this = "UserInputInComparisonConfig" }
277
+ module UserInputInComparisonConfig implements DataFlow :: ConfigSig {
278
+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
283
279
284
- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
285
-
286
- override predicate isSink ( DataFlow:: Node sink ) {
280
+ predicate isSink ( DataFlow:: Node sink ) {
287
281
exists ( Compare cmp , Expr left , Expr right , Cmpop cmpop |
288
282
cmpop .getSymbol ( ) = [ "==" , "in" , "is not" , "!=" ] and
289
283
cmp .compares ( left , cmpop , right ) and
@@ -292,22 +286,24 @@ class UserInputInComparisonConfig extends TaintTracking2::Configuration {
292
286
}
293
287
}
294
288
289
+ module UserInputInComparisonFlow = TaintTracking:: Global< UserInputInComparisonConfig > ;
290
+
295
291
/**
296
292
* A configuration tracing flow from a client Secret obtained by an HTTP header to a len() function.
297
293
*/
298
- private class ExcludeLenFunc extends TaintTracking2:: Configuration {
299
- ExcludeLenFunc ( ) { this = "ExcludeLenFunc" }
300
-
301
- override predicate isSource ( DataFlow:: Node source ) { source instanceof ClientSuppliedSecret }
294
+ private module ExcludeLenFuncConfig implements DataFlow:: ConfigSig {
295
+ predicate isSource ( DataFlow:: Node source ) { source instanceof ClientSuppliedSecret }
302
296
303
- override predicate isSink ( DataFlow:: Node sink ) {
297
+ predicate isSink ( DataFlow:: Node sink ) {
304
298
exists ( Call call |
305
299
call .getFunc ( ) .( Name ) .getId ( ) = "len" and
306
300
sink .asExpr ( ) = call .getArg ( 0 )
307
301
)
308
302
}
309
303
}
310
304
305
+ module ExcludeLenFuncFlow = TaintTracking:: Global< ExcludeLenFuncConfig > ;
306
+
311
307
/**
312
308
* Holds if there is a fast-fail check.
313
309
*/
@@ -343,8 +339,7 @@ class CompareSink extends DataFlow::Node {
343
339
* Holds if there is a flow to len().
344
340
*/
345
341
predicate flowtolen ( ) {
346
- exists ( ExcludeLenFunc config , DataFlow2:: PathNode source , DataFlow2:: PathNode sink |
347
- config .hasFlowPath ( source , sink )
348
- )
342
+ // TODO: Fly by comment: I don't understand this code at all, seems very strange.
343
+ ExcludeLenFuncFlow:: flowPath ( _, _)
349
344
}
350
345
}
0 commit comments