File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
cpp/ql/src/Security/CWE/CWE-311 Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,18 @@ class NetworkRecv extends NetworkSendRecv {
168168 override Recv target ;
169169}
170170
171+ predicate encryptionFunction ( Function f )
172+ {
173+ f .getName ( )
174+ .toLowerCase ( )
175+ .regexpMatch ( ".*(crypt|encode|decode|hash|securezero).*" )
176+ }
177+
178+ predicate encryptionType ( Type t )
179+ {
180+ t .getName ( ) .toLowerCase ( ) .regexpMatch ( ".*(crypt|encode|decode|hash|securezero).*" )
181+ }
182+
171183/**
172184 * An expression that is an argument or return value from an encryption /
173185 * decryption call. This is quite inclusive to minimize false positives, for
@@ -177,10 +189,7 @@ class NetworkRecv extends NetworkSendRecv {
177189class Encrypted extends Expr {
178190 Encrypted ( ) {
179191 exists ( FunctionCall fc |
180- fc .getTarget ( )
181- .getName ( )
182- .toLowerCase ( )
183- .regexpMatch ( ".*(crypt|encode|decode|hash|securezero).*" ) and
192+ encryptionFunction ( fc .getTarget ( ) ) and
184193 (
185194 this = fc or
186195 this = fc .getAnArgument ( )
@@ -189,7 +198,7 @@ class Encrypted extends Expr {
189198 or
190199 exists ( Type t |
191200 this .getType ( ) .refersTo ( t ) and
192- t . getName ( ) . toLowerCase ( ) . regexpMatch ( ".*(crypt|encode|decode|hash|securezero).*" )
201+ encryptionType ( t )
193202 )
194203 }
195204}
You can’t perform that action at this time.
0 commit comments