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 {
168
168
override Recv target ;
169
169
}
170
170
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
+
171
183
/**
172
184
* An expression that is an argument or return value from an encryption /
173
185
* decryption call. This is quite inclusive to minimize false positives, for
@@ -177,10 +189,7 @@ class NetworkRecv extends NetworkSendRecv {
177
189
class Encrypted extends Expr {
178
190
Encrypted ( ) {
179
191
exists ( FunctionCall fc |
180
- fc .getTarget ( )
181
- .getName ( )
182
- .toLowerCase ( )
183
- .regexpMatch ( ".*(crypt|encode|decode|hash|securezero).*" ) and
192
+ encryptionFunction ( fc .getTarget ( ) ) and
184
193
(
185
194
this = fc or
186
195
this = fc .getAnArgument ( )
@@ -189,7 +198,7 @@ class Encrypted extends Expr {
189
198
or
190
199
exists ( Type t |
191
200
this .getType ( ) .refersTo ( t ) and
192
- t . getName ( ) . toLowerCase ( ) . regexpMatch ( ".*(crypt|encode|decode|hash|securezero).*" )
201
+ encryptionType ( t )
193
202
)
194
203
}
195
204
}
You can’t perform that action at this time.
0 commit comments