mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
C++: Speed up cpp/cleartext-transmission ('Encrypted' class).
This commit is contained in:
@@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user