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 SensitiveVarAccess extends SensitiveExpr {
SensitiveVarAccess() {
suspicious(this.(VariableAccess).getTarget().getName().toLowerCase())
class SensitiveVariable extends Variable {
SensitiveVariable()
{
suspicious(getName().toLowerCase())
}
}
class SensitiveCall extends SensitiveExpr {
SensitiveCall() {
suspicious(this.(FunctionCall).getTarget().getName().toLowerCase())
class SensitiveFunction extends Function {
SensitiveFunction()
{
suspicious(getName().toLowerCase())
}
}
class SensitiveExpr extends Expr {
SensitiveExpr()
{
this.(VariableAccess).getTarget() instanceof SensitiveVariable or
this.(FunctionCall).getTarget() instanceof SensitiveFunction
}
}