CPP: Do the logic at the target, rather than the access, as there are likely fewer.

This commit is contained in:
Geoffrey White
2019-12-03 10:52:31 +00:00
parent 20eb39d37e
commit cc43e1116b

View File

@@ -15,16 +15,24 @@ private predicate suspicious(string s) {
) )
} }
abstract class SensitiveExpr extends Expr { } class SensitiveVariable extends Variable {
SensitiveVariable()
class SensitiveVarAccess extends SensitiveExpr { {
SensitiveVarAccess() { suspicious(getName().toLowerCase())
suspicious(this.(VariableAccess).getTarget().getName().toLowerCase())
} }
} }
class SensitiveCall extends SensitiveExpr { class SensitiveFunction extends Function {
SensitiveCall() { SensitiveFunction()
suspicious(this.(FunctionCall).getTarget().getName().toLowerCase()) {
suspicious(getName().toLowerCase())
}
}
class SensitiveExpr extends Expr {
SensitiveExpr()
{
this.(VariableAccess).getTarget() instanceof SensitiveVariable or
this.(FunctionCall).getTarget() instanceof SensitiveFunction
} }
} }