Skip to content

Commit 0ed89fb

Browse files
committed
Swift: Use ClassOrStructDecl.
1 parent d4742d2 commit 0ed89fb

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

swift/ql/src/queries/Security/CWE-079/UnsafeWebViewFetch.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Sink extends DataFlow::Node {
3131
int baseUrlArg
3232
|
3333
// arguments to method calls...
34-
exists(string className, ClassDecl c |
34+
exists(string className, ClassOrStructDecl c |
3535
(
3636
// `loadHTMLString`
3737
className = ["UIWebView", "WKWebView"] and

swift/ql/src/queries/Security/CWE-135/StringLengthConflation.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class StringLengthConflationConfiguration extends DataFlow::Configuration {
9999
|
100100
(
101101
// arguments to method calls...
102-
exists(string className, ClassDecl c |
102+
exists(string className, ClassOrStructDecl c |
103103
(
104104
// `NSRange.init`
105105
className = "NSRange" and
@@ -127,7 +127,7 @@ class StringLengthConflationConfiguration extends DataFlow::Configuration {
127127
paramName = "at"
128128
) and
129129
c.getName() = className and
130-
c.getABaseTypeDecl*().(ClassDecl).getAMember() = funcDecl and
130+
c.getABaseTypeDecl*().(ClassOrStructDecl).getAMember() = funcDecl and
131131
call.getStaticTarget() = funcDecl and
132132
flowstate = "NSString"
133133
)

swift/ql/src/queries/Security/CWE-311/CleartextStorageDatabase.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class Stored extends DataFlow::Node { }
2828
class CoreDataStore extends Stored {
2929
CoreDataStore() {
3030
// `content` arg to `NWConnection.send` is a sink
31-
exists(ClassDecl c, AbstractFunctionDecl f, CallExpr call |
31+
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
3232
c.getName() = "NSManagedObject" and
3333
c.getAMember() = f and
3434
f.getName() = ["setValue(_:forKey:)", "setPrimitiveValue(_:forKey:)"] and
@@ -47,7 +47,7 @@ class RealmStore extends Stored instanceof DataFlow::PostUpdateNode {
4747
// any write into a class derived from `RealmSwiftObject` is a sink. For
4848
// example in `realmObj.data = sensitive` the post-update node corresponding
4949
// with `realmObj.data` is a sink.
50-
exists(ClassDecl cd, Expr e |
50+
exists(ClassOrStructDecl cd, Expr e |
5151
cd.getABaseTypeDecl*().getName() = "RealmSwiftObject" and
5252
this.getPreUpdateNode().asExpr() = e and
5353
e.getFullyConverted().getType() = cd.getType() and
@@ -81,7 +81,7 @@ class CleartextStorageConfig extends TaintTracking::Configuration {
8181
// flow out from fields of a `RealmSwiftObject` at the sink, for example in
8282
// `realmObj.data = sensitive`.
8383
isSink(node) and
84-
exists(ClassDecl cd |
84+
exists(ClassOrStructDecl cd |
8585
c.getAReadContent().(DataFlow::Content::FieldContent).getField() = cd.getAMember() and
8686
cd.getABaseTypeDecl*().getName() = "RealmSwiftObject"
8787
)

swift/ql/src/queries/Security/CWE-311/CleartextTransmission.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class Transmitted extends Expr { }
2828
class NWConnectionSend extends Transmitted {
2929
NWConnectionSend() {
3030
// `content` arg to `NWConnection.send` is a sink
31-
exists(ClassDecl c, AbstractFunctionDecl f, CallExpr call |
31+
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
3232
c.getName() = "NWConnection" and
3333
c.getAMember() = f and
3434
f.getName() = "send(content:contentContext:isComplete:completion:)" and
@@ -46,7 +46,7 @@ class Url extends Transmitted {
4646
Url() {
4747
// `string` arg in `URL.init` is a sink
4848
// (we assume here that the URL goes on to be used in a network operation)
49-
exists(StructDecl c, AbstractFunctionDecl f, CallExpr call |
49+
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
5050
c.getName() = "URL" and
5151
c.getAMember() = f and
5252
f.getName() = ["init(string:)", "init(string:relativeTo:)"] and

swift/ql/src/queries/Security/CWE-328/WeakSensitiveDataHashing.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module WeakHashingConfig {
4242
call.getAnArgument().getExpr() = this.asExpr() and
4343
call.getStaticTarget() = func and
4444
func.getName().matches(["hash(%", "update(%"]) and
45-
algorithm = func.getEnclosingDecl().(StructDecl).getName() and
45+
algorithm = func.getEnclosingDecl().(ClassOrStructDecl).getName() and
4646
algorithm = ["MD5", "SHA1"]
4747
)
4848
}

swift/ql/src/queries/Security/ECB-Encryption/ECBEncryption.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ abstract class BlockMode extends Expr { }
2626
class AES extends BlockMode {
2727
AES() {
2828
// `blockMode` arg in `AES.init` is a sink
29-
exists(ClassDecl c, AbstractFunctionDecl f, CallExpr call |
29+
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
3030
c.getName() = "AES" and
3131
c.getAMember() = f and
3232
f.getName() = ["init(key:blockMode:)", "init(key:blockMode:padding:)"] and
@@ -42,7 +42,7 @@ class AES extends BlockMode {
4242
class Blowfish extends BlockMode {
4343
Blowfish() {
4444
// `blockMode` arg in `Blowfish.init` is a sink
45-
exists(ClassDecl c, AbstractFunctionDecl f, CallExpr call |
45+
exists(ClassOrStructDecl c, AbstractFunctionDecl f, CallExpr call |
4646
c.getName() = "Blowfish" and
4747
c.getAMember() = f and
4848
f.getName() = "init(key:blockMode:padding:)" and
@@ -60,7 +60,7 @@ class EcbEncryptionConfig extends DataFlow::Configuration {
6060
EcbEncryptionConfig() { this = "EcbEncryptionConfig" }
6161

6262
override predicate isSource(DataFlow::Node node) {
63-
exists(StructDecl s, AbstractFunctionDecl f, CallExpr call |
63+
exists(ClassOrStructDecl s, AbstractFunctionDecl f, CallExpr call |
6464
s.getName() = "ECB" and
6565
s.getAMember() = f and
6666
f.getName() = "init()" and

0 commit comments

Comments
 (0)