Skip to content

Commit d4cc86c

Browse files
committed
Swift: Make the RNCryptor sources wider (actual usage seems to vary).
1 parent 81b0dbf commit d4cc86c

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ private class DefaultConstantPasswordSink extends ConstantPasswordSink {
5050
private class RnCryptorPasswordSink extends ConstantPasswordSink {
5151
RnCryptorPasswordSink() {
5252
// RNCryptor (labelled arguments)
53-
exists(ClassOrStructDecl c, MethodDecl f, CallExpr call |
54-
c.getName() = ["RNCryptor", "RNEncryptor", "RNDecryptor"] and
53+
exists(NominalTypeDecl c, MethodDecl f, CallExpr call |
54+
c.getName() =
55+
[
56+
"RNCryptor", "RNEncryptor", "RNDecryptor", "RNCryptor.EncryptorV3",
57+
"RNCryptor.DecryptorV3"
58+
] and
5559
c.getAMember() = f and
5660
call.getStaticTarget() = f and
5761
call.getArgumentWithLabel(["password", "withPassword", "forPassword"]).getExpr() =

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ private class CryptoSwiftSaltSink extends ConstantSaltSink {
4949
*/
5050
private class RnCryptorSaltSink extends ConstantSaltSink {
5151
RnCryptorSaltSink() {
52-
exists(ClassOrStructDecl c, MethodDecl f, CallExpr call |
53-
c.getName() = ["RNCryptor", "RNEncryptor", "RNDecryptor"] and
52+
exists(NominalTypeDecl c, MethodDecl f, CallExpr call |
53+
c.getName() =
54+
[
55+
"RNCryptor", "RNEncryptor", "RNDecryptor", "RNCryptor.EncryptorV3",
56+
"RNCryptor.DecryptorV3"
57+
] and
5458
c.getAMember() = f and
5559
call.getStaticTarget() = f and
5660
call.getArgumentWithLabel(["salt", "encryptionSalt", "hmacSalt", "HMACSalt"]).getExpr() =

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ private class CryptoSwiftEncryptionKeySink extends HardcodedEncryptionKeySink {
5252
*/
5353
private class RnCryptorEncryptionKeySink extends HardcodedEncryptionKeySink {
5454
RnCryptorEncryptionKeySink() {
55-
exists(ClassOrStructDecl c, MethodDecl f, CallExpr call |
56-
c.getFullName() = ["RNCryptor", "RNEncryptor", "RNDecryptor"] and
55+
exists(NominalTypeDecl c, MethodDecl f, CallExpr call |
56+
c.getFullName() =
57+
[
58+
"RNCryptor", "RNEncryptor", "RNDecryptor", "RNCryptor.EncryptorV3",
59+
"RNCryptor.DecryptorV3"
60+
] and
5761
c.getAMember() = f and
5862
call.getStaticTarget() = f and
5963
call.getArgumentWithLabel(["encryptionKey", "withEncryptionKey"]).getExpr() = this.asExpr()

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ private class CryptoSwiftInitializationVectorSink extends StaticInitializationVe
5151
*/
5252
private class RnCryptorInitializationVectorSink extends StaticInitializationVectorSink {
5353
RnCryptorInitializationVectorSink() {
54-
exists(ClassOrStructDecl c, MethodDecl f, CallExpr call |
55-
c.getFullName() = ["RNCryptor", "RNEncryptor", "RNDecryptor"] and
54+
exists(NominalTypeDecl c, MethodDecl f, CallExpr call |
55+
c.getFullName() =
56+
[
57+
"RNCryptor", "RNEncryptor", "RNDecryptor", "RNCryptor.EncryptorV3",
58+
"RNCryptor.DecryptorV3"
59+
] and
5660
c.getAMember() = f and
5761
call.getStaticTarget() = f and
5862
call.getArgumentWithLabel(["iv", "IV"]).getExpr() = this.asExpr()

0 commit comments

Comments
 (0)