Skip to content

Commit 3304e9f

Browse files
authored
Merge pull request github#11459 from geoffw0/constructor
Swift: Constructor and destructor related cleanup
2 parents 0f87eb4 + 63c139f commit 3304e9f

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

swift/ql/.generated.list

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ ql/lib/codeql/swift/elements/decl/ConcreteFuncDecl.qll 7dd23b6145977ec6ca60dd39c
1717
ql/lib/codeql/swift/elements/decl/ConcreteFuncDeclConstructor.qll 4eb2e9dc8b4c93e457bb594085d8f50862dc07a712ce7a0f2dee7f108467ce3e 1f994d6ae1ca2e4fd5da075b70ea22322181bdaf43034face1e82ef353fe34bf
1818
ql/lib/codeql/swift/elements/decl/ConcreteVarDecl.qll be33f40e8870a10aec413f35d8f62a502d7d5dd8a52665730740e880566206d7 d821efa43c6d83aedfb959500de42c5ecabbf856f8556f739bc6cec30a88dfab
1919
ql/lib/codeql/swift/elements/decl/ConcreteVarDeclConstructor.qll 4b6a9f458db5437f9351b14464b3809a78194029554ea818b3e18272c17afba3 a60d695b0d0ffa917ad01908bec2beaa663e644eddb00fb370fbc906623775d4
20-
ql/lib/codeql/swift/elements/decl/ConstructorDecl.qll df6725dfa6670b1ff9a5135126b38cb93d813f852ffd1290bb60b541e28b92d9 fb3ed454cdc97bedc5577c9823f6385eb9616d156085fc8796cc09732ae48121
2120
ql/lib/codeql/swift/elements/decl/ConstructorDeclConstructor.qll ba5cc6f440cba3d47b364a37febd64f85941cdc0237db52a2b8844d1dc75d483 9fc039ca7a0f33f03b3f573186f02efecbac0c2e0dc5abba5d47876ca26390fe
2221
ql/lib/codeql/swift/elements/decl/Decl.qll 7a7ea5727a238684e783adf04ce8f721bf4451e1324ffc966ad671d60a43d64b 662e53ffc8226ae351032d0389784e6b70d517794e83a4c698ac84996361608f
23-
ql/lib/codeql/swift/elements/decl/DestructorDecl.qll a2ba5e8861661ebc4cf875d540bf1edf0970920304aeeaef34592ea2739afc21 10001d21ec5aecc398e4c0e9bf05ee905c3edc4f89dd0afc7b2e5aca6b767dec
2422
ql/lib/codeql/swift/elements/decl/DestructorDeclConstructor.qll c33b113a3ccb0b1bfd9aad8b909940776da5fdb8a24e1b998c5ebde3903be981 155ad928fbebf9688eec30a2cf61d9a2d4cd15d1161dc3f6202e6331bdb3a56a
2523
ql/lib/codeql/swift/elements/decl/EnumCaseDeclConstructor.qll 8c907544170671f713a8665d294eeefdbe78a607c2f16e2c630ea9c33f484baf eec83efc930683628185dbdad8f73311aad510074d168a53d85ea09d13f1f7e1
2624
ql/lib/codeql/swift/elements/decl/EnumDecl.qll 04271e164379af3a33eb060d230b768878e06acc37c3d132cad089a2c663c6c4 779940ebdbd510eb651972c57eb84b04af39c44ef59a8c307a44549ab730febb
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
21
private import codeql.swift.generated.decl.ConstructorDecl
2+
private import codeql.swift.elements.decl.MethodDecl
33

4-
class ConstructorDecl extends Generated::ConstructorDecl { }
4+
/**
5+
* An initializer of a class, struct, enum or protocol.
6+
*/
7+
class ConstructorDecl extends Generated::ConstructorDecl, MethodDecl { }
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
21
private import codeql.swift.generated.decl.DestructorDecl
2+
private import codeql.swift.elements.decl.MethodDecl
33

4-
class DestructorDecl extends Generated::DestructorDecl { }
4+
/**
5+
* A deinitializer of a class.
6+
*/
7+
class DestructorDecl extends Generated::DestructorDecl, MethodDecl { }

swift/ql/src/queries/Security/CWE-1204/StaticInitializationVector.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ class EncryptionInitializationSink extends Expr {
3434
// `iv` arg in `init` is a sink
3535
exists(CallExpr call, string fName |
3636
call.getStaticTarget()
37-
.(MethodDecl)
37+
.(ConstructorDecl)
3838
.hasQualifiedName([
3939
"AES", "ChaCha20", "Blowfish", "Rabbit", "CBC", "CFB", "GCM", "OCB", "OFB", "PCBC",
4040
"CCM", "CTR"
4141
], fName) and
42-
fName.matches("%init(%") and
4342
call.getArgumentWithLabel("iv").getExpr() = this
4443
)
4544
}

swift/ql/src/queries/Security/CWE-259/ConstantPassword.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ class ConstantPasswordSource extends Expr {
3232
class ConstantPasswordSink extends Expr {
3333
ConstantPasswordSink() {
3434
// `password` arg in `init` is a sink
35-
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
35+
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
3636
c.getFullName() = ["HKDF", "PBKDF1", "PBKDF2", "Scrypt"] and
3737
c.getAMember() = f and
38-
f.getName().matches("%init(%") and
3938
call.getStaticTarget() = f and
4039
call.getArgumentWithLabel("password").getExpr() = this
4140
)

swift/ql/src/queries/Security/CWE-760/ConstantSalt.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ class ConstantSaltSource extends Expr {
3232
class ConstantSaltSink extends Expr {
3333
ConstantSaltSink() {
3434
// `salt` arg in `init` is a sink
35-
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
35+
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
3636
c.getFullName() = ["HKDF", "PBKDF1", "PBKDF2", "Scrypt"] and
3737
c.getAMember() = f and
38-
f.getName().matches("%init(%") and
3938
call.getStaticTarget() = f and
4039
call.getArgumentWithLabel("salt").getExpr() = this
4140
)

swift/ql/src/queries/Security/CWE-916/InsufficientHashIterations.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ class IntLiteralSource extends IterationsSource instanceof IntegerLiteralExpr {
3333
class InsufficientHashIterationsSink extends Expr {
3434
InsufficientHashIterationsSink() {
3535
// `iterations` arg in `init` is a sink
36-
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
36+
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
3737
c.getFullName() = ["PBKDF1", "PBKDF2"] and
3838
c.getAMember() = f and
39-
f.getName().matches("init(%") and
4039
call.getStaticTarget() = f and
4140
call.getArgumentWithLabel("iterations").getExpr() = this
4241
)

0 commit comments

Comments
 (0)