File tree Expand file tree Collapse file tree
cpp/ql/src/semmle/code/cpp/security Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import cpp
22
3- private string suspicious ( ) {
4- result = "%password%" or
5- result = "%passwd%" or
6- result = "%account%" or
7- result = "%accnt%" or
8- result = "%trusted%"
9- }
10-
11- private string nonSuspicious ( ) {
12- result = "%hashed%" or
13- result = "%encrypted%" or
14- result = "%crypt%"
3+ bindingset [ s]
4+ private predicate suspicious ( string s ) {
5+ (
6+ s .matches ( "%password%" ) or
7+ s .matches ( "%passwd%" ) or
8+ s .matches ( "%account%" ) or
9+ s .matches ( "%accnt%" ) or
10+ s .matches ( "%trusted%" )
11+ ) and not (
12+ s .matches ( "%hashed%" ) or
13+ s .matches ( "%encrypted%" ) or
14+ s .matches ( "%crypt%" )
15+ )
1516}
1617
1718abstract class SensitiveExpr extends Expr { }
@@ -20,8 +21,7 @@ class SensitiveVarAccess extends SensitiveExpr {
2021 SensitiveVarAccess ( ) {
2122 this instanceof VariableAccess and
2223 exists ( string s | this .toString ( ) .toLowerCase ( ) = s |
23- s .matches ( suspicious ( ) ) and
24- not s .matches ( nonSuspicious ( ) )
24+ suspicious ( s )
2525 )
2626 }
2727}
@@ -30,8 +30,7 @@ class SensitiveCall extends SensitiveExpr {
3030 SensitiveCall ( ) {
3131 this instanceof FunctionCall and
3232 exists ( string s | this .toString ( ) .toLowerCase ( ) = s |
33- s .matches ( suspicious ( ) ) and
34- not s .matches ( nonSuspicious ( ) )
33+ suspicious ( s )
3534 )
3635 }
3736}
You can’t perform that action at this time.
0 commit comments