C++: Speed up cpp/cleartext-transmission ('Encrypted' class).

This commit is contained in:
Geoffrey White
2022-02-07 14:07:02 +00:00
parent 55e69d421c
commit 005dfdffdb

View File

@@ -168,6 +168,18 @@ class NetworkRecv extends NetworkSendRecv {
override Recv target;
}
predicate encryptionFunction(Function f)
{
f.getName()
.toLowerCase()
.regexpMatch(".*(crypt|encode|decode|hash|securezero).*")
}
predicate encryptionType(Type t)
{
t.getName().toLowerCase().regexpMatch(".*(crypt|encode|decode|hash|securezero).*")
}
/**
* An expression that is an argument or return value from an encryption /
* decryption call. This is quite inclusive to minimize false positives, for
@@ -177,10 +189,7 @@ class NetworkRecv extends NetworkSendRecv {
class Encrypted extends Expr {
Encrypted() {
exists(FunctionCall fc |
fc.getTarget()
.getName()
.toLowerCase()
.regexpMatch(".*(crypt|encode|decode|hash|securezero).*") and
encryptionFunction(fc.getTarget()) and
(
this = fc or
this = fc.getAnArgument()
@@ -189,7 +198,7 @@ class Encrypted extends Expr {
or
exists(Type t |
this.getType().refersTo(t) and
t.getName().toLowerCase().regexpMatch(".*(crypt|encode|decode|hash|securezero).*")
encryptionType(t)
)
}
}