Skip to content

Commit 3f206cc

Browse files
committed
Swift: Simplify out toLowerCase().
1 parent 047494d commit 3f206cc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

swift/ql/lib/codeql/swift/security/SensitiveExprs.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SensitivePrivateInfo extends SensitiveDataType, TPrivateInfo {
4343

4444
override string getRegexp() {
4545
result =
46-
".*(" +
46+
"(?is).*(" +
4747
// Inspired by the list on https://cwe.mitre.org/data/definitions/359.html
4848
// Government identifiers, such as Social Security Numbers
4949
"social.?security|national.?insurance|" +
@@ -82,7 +82,7 @@ private string regexpProbablySafe() {
8282
private class SensitiveVarDecl extends VarDecl {
8383
SensitiveDataType sensitiveType;
8484

85-
SensitiveVarDecl() { this.getName().toLowerCase().regexpMatch(sensitiveType.getRegexp()) }
85+
SensitiveVarDecl() { this.getName().regexpMatch(sensitiveType.getRegexp()) }
8686

8787
predicate hasInfo(string label, SensitiveDataType type) {
8888
label = this.getName() and
@@ -99,7 +99,7 @@ private class SensitiveFunction extends Function {
9999

100100
SensitiveFunction() {
101101
name = this.getName().splitAt("(", 0) and
102-
name.toLowerCase().regexpMatch(sensitiveType.getRegexp())
102+
name.regexpMatch(sensitiveType.getRegexp())
103103
}
104104

105105
predicate hasInfo(string label, SensitiveDataType type) {
@@ -114,7 +114,7 @@ private class SensitiveFunction extends Function {
114114
private class SensitiveArgument extends Argument {
115115
SensitiveDataType sensitiveType;
116116

117-
SensitiveArgument() { this.getLabel().toLowerCase().regexpMatch(sensitiveType.getRegexp()) }
117+
SensitiveArgument() { this.getLabel().regexpMatch(sensitiveType.getRegexp()) }
118118

119119
predicate hasInfo(string label, SensitiveDataType type) {
120120
label = this.getLabel() and
@@ -147,7 +147,7 @@ class SensitiveExpr extends Expr {
147147
)
148148
) and
149149
// do not mark as sensitive it if it is probably safe
150-
not label.toLowerCase().regexpMatch(regexpProbablySafe())
150+
not label.regexpMatch(regexpProbablySafe())
151151
}
152152

153153
/**
@@ -165,7 +165,7 @@ class SensitiveExpr extends Expr {
165165
* A function that is likely used to encrypt or hash data.
166166
*/
167167
private class EncryptionFunction extends Function {
168-
EncryptionFunction() { this.getName().regexpMatch(".*(crypt|hash|encode|protect).*") }
168+
EncryptionFunction() { this.getName().regexpMatch("(?is).*(crypt|hash|encode|protect).*") }
169169
}
170170

171171
/**

0 commit comments

Comments
 (0)