Skip to content

Commit cc43e11

Browse files
committed
CPP: Do the logic at the target, rather than the access, as there are likely fewer.
1 parent 20eb39d commit cc43e11

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

cpp/ql/src/semmle/code/cpp/security/SensitiveExprs.qll

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,24 @@ private predicate suspicious(string s) {
1515
)
1616
}
1717

18-
abstract class SensitiveExpr extends Expr { }
18+
class SensitiveVariable extends Variable {
19+
SensitiveVariable()
20+
{
21+
suspicious(getName().toLowerCase())
22+
}
23+
}
1924

20-
class SensitiveVarAccess extends SensitiveExpr {
21-
SensitiveVarAccess() {
22-
suspicious(this.(VariableAccess).getTarget().getName().toLowerCase())
25+
class SensitiveFunction extends Function {
26+
SensitiveFunction()
27+
{
28+
suspicious(getName().toLowerCase())
2329
}
2430
}
2531

26-
class SensitiveCall extends SensitiveExpr {
27-
SensitiveCall() {
28-
suspicious(this.(FunctionCall).getTarget().getName().toLowerCase())
32+
class SensitiveExpr extends Expr {
33+
SensitiveExpr()
34+
{
35+
this.(VariableAccess).getTarget() instanceof SensitiveVariable or
36+
this.(FunctionCall).getTarget() instanceof SensitiveFunction
2937
}
3038
}

0 commit comments

Comments
 (0)