Skip to content

Commit 1980e25

Browse files
authored
Merge pull request github#12120 from MathiasVP/even-fewer-strings
C++: Avoid unnecessary calls to `toLowerCase()`
2 parents 984729f + 746f04b commit 1980e25

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ import cpp
1414
*/
1515
bindingset[s]
1616
private predicate suspicious(string s) {
17-
s.regexpMatch(".*(password|passwd|accountid|account.?key|accnt.?key|license.?key|trusted).*") and
18-
not s.matches(["%hash%", "%crypt%", "%file%", "%path%", "%invalid%"])
17+
s.regexpMatch("(?i).*(password|passwd|accountid|account.?key|accnt.?key|license.?key|trusted).*") and
18+
not s.regexpMatch("(?i).*(hash|crypt|file|path|invalid).*")
1919
}
2020

2121
/**
2222
* A variable that might contain a password or other credential.
2323
*/
2424
class SensitiveVariable extends Variable {
2525
SensitiveVariable() {
26-
suspicious(this.getName().toLowerCase()) and
26+
suspicious(this.getName()) and
2727
not this.getUnspecifiedType() instanceof IntegralType
2828
}
2929
}
@@ -33,7 +33,7 @@ class SensitiveVariable extends Variable {
3333
*/
3434
class SensitiveFunction extends Function {
3535
SensitiveFunction() {
36-
suspicious(this.getName().toLowerCase()) and
36+
suspicious(this.getName()) and
3737
not this.getUnspecifiedType() instanceof IntegralType
3838
}
3939
}

0 commit comments

Comments
 (0)