Skip to content

Commit bbbb526

Browse files
authored
Merge pull request github#7881 from geoffw0/clrtxtperf
CPP: Fix performance for cpp/cleartext-transmission
2 parents 3206384 + 6005f3d commit bbbb526

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cpp/ql/src/Security/CWE/CWE-311/CleartextTransmission.ql

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ class NetworkRecv extends NetworkSendRecv {
168168
override Recv target;
169169
}
170170

171+
pragma[noinline]
172+
predicate encryptionFunction(Function f) {
173+
f.getName().toLowerCase().regexpMatch(".*(crypt|encode|decode|hash|securezero).*")
174+
}
175+
176+
pragma[noinline]
177+
predicate encryptionType(UserType t) {
178+
t.getName().toLowerCase().regexpMatch(".*(crypt|encode|decode|hash|securezero).*")
179+
}
180+
171181
/**
172182
* An expression that is an argument or return value from an encryption /
173183
* decryption call. This is quite inclusive to minimize false positives, for
@@ -177,10 +187,7 @@ class NetworkRecv extends NetworkSendRecv {
177187
class Encrypted extends Expr {
178188
Encrypted() {
179189
exists(FunctionCall fc |
180-
fc.getTarget()
181-
.getName()
182-
.toLowerCase()
183-
.regexpMatch(".*(crypt|encode|decode|hash|securezero).*") and
190+
encryptionFunction(fc.getTarget()) and
184191
(
185192
this = fc or
186193
this = fc.getAnArgument()
@@ -189,7 +196,7 @@ class Encrypted extends Expr {
189196
or
190197
exists(Type t |
191198
this.getType().refersTo(t) and
192-
t.getName().toLowerCase().regexpMatch(".*(crypt|encode|decode|hash|securezero).*")
199+
encryptionType(t)
193200
)
194201
}
195202
}

0 commit comments

Comments
 (0)