Skip to content

Commit 2b99344

Browse files
committed
Swift: Add some cached annotations for sensitive exprs.
1 parent bc16fb5 commit 2b99344

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

swift/ql/lib/codeql/swift/security/SensitiveExprs.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private string regexpProbablySafe() {
9191
private class SensitiveVarDecl extends VarDecl {
9292
SensitiveDataType sensitiveType;
9393

94+
cached
9495
SensitiveVarDecl() { this.getName().regexpMatch(sensitiveType.getRegexp()) }
9596

9697
predicate hasInfo(string label, SensitiveDataType type) {
@@ -106,6 +107,7 @@ private class SensitiveFunction extends Function {
106107
SensitiveDataType sensitiveType;
107108
string name; // name of the function, not including the argument list.
108109

110+
cached
109111
SensitiveFunction() {
110112
name = this.getShortName() and
111113
name.regexpMatch(sensitiveType.getRegexp())
@@ -123,6 +125,7 @@ private class SensitiveFunction extends Function {
123125
private class SensitiveArgument extends Argument {
124126
SensitiveDataType sensitiveType;
125127

128+
cached
126129
SensitiveArgument() { this.getLabel().regexpMatch(sensitiveType.getRegexp()) }
127130

128131
predicate hasInfo(string label, SensitiveDataType type) {
@@ -174,6 +177,7 @@ class SensitiveExpr extends Expr {
174177
* A function that is likely used to encrypt or hash data.
175178
*/
176179
private class EncryptionFunction extends Function {
180+
cached
177181
EncryptionFunction() { this.getName().regexpMatch("(?is).*(crypt|hash|encode|protect).*") }
178182
}
179183

0 commit comments

Comments
 (0)