File tree Expand file tree Collapse file tree
swift/ql/lib/codeql/swift/security Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,14 +155,21 @@ class SensitiveExpr extends Expr {
155155 predicate isProbablySafe ( ) { label .toLowerCase ( ) .regexpMatch ( regexpProbablySafe ( ) ) }
156156}
157157
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+
158165/**
159166 * An expression that may be protected with encryption, for example an
160167 * argument to a function called "encrypt".
161168 */
162169class EncryptedExpr extends Expr {
163170 EncryptedExpr ( ) {
164171 exists ( CallExpr call |
165- call .getStaticTarget ( ) . getName ( ) . regexpMatch ( ".*(crypt|hash|encode|protect).*" ) and
172+ call .getStaticTarget ( ) instanceof EncryptionFunction and
166173 call .getAnArgument ( ) .getExpr ( ) = this
167174 )
168175 }
You can’t perform that action at this time.
0 commit comments