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