Skip to content

Commit e17c059

Browse files
committed
Swift: More reliable sink recognition.
This is needed for the real world results, but I could not reproduce the issue in tests. I think it may have something to do with classes defined across different files / modules???
1 parent ffa279e commit e17c059

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ private class CoreDataStore extends CleartextStorageDatabaseSink {
4848
// example in `coreDataObj.data = sensitive` the post-update node corresponding
4949
// with `coreDataObj.data` is a sink.
5050
// (ideally this would be only members with the `@NSManaged` attribute)
51-
exists(ClassOrStructDecl cd, Expr e |
52-
cd.getABaseTypeDecl*().getName() = "NSManagedObject" and
51+
exists(NominalType t, Expr e |
52+
t.getABaseType*().getName() = "NSManagedObject" and
5353
this.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr() = e and
54-
e.getFullyConverted().getType() = cd.getType() and
54+
e.getFullyConverted().getType() = t and
5555
not e.(DeclRefExpr).getDecl() instanceof SelfParamDecl
5656
)
5757
}
@@ -66,10 +66,10 @@ private class RealmStore extends CleartextStorageDatabaseSink instanceof DataFlo
6666
// any write into a class derived from `RealmSwiftObject` is a sink. For
6767
// example in `realmObj.data = sensitive` the post-update node corresponding
6868
// with `realmObj.data` is a sink.
69-
exists(ClassOrStructDecl cd, Expr e |
70-
cd.getABaseTypeDecl*().getName() = "RealmSwiftObject" and
69+
exists(NominalType t, Expr e |
70+
t.getABaseType*().getName() = "RealmSwiftObject" and
7171
this.getPreUpdateNode().asExpr() = e and
72-
e.getFullyConverted().getType() = cd.getType() and
72+
e.getFullyConverted().getType() = t and
7373
not e.(DeclRefExpr).getDecl() instanceof SelfParamDecl
7474
)
7575
}

0 commit comments

Comments
 (0)