@@ -348,6 +348,16 @@ private Element adjustedSink(DataFlow::Node sink) {
348
348
result .( AssignOperation ) .getAnOperand ( ) = sink .asExpr ( )
349
349
}
350
350
351
+ /**
352
+ * Holds if `tainted` may contain taint from `source`.
353
+ *
354
+ * A tainted expression is either directly user input, or is
355
+ * computed from user input in a way that users can probably
356
+ * control the exact output of the computation.
357
+ *
358
+ * This doesn't include data flow through global variables.
359
+ * If you need that you must call `taintedIncludingGlobalVars`.
360
+ */
351
361
cached
352
362
predicate tainted ( Expr source , Element tainted ) {
353
363
exists ( DefaultTaintTrackingCfg cfg , DataFlow:: Node sink |
@@ -356,6 +366,21 @@ predicate tainted(Expr source, Element tainted) {
356
366
)
357
367
}
358
368
369
+ /**
370
+ * Holds if `tainted` may contain taint from `source`, where the taint passed
371
+ * through a global variable named `globalVar`.
372
+ *
373
+ * A tainted expression is either directly user input, or is
374
+ * computed from user input in a way that users can probably
375
+ * control the exact output of the computation.
376
+ *
377
+ * This version gives the same results as tainted but also includes
378
+ * data flow through global variables.
379
+ *
380
+ * The parameter `globalVar` is the qualified name of the last global variable
381
+ * used to move the value from source to tainted. If the taint did not pass
382
+ * through a global variable, then `globalVar = ""`.
383
+ */
359
384
cached
360
385
predicate taintedIncludingGlobalVars ( Expr source , Element tainted , string globalVar ) {
361
386
tainted ( source , tainted ) and
@@ -373,8 +398,26 @@ predicate taintedIncludingGlobalVars(Expr source, Element tainted, string global
373
398
)
374
399
}
375
400
401
+ /**
402
+ * Gets the global variable whose qualified name is `id`. Use this predicate
403
+ * together with `taintedIncludingGlobalVars`. Example:
404
+ *
405
+ * ```
406
+ * exists(string varName |
407
+ * taintedIncludingGlobalVars(source, tainted, varName) and
408
+ * var = globalVarFromId(varName)
409
+ * )
410
+ * ```
411
+ */
376
412
GlobalOrNamespaceVariable globalVarFromId ( string id ) { id = result .getQualifiedName ( ) }
377
413
414
+ /**
415
+ * Resolve potential target function(s) for `call`.
416
+ *
417
+ * If `call` is a call through a function pointer (`ExprCall`) or
418
+ * targets a virtual method, simple data flow analysis is performed
419
+ * in order to identify target(s).
420
+ */
378
421
Function resolveCall ( Call call ) {
379
422
exists ( CallInstruction callInstruction |
380
423
callInstruction .getAST ( ) = call and
0 commit comments