Skip to content

Commit 7b96cb0

Browse files
committed
Swift: Remove the original sink cases as they are no longer required.
1 parent e0100d7 commit 7b96cb0

File tree

3 files changed

+4
-32
lines changed

3 files changed

+4
-32
lines changed

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,6 @@ class CoreDataStore extends Stored {
4343
*/
4444
class RealmStore extends Stored {
4545
RealmStore() {
46-
// `object` arg to `Realm.add` is a sink
47-
exists(ClassDecl c, AbstractFunctionDecl f, CallExpr call |
48-
c.getName() = "Realm" and
49-
c.getAMember() = f and
50-
f.getName() = "add(_:update:)" and
51-
call.getStaticTarget() = f and
52-
call.getArgument(0).getExpr() = this
53-
)
54-
or
55-
// `value` arg to `Realm.create` is a sink
56-
exists(ClassDecl c, AbstractFunctionDecl f, CallExpr call |
57-
c.getName() = "Realm" and
58-
c.getAMember() = f and
59-
f.getName() = "create(_:value:update:)" and
60-
call.getStaticTarget() = f and
61-
call.getArgument(1).getExpr() = this
62-
)
63-
or
6446
// any access into a class derived from `RealmSwiftObject` is a sink
6547
exists(ClassDecl cd |
6648
cd.getABaseTypeDecl*().getName() = "RealmSwiftObject" and

swift/ql/test/query-tests/Security/CWE-311/CleartextStorageDatabase.expected

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,17 @@ edges
1616
| testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | value : |
1717
| testRealm.swift:34:2:34:2 | [post] a : | testRealm.swift:34:2:34:2 | a |
1818
| testRealm.swift:34:2:34:2 | [post] a : | testRealm.swift:34:2:34:2 | a : |
19-
| testRealm.swift:34:2:34:2 | [post] a : | testRealm.swift:35:12:35:12 | a |
2019
| testRealm.swift:34:2:34:2 | [post] a [data] : | testRealm.swift:34:2:34:2 | a |
2120
| testRealm.swift:34:2:34:2 | [post] a [data] : | testRealm.swift:34:2:34:2 | a : |
22-
| testRealm.swift:34:2:34:2 | [post] a [data] : | testRealm.swift:35:12:35:12 | a |
2321
| testRealm.swift:34:2:34:2 | a : | testRealm.swift:16:6:16:6 | self : |
24-
| testRealm.swift:34:2:34:2 | a : | testRealm.swift:35:12:35:12 | a |
2522
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:16:6:16:6 | value : |
2623
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:34:2:34:2 | [post] a : |
2724
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:34:2:34:2 | [post] a [data] : |
2825
| testRealm.swift:42:2:42:2 | [post] c : | testRealm.swift:42:2:42:2 | c |
2926
| testRealm.swift:42:2:42:2 | [post] c : | testRealm.swift:42:2:42:2 | c : |
30-
| testRealm.swift:42:2:42:2 | [post] c : | testRealm.swift:43:47:43:47 | c |
3127
| testRealm.swift:42:2:42:2 | [post] c [data] : | testRealm.swift:42:2:42:2 | c |
3228
| testRealm.swift:42:2:42:2 | [post] c [data] : | testRealm.swift:42:2:42:2 | c : |
33-
| testRealm.swift:42:2:42:2 | [post] c [data] : | testRealm.swift:43:47:43:47 | c |
3429
| testRealm.swift:42:2:42:2 | c : | testRealm.swift:16:6:16:6 | self : |
35-
| testRealm.swift:42:2:42:2 | c : | testRealm.swift:43:47:43:47 | c |
3630
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:16:6:16:6 | value : |
3731
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:42:2:42:2 | [post] c : |
3832
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:42:2:42:2 | [post] c [data] : |
@@ -91,13 +85,11 @@ nodes
9185
| testRealm.swift:34:2:34:2 | a | semmle.label | a |
9286
| testRealm.swift:34:2:34:2 | a : | semmle.label | a : |
9387
| testRealm.swift:34:11:34:11 | myPassword : | semmle.label | myPassword : |
94-
| testRealm.swift:35:12:35:12 | a | semmle.label | a |
9588
| testRealm.swift:42:2:42:2 | [post] c : | semmle.label | [post] c : |
9689
| testRealm.swift:42:2:42:2 | [post] c [data] : | semmle.label | [post] c [data] : |
9790
| testRealm.swift:42:2:42:2 | c | semmle.label | c |
9891
| testRealm.swift:42:2:42:2 | c : | semmle.label | c : |
9992
| testRealm.swift:42:11:42:11 | myPassword : | semmle.label | myPassword : |
100-
| testRealm.swift:43:47:43:47 | c | semmle.label | c |
10193
| testRealm.swift:52:2:52:3 | ...! | semmle.label | ...! |
10294
| testRealm.swift:52:2:52:3 | ...! : | semmle.label | ...! : |
10395
| testRealm.swift:52:2:52:3 | [post] ...! : | semmle.label | [post] ...! : |
@@ -136,9 +128,7 @@ subpaths
136128
| testCoreData.swift:96:15:96:15 | y | testCoreData.swift:92:10:92:10 | passwd : | testCoreData.swift:96:15:96:15 | y | This operation stores 'y' in a database. It may contain unencrypted sensitive data from $@ | testCoreData.swift:92:10:92:10 | passwd : | passwd |
137129
| testCoreData.swift:97:15:97:15 | z | testCoreData.swift:93:10:93:10 | passwd : | testCoreData.swift:97:15:97:15 | z | This operation stores 'z' in a database. It may contain unencrypted sensitive data from $@ | testCoreData.swift:93:10:93:10 | passwd : | passwd |
138130
| testRealm.swift:34:2:34:2 | a | testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:34:2:34:2 | a | This operation stores 'a' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:34:11:34:11 | myPassword : | myPassword |
139-
| testRealm.swift:35:12:35:12 | a | testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:35:12:35:12 | a | This operation stores 'a' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:34:11:34:11 | myPassword : | myPassword |
140131
| testRealm.swift:42:2:42:2 | c | testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:42:2:42:2 | c | This operation stores 'c' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:42:11:42:11 | myPassword : | myPassword |
141-
| testRealm.swift:43:47:43:47 | c | testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:43:47:43:47 | c | This operation stores 'c' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:42:11:42:11 | myPassword : | myPassword |
142132
| testRealm.swift:52:2:52:3 | ...! | testRealm.swift:52:12:52:12 | myPassword : | testRealm.swift:52:2:52:3 | ...! | This operation stores '...!' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:52:12:52:12 | myPassword : | myPassword |
143133
| testRealm.swift:59:2:59:2 | g | testRealm.swift:59:11:59:11 | myPassword : | testRealm.swift:59:2:59:2 | g | This operation stores 'g' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:59:11:59:11 | myPassword : | myPassword |
144134
| testRealm.swift:60:2:60:2 | g | testRealm.swift:59:11:59:11 | myPassword : | testRealm.swift:60:2:60:2 | g | This operation stores 'g' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:59:11:59:11 | myPassword : | myPassword |

swift/ql/test/query-tests/Security/CWE-311/testRealm.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ func test1(realm : Realm, myPassword : String, myHashedPassword : String) {
3131
// add objects (within a transaction) ...
3232

3333
let a = MyRealmSwiftObject()
34-
a.data = myPassword // BAD [DUPLICATE]
35-
realm.add(a) // BAD
34+
a.data = myPassword // BAD
35+
realm.add(a)
3636

3737
let b = MyRealmSwiftObject()
3838
b.data = myHashedPassword
3939
realm.add(b) // GOOD (not sensitive)
4040

4141
let c = MyRealmSwiftObject()
42-
c.data = myPassword // BAD [DUPLICATE]
43-
realm.create(MyRealmSwiftObject.self, value: c) // BAD
42+
c.data = myPassword // BAD
43+
realm.create(MyRealmSwiftObject.self, value: c)
4444

4545
let d = MyRealmSwiftObject()
4646
d.data = myHashedPassword

0 commit comments

Comments
 (0)