Skip to content

Commit dc47771

Browse files
committed
Swift: Fix locationless results.
1 parent 2584099 commit dc47771

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ class RealmStore extends Stored {
4646
// any write into a class derived from `RealmSwiftObject` is a sink. For
4747
// example in `realmObj.data = sensitive` the post-update node corresponding
4848
// with `realmObj.data` is a sink.
49-
exists(ClassDecl cd |
49+
exists(ClassDecl cd, Expr e |
5050
cd.getABaseTypeDecl*().getName() = "RealmSwiftObject" and
51-
this.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr().getFullyConverted().getType() =
52-
cd.getType()
51+
this.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr() = e and
52+
e.getFullyConverted().getType() = cd.getType() and
53+
not e.(DeclRefExpr).getDecl() instanceof SelfParamDecl
5354
)
5455
}
5556
}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
edges
2-
| file://:0:0:0:0 | [post] self [data] : | file://:0:0:0:0 | [post] self |
3-
| file://:0:0:0:0 | [post] self [data] : | file://:0:0:0:0 | [post] self : |
42
| file://:0:0:0:0 | value : | file://:0:0:0:0 | [post] self [data] : |
53
| testCoreData.swift:18:19:18:26 | value : | testCoreData.swift:19:12:19:12 | value |
64
| testCoreData.swift:31:3:31:3 | newValue : | testCoreData.swift:32:13:32:13 | newValue |
@@ -14,23 +12,17 @@ edges
1412
| testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | value : |
1513
| testRealm.swift:34:2:34:2 | [post] a [data] : | testRealm.swift:34:2:34:2 | [post] a |
1614
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:16:6:16:6 | value : |
17-
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:34:2:34:2 | [post] a |
1815
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:34:2:34:2 | [post] a [data] : |
1916
| testRealm.swift:42:2:42:2 | [post] c [data] : | testRealm.swift:42:2:42:2 | [post] c |
2017
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:16:6:16:6 | value : |
21-
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:42:2:42:2 | [post] c |
2218
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:42:2:42:2 | [post] c [data] : |
2319
| testRealm.swift:52:2:52:3 | [post] ...! [data] : | testRealm.swift:52:2:52:3 | [post] ...! |
2420
| testRealm.swift:52:12:52:12 | myPassword : | testRealm.swift:16:6:16:6 | value : |
25-
| testRealm.swift:52:12:52:12 | myPassword : | testRealm.swift:52:2:52:3 | [post] ...! |
2621
| testRealm.swift:52:12:52:12 | myPassword : | testRealm.swift:52:2:52:3 | [post] ...! [data] : |
2722
| testRealm.swift:59:2:59:2 | [post] g [data] : | testRealm.swift:59:2:59:2 | [post] g |
2823
| testRealm.swift:59:11:59:11 | myPassword : | testRealm.swift:16:6:16:6 | value : |
29-
| testRealm.swift:59:11:59:11 | myPassword : | testRealm.swift:59:2:59:2 | [post] g |
3024
| testRealm.swift:59:11:59:11 | myPassword : | testRealm.swift:59:2:59:2 | [post] g [data] : |
3125
nodes
32-
| file://:0:0:0:0 | [post] self | semmle.label | [post] self |
33-
| file://:0:0:0:0 | [post] self : | semmle.label | [post] self : |
3426
| file://:0:0:0:0 | [post] self [data] : | semmle.label | [post] self [data] : |
3527
| file://:0:0:0:0 | value : | semmle.label | value : |
3628
| testCoreData.swift:18:19:18:26 | value : | semmle.label | value : |
@@ -67,19 +59,11 @@ nodes
6759
| testRealm.swift:59:2:59:2 | [post] g [data] : | semmle.label | [post] g [data] : |
6860
| testRealm.swift:59:11:59:11 | myPassword : | semmle.label | myPassword : |
6961
subpaths
70-
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | [post] self : | testRealm.swift:34:2:34:2 | [post] a |
7162
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | [post] self [data] : | testRealm.swift:34:2:34:2 | [post] a [data] : |
72-
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | [post] self : | testRealm.swift:42:2:42:2 | [post] c |
7363
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | [post] self [data] : | testRealm.swift:42:2:42:2 | [post] c [data] : |
74-
| testRealm.swift:52:12:52:12 | myPassword : | testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | [post] self : | testRealm.swift:52:2:52:3 | [post] ...! |
7564
| testRealm.swift:52:12:52:12 | myPassword : | testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | [post] self [data] : | testRealm.swift:52:2:52:3 | [post] ...! [data] : |
76-
| testRealm.swift:59:11:59:11 | myPassword : | testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | [post] self : | testRealm.swift:59:2:59:2 | [post] g |
7765
| testRealm.swift:59:11:59:11 | myPassword : | testRealm.swift:16:6:16:6 | value : | file://:0:0:0:0 | [post] self [data] : | testRealm.swift:59:2:59:2 | [post] g [data] : |
7866
#select
79-
| file://:0:0:0:0 | self | testRealm.swift:34:11:34:11 | myPassword : | file://:0:0:0:0 | [post] self | This operation stores '[post] self' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:34:11:34:11 | myPassword : | myPassword |
80-
| file://:0:0:0:0 | self | testRealm.swift:42:11:42:11 | myPassword : | file://:0:0:0:0 | [post] self | This operation stores '[post] self' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:42:11:42:11 | myPassword : | myPassword |
81-
| file://:0:0:0:0 | self | testRealm.swift:52:12:52:12 | myPassword : | file://:0:0:0:0 | [post] self | This operation stores '[post] self' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:52:12:52:12 | myPassword : | myPassword |
82-
| file://:0:0:0:0 | self | testRealm.swift:59:11:59:11 | myPassword : | file://:0:0:0:0 | [post] self | This operation stores '[post] self' in a database. It may contain unencrypted sensitive data from $@ | testRealm.swift:59:11:59:11 | myPassword : | myPassword |
8367
| testCoreData.swift:19:12:19:12 | value | testCoreData.swift:61:25:61:25 | password : | testCoreData.swift:19:12:19:12 | value | This operation stores 'value' in a database. It may contain unencrypted sensitive data from $@ | testCoreData.swift:61:25:61:25 | password : | password |
8468
| testCoreData.swift:32:13:32:13 | newValue | testCoreData.swift:64:16:64:16 | password : | testCoreData.swift:32:13:32:13 | newValue | This operation stores 'newValue' in a database. It may contain unencrypted sensitive data from $@ | testCoreData.swift:64:16:64:16 | password : | password |
8569
| testCoreData.swift:48:15:48:15 | password | testCoreData.swift:48:15:48:15 | password | testCoreData.swift:48:15:48:15 | password | This operation stores 'password' in a database. It may contain unencrypted sensitive data from $@ | testCoreData.swift:48:15:48:15 | password | password |

0 commit comments

Comments
 (0)