@@ -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,19 @@ 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`.
404
+ */
376
405
GlobalOrNamespaceVariable globalVarFromId ( string id ) { id = result .getQualifiedName ( ) }
377
406
407
+ /**
408
+ * Resolve potential target function(s) for `call`.
409
+ *
410
+ * If `call` is a call through a function pointer (`ExprCall`) or
411
+ * targets a virtual method, simple data flow analysis is performed
412
+ * in order to identify target(s).
413
+ */
378
414
Function resolveCall ( Call call ) {
379
415
exists ( CallInstruction callInstruction |
380
416
callInstruction .getAST ( ) = call and
0 commit comments