Skip to content

Commit 256c3f6

Browse files
committed
Swift: Various minor fixes / consistency improvements to sinks.
1 parent 7ddfcb2 commit 256c3f6

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ConstantPasswordAdditionalTaintStep extends Unit {
3535
private class CryptoSwiftPasswordSink extends ConstantPasswordSink {
3636
CryptoSwiftPasswordSink() {
3737
// `password` arg in `init` is a sink
38-
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
38+
exists(NominalTypeDecl c, ConstructorDecl f, CallExpr call |
3939
c.getName() = ["HKDF", "PBKDF1", "PBKDF2", "Scrypt"] and
4040
c.getAMember() = f and
4141
call.getStaticTarget() = f and

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ConstantSaltAdditionalTaintStep extends Unit {
3535
private class CryptoSwiftSaltSink extends ConstantSaltSink {
3636
CryptoSwiftSaltSink() {
3737
// `salt` arg in `init` is a sink
38-
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
38+
exists(NominalTypeDecl c, ConstructorDecl f, CallExpr call |
3939
c.getName() = ["HKDF", "PBKDF1", "PBKDF2", "Scrypt"] and
4040
c.getAMember() = f and
4141
call.getStaticTarget() = f and

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ class HardcodedEncryptionKeyAdditionalTaintStep extends Unit {
3535
private class CryptoSwiftEncryptionKeySink extends HardcodedEncryptionKeySink {
3636
CryptoSwiftEncryptionKeySink() {
3737
// `key` arg in `init` is a sink
38-
exists(CallExpr call, string fName |
39-
call.getStaticTarget()
40-
.(MethodDecl)
41-
.hasQualifiedName([
42-
"AES", "HMAC", "ChaCha20", "CBCMAC", "CMAC", "Poly1305", "Blowfish", "Rabbit"
43-
], fName) and
44-
fName.matches("init(key:%") and
45-
call.getArgument(0).getExpr() = this.asExpr()
38+
exists(NominalTypeDecl c, ConstructorDecl f, CallExpr call |
39+
c.getName() = ["AES", "HMAC", "ChaCha20", "CBCMAC", "CMAC", "Poly1305", "Blowfish", "Rabbit"] and
40+
c.getAMember() = f and
41+
call.getStaticTarget() = f and
42+
call.getArgumentWithLabel("key").getExpr() = this.asExpr()
4643
)
4744
}
4845
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class InsufficientHashIterationsAdditionalTaintStep extends Unit {
3636
private class CryptoSwiftHashIterationsSink extends InsufficientHashIterationsSink {
3737
CryptoSwiftHashIterationsSink() {
3838
// `iterations` arg in `init` is a sink
39-
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
39+
exists(NominalTypeDecl c, ConstructorDecl f, CallExpr call |
4040
c.getName() = ["PBKDF1", "PBKDF2"] and
4141
c.getAMember() = f and
4242
call.getStaticTarget() = f and

0 commit comments

Comments
 (0)