File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
swift/ql/lib/codeql/swift/security Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -155,14 +155,21 @@ class SensitiveExpr extends Expr {
155
155
predicate isProbablySafe ( ) { label .toLowerCase ( ) .regexpMatch ( regexpProbablySafe ( ) ) }
156
156
}
157
157
158
+ /**
159
+ * A function that is likely used to encrypt or hash data.
160
+ */
161
+ private class EncryptionFunction extends AbstractFunctionDecl {
162
+ EncryptionFunction ( ) { this .getName ( ) .regexpMatch ( ".*(crypt|hash|encode|protect).*" ) }
163
+ }
164
+
158
165
/**
159
166
* An expression that may be protected with encryption, for example an
160
167
* argument to a function called "encrypt".
161
168
*/
162
169
class EncryptedExpr extends Expr {
163
170
EncryptedExpr ( ) {
164
171
exists ( CallExpr call |
165
- call .getStaticTarget ( ) . getName ( ) . regexpMatch ( ".*(crypt|hash|encode|protect).*" ) and
172
+ call .getStaticTarget ( ) instanceof EncryptionFunction and
166
173
call .getAnArgument ( ) .getExpr ( ) = this
167
174
)
168
175
}
You can’t perform that action at this time.
0 commit comments