Merge pull request #11459 from geoffw0/constructor

Swift: Constructor and destructor related cleanup
This commit is contained in:
Geoffrey White
2022-11-29 11:00:22 +00:00
committed by GitHub
7 changed files with 14 additions and 14 deletions

View File

@@ -17,10 +17,8 @@ ql/lib/codeql/swift/elements/decl/ConcreteFuncDecl.qll 7dd23b6145977ec6ca60dd39c
ql/lib/codeql/swift/elements/decl/ConcreteFuncDeclConstructor.qll 4eb2e9dc8b4c93e457bb594085d8f50862dc07a712ce7a0f2dee7f108467ce3e 1f994d6ae1ca2e4fd5da075b70ea22322181bdaf43034face1e82ef353fe34bf
ql/lib/codeql/swift/elements/decl/ConcreteVarDecl.qll be33f40e8870a10aec413f35d8f62a502d7d5dd8a52665730740e880566206d7 d821efa43c6d83aedfb959500de42c5ecabbf856f8556f739bc6cec30a88dfab
ql/lib/codeql/swift/elements/decl/ConcreteVarDeclConstructor.qll 4b6a9f458db5437f9351b14464b3809a78194029554ea818b3e18272c17afba3 a60d695b0d0ffa917ad01908bec2beaa663e644eddb00fb370fbc906623775d4
ql/lib/codeql/swift/elements/decl/ConstructorDecl.qll df6725dfa6670b1ff9a5135126b38cb93d813f852ffd1290bb60b541e28b92d9 fb3ed454cdc97bedc5577c9823f6385eb9616d156085fc8796cc09732ae48121
ql/lib/codeql/swift/elements/decl/ConstructorDeclConstructor.qll ba5cc6f440cba3d47b364a37febd64f85941cdc0237db52a2b8844d1dc75d483 9fc039ca7a0f33f03b3f573186f02efecbac0c2e0dc5abba5d47876ca26390fe
ql/lib/codeql/swift/elements/decl/Decl.qll 7a7ea5727a238684e783adf04ce8f721bf4451e1324ffc966ad671d60a43d64b 662e53ffc8226ae351032d0389784e6b70d517794e83a4c698ac84996361608f
ql/lib/codeql/swift/elements/decl/DestructorDecl.qll a2ba5e8861661ebc4cf875d540bf1edf0970920304aeeaef34592ea2739afc21 10001d21ec5aecc398e4c0e9bf05ee905c3edc4f89dd0afc7b2e5aca6b767dec
ql/lib/codeql/swift/elements/decl/DestructorDeclConstructor.qll c33b113a3ccb0b1bfd9aad8b909940776da5fdb8a24e1b998c5ebde3903be981 155ad928fbebf9688eec30a2cf61d9a2d4cd15d1161dc3f6202e6331bdb3a56a
ql/lib/codeql/swift/elements/decl/EnumCaseDeclConstructor.qll 8c907544170671f713a8665d294eeefdbe78a607c2f16e2c630ea9c33f484baf eec83efc930683628185dbdad8f73311aad510074d168a53d85ea09d13f1f7e1
ql/lib/codeql/swift/elements/decl/EnumDecl.qll 04271e164379af3a33eb060d230b768878e06acc37c3d132cad089a2c663c6c4 779940ebdbd510eb651972c57eb84b04af39c44ef59a8c307a44549ab730febb

View File

@@ -1,4 +1,7 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.decl.ConstructorDecl
private import codeql.swift.elements.decl.MethodDecl
class ConstructorDecl extends Generated::ConstructorDecl { }
/**
* An initializer of a class, struct, enum or protocol.
*/
class ConstructorDecl extends Generated::ConstructorDecl, MethodDecl { }

View File

@@ -1,4 +1,7 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
private import codeql.swift.generated.decl.DestructorDecl
private import codeql.swift.elements.decl.MethodDecl
class DestructorDecl extends Generated::DestructorDecl { }
/**
* A deinitializer of a class.
*/
class DestructorDecl extends Generated::DestructorDecl, MethodDecl { }

View File

@@ -34,12 +34,11 @@ class EncryptionInitializationSink extends Expr {
// `iv` arg in `init` is a sink
exists(CallExpr call, string fName |
call.getStaticTarget()
.(MethodDecl)
.(ConstructorDecl)
.hasQualifiedName([
"AES", "ChaCha20", "Blowfish", "Rabbit", "CBC", "CFB", "GCM", "OCB", "OFB", "PCBC",
"CCM", "CTR"
], fName) and
fName.matches("%init(%") and
call.getArgumentWithLabel("iv").getExpr() = this
)
}

View File

@@ -32,10 +32,9 @@ class ConstantPasswordSource extends Expr {
class ConstantPasswordSink extends Expr {
ConstantPasswordSink() {
// `password` arg in `init` is a sink
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
c.getFullName() = ["HKDF", "PBKDF1", "PBKDF2", "Scrypt"] and
c.getAMember() = f and
f.getName().matches("%init(%") and
call.getStaticTarget() = f and
call.getArgumentWithLabel("password").getExpr() = this
)

View File

@@ -32,10 +32,9 @@ class ConstantSaltSource extends Expr {
class ConstantSaltSink extends Expr {
ConstantSaltSink() {
// `salt` arg in `init` is a sink
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
c.getFullName() = ["HKDF", "PBKDF1", "PBKDF2", "Scrypt"] and
c.getAMember() = f and
f.getName().matches("%init(%") and
call.getStaticTarget() = f and
call.getArgumentWithLabel("salt").getExpr() = this
)

View File

@@ -33,10 +33,9 @@ class IntLiteralSource extends IterationsSource instanceof IntegerLiteralExpr {
class InsufficientHashIterationsSink extends Expr {
InsufficientHashIterationsSink() {
// `iterations` arg in `init` is a sink
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
exists(ClassOrStructDecl c, ConstructorDecl f, CallExpr call |
c.getFullName() = ["PBKDF1", "PBKDF2"] and
c.getAMember() = f and
f.getName().matches("init(%") and
call.getStaticTarget() = f and
call.getArgumentWithLabel("iterations").getExpr() = this
)