File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
cpp/ql/src/Security/CWE/CWE-311 Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff 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 {
177187class 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}
You can’t perform that action at this time.
0 commit comments