Skip to content

Commit 430a8e1

Browse files
committed
Swift: Fix issues.
1 parent 4984d8f commit 430a8e1

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CoreDataStore extends Stored {
3232
c.getName() = "NSManagedObject" and
3333
c.getAMember() = f and
3434
f.getName() = ["setValue(_:forKey:)", "setPrimitiveValue(_:forKey:)"] and
35-
call.getFunction().(ApplyExpr).getStaticTarget() = f and
35+
call.getStaticTarget() = f and
3636
call.getArgument(0).getExpr() = this
3737
)
3838
}
@@ -48,7 +48,7 @@ class RealmStore extends Stored {
4848
c.getName() = "Realm" and
4949
c.getAMember() = f and
5050
f.getName() = "add(_:update:)" and
51-
call.getFunction().(ApplyExpr).getStaticTarget() = f and
51+
call.getStaticTarget() = f and
5252
call.getArgument(0).getExpr() = this
5353
)
5454
or
@@ -57,7 +57,7 @@ class RealmStore extends Stored {
5757
c.getName() = "Realm" and
5858
c.getAMember() = f and
5959
f.getName() = "create(_:value:update:)" and
60-
call.getFunction().(ApplyExpr).getStaticTarget() = f and
60+
call.getStaticTarget() = f and
6161
call.getArgument(1).getExpr() = this
6262
)
6363
}
@@ -90,7 +90,7 @@ class CleartextStorageConfig extends TaintTracking::Configuration {
9090
// flow out from field accesses, i.e. `a.b` -> `a`
9191
exists(MemberRefExpr m |
9292
node1.asExpr() = m and // `a.b`
93-
node2.asExpr() = m.getBaseExpr() // `a`
93+
node2.asExpr() = m.getImmediateBase() // `a`
9494
)
9595
or
9696
// flow through assignment (!)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class NWConnectionSend extends Transmitted {
3232
c.getName() = "NWConnection" and
3333
c.getAMember() = f and
3434
f.getName() = "send(content:contentContext:isComplete:completion:)" and
35-
call.getFunction().(ApplyExpr).getStaticTarget() = f and
35+
call.getStaticTarget() = f and
3636
call.getArgument(0).getExpr() = this
3737
)
3838
}
@@ -50,7 +50,7 @@ class URL extends Transmitted {
5050
c.getName() = "URL" and
5151
c.getAMember() = f and
5252
f.getName() = ["init(string:)", "init(string:relativeTo:)"] and
53-
call.getFunction().(ApplyExpr).getStaticTarget() = f and
53+
call.getStaticTarget() = f and
5454
call.getArgument(0).getExpr() = this
5555
)
5656
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
edges
2-
| testCoreData.swift:37:14:37:22 | WriteDef : | testCoreData.swift:37:49:37:49 | data : |
2+
| testCoreData.swift:18:19:18:26 | value : | testCoreData.swift:19:12:19:12 | value |
3+
| testCoreData.swift:31:3:31:3 | newValue : | testCoreData.swift:32:13:32:13 | newValue |
34
| testCoreData.swift:37:14:37:22 | data : | testCoreData.swift:37:49:37:49 | data : |
4-
| testCoreData.swift:38:11:38:23 | WriteDef : | testCoreData.swift:38:1:38:33 | data[return] : |
55
| testCoreData.swift:38:11:38:23 | data : | testCoreData.swift:38:1:38:33 | data[return] : |
6+
| testCoreData.swift:61:25:61:25 | password : | testCoreData.swift:18:19:18:26 | value : |
7+
| testCoreData.swift:64:16:64:16 | password : | testCoreData.swift:31:3:31:3 | newValue : |
68
| testCoreData.swift:77:24:77:24 | x : | testCoreData.swift:78:15:78:15 | x |
79
| testCoreData.swift:80:10:80:22 | call to getPassword() : | testCoreData.swift:81:15:81:15 | y |
810
| testCoreData.swift:91:10:91:10 | passwd : | testCoreData.swift:95:15:95:15 | x |
@@ -11,29 +13,27 @@ edges
1113
| testCoreData.swift:92:10:92:10 | passwd : | testCoreData.swift:100:13:100:14 | &... : |
1214
| testCoreData.swift:93:10:93:10 | passwd : | testCoreData.swift:97:15:97:15 | z |
1315
| testCoreData.swift:99:6:99:15 | call to encrypt(_:) : | testCoreData.swift:103:15:103:15 | x |
14-
| testCoreData.swift:99:14:99:14 | x : | testCoreData.swift:37:14:37:22 | WriteDef : |
1516
| testCoreData.swift:99:14:99:14 | x : | testCoreData.swift:37:14:37:22 | data : |
1617
| testCoreData.swift:99:14:99:14 | x : | testCoreData.swift:99:6:99:15 | call to encrypt(_:) : |
1718
| testCoreData.swift:100:7:100:14 | data: &... : | testCoreData.swift:104:15:104:15 | y |
18-
| testCoreData.swift:100:13:100:14 | &... : | testCoreData.swift:38:11:38:23 | WriteDef : |
1919
| testCoreData.swift:100:13:100:14 | &... : | testCoreData.swift:38:11:38:23 | data : |
2020
| testCoreData.swift:100:13:100:14 | &... : | testCoreData.swift:100:7:100:14 | data: &... : |
2121
| testRealm.swift:34:11:34:11 | myPassword : | testRealm.swift:35:12:35:12 | a |
2222
| testRealm.swift:42:11:42:11 | myPassword : | testRealm.swift:43:47:43:47 | c |
2323
nodes
24-
| testCoreData.swift:37:14:37:22 | WriteDef : | semmle.label | WriteDef : |
25-
| testCoreData.swift:37:14:37:22 | WriteDef : | semmle.label | data : |
26-
| testCoreData.swift:37:14:37:22 | data : | semmle.label | WriteDef : |
24+
| testCoreData.swift:18:19:18:26 | value : | semmle.label | value : |
25+
| testCoreData.swift:19:12:19:12 | value | semmle.label | value |
26+
| testCoreData.swift:31:3:31:3 | newValue : | semmle.label | newValue : |
27+
| testCoreData.swift:32:13:32:13 | newValue | semmle.label | newValue |
2728
| testCoreData.swift:37:14:37:22 | data : | semmle.label | data : |
2829
| testCoreData.swift:37:49:37:49 | data : | semmle.label | data : |
2930
| testCoreData.swift:38:1:38:33 | data[return] : | semmle.label | data[return] : |
30-
| testCoreData.swift:38:11:38:23 | WriteDef : | semmle.label | WriteDef : |
31-
| testCoreData.swift:38:11:38:23 | WriteDef : | semmle.label | data : |
32-
| testCoreData.swift:38:11:38:23 | data : | semmle.label | WriteDef : |
3331
| testCoreData.swift:38:11:38:23 | data : | semmle.label | data : |
3432
| testCoreData.swift:48:15:48:15 | password | semmle.label | password |
3533
| testCoreData.swift:51:24:51:24 | password | semmle.label | password |
3634
| testCoreData.swift:58:15:58:15 | password | semmle.label | password |
35+
| testCoreData.swift:61:25:61:25 | password : | semmle.label | password : |
36+
| testCoreData.swift:64:16:64:16 | password : | semmle.label | password : |
3737
| testCoreData.swift:77:24:77:24 | x : | semmle.label | x : |
3838
| testCoreData.swift:78:15:78:15 | x | semmle.label | x |
3939
| testCoreData.swift:80:10:80:22 | call to getPassword() : | semmle.label | call to getPassword() : |
@@ -56,11 +56,11 @@ nodes
5656
| testRealm.swift:42:11:42:11 | myPassword : | semmle.label | myPassword : |
5757
| testRealm.swift:43:47:43:47 | c | semmle.label | c |
5858
subpaths
59-
| testCoreData.swift:99:14:99:14 | x : | testCoreData.swift:37:14:37:22 | WriteDef : | testCoreData.swift:37:49:37:49 | data : | testCoreData.swift:99:6:99:15 | call to encrypt(_:) : |
6059
| testCoreData.swift:99:14:99:14 | x : | testCoreData.swift:37:14:37:22 | data : | testCoreData.swift:37:49:37:49 | data : | testCoreData.swift:99:6:99:15 | call to encrypt(_:) : |
61-
| testCoreData.swift:100:13:100:14 | &... : | testCoreData.swift:38:11:38:23 | WriteDef : | testCoreData.swift:38:1:38:33 | data[return] : | testCoreData.swift:100:7:100:14 | data: &... : |
6260
| testCoreData.swift:100:13:100:14 | &... : | testCoreData.swift:38:11:38:23 | data : | testCoreData.swift:38:1:38:33 | data[return] : | testCoreData.swift:100:7:100:14 | data: &... : |
6361
#select
62+
| 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 |
63+
| 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 |
6464
| 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 |
6565
| testCoreData.swift:51:24:51:24 | password | testCoreData.swift:51:24:51:24 | password | testCoreData.swift:51:24:51:24 | password | This operation stores 'password' in a database. It may contain unencrypted sensitive data from $@ | testCoreData.swift:51:24:51:24 | password | password |
6666
| testCoreData.swift:58:15:58:15 | password | testCoreData.swift:58:15:58:15 | password | testCoreData.swift:58:15:58:15 | password | This operation stores 'password' in a database. It may contain unencrypted sensitive data from $@ | testCoreData.swift:58:15:58:15 | password | password |
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
edges
2-
| testURL.swift:13:54:13:54 | passwd : | testURL.swift:13:22:13:54 | ... call to +(_:_:) ... |
3-
| testURL.swift:16:55:16:55 | credit_card_no : | testURL.swift:16:22:16:55 | ... call to +(_:_:) ... |
2+
| testURL.swift:13:54:13:54 | passwd : | testURL.swift:13:22:13:54 | ... .+(_:_:) ... |
3+
| testURL.swift:16:55:16:55 | credit_card_no : | testURL.swift:16:22:16:55 | ... .+(_:_:) ... |
44
nodes
55
| testSend.swift:29:19:29:19 | passwordPlain | semmle.label | passwordPlain |
6-
| testURL.swift:13:22:13:54 | ... call to +(_:_:) ... | semmle.label | ... call to +(_:_:) ... |
6+
| testURL.swift:13:22:13:54 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... |
77
| testURL.swift:13:54:13:54 | passwd : | semmle.label | passwd : |
8-
| testURL.swift:16:22:16:55 | ... call to +(_:_:) ... | semmle.label | ... call to +(_:_:) ... |
8+
| testURL.swift:16:22:16:55 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... |
99
| testURL.swift:16:55:16:55 | credit_card_no : | semmle.label | credit_card_no : |
1010
| testURL.swift:20:22:20:22 | passwd | semmle.label | passwd |
1111
subpaths
1212
#select
1313
| testSend.swift:29:19:29:19 | passwordPlain | testSend.swift:29:19:29:19 | passwordPlain | testSend.swift:29:19:29:19 | passwordPlain | This operation transmits 'passwordPlain', which may contain unencrypted sensitive data from $@ | testSend.swift:29:19:29:19 | passwordPlain | passwordPlain |
14-
| testURL.swift:13:22:13:54 | ... call to +(_:_:) ... | testURL.swift:13:54:13:54 | passwd : | testURL.swift:13:22:13:54 | ... call to +(_:_:) ... | This operation transmits '... call to +(_:_:) ...', which may contain unencrypted sensitive data from $@ | testURL.swift:13:54:13:54 | passwd : | passwd |
15-
| testURL.swift:16:22:16:55 | ... call to +(_:_:) ... | testURL.swift:16:55:16:55 | credit_card_no : | testURL.swift:16:22:16:55 | ... call to +(_:_:) ... | This operation transmits '... call to +(_:_:) ...', which may contain unencrypted sensitive data from $@ | testURL.swift:16:55:16:55 | credit_card_no : | credit_card_no |
14+
| testURL.swift:13:22:13:54 | ... .+(_:_:) ... | testURL.swift:13:54:13:54 | passwd : | testURL.swift:13:22:13:54 | ... .+(_:_:) ... | This operation transmits '... .+(_:_:) ...', which may contain unencrypted sensitive data from $@ | testURL.swift:13:54:13:54 | passwd : | passwd |
15+
| testURL.swift:16:22:16:55 | ... .+(_:_:) ... | testURL.swift:16:55:16:55 | credit_card_no : | testURL.swift:16:22:16:55 | ... .+(_:_:) ... | This operation transmits '... .+(_:_:) ...', which may contain unencrypted sensitive data from $@ | testURL.swift:16:55:16:55 | credit_card_no : | credit_card_no |
1616
| testURL.swift:20:22:20:22 | passwd | testURL.swift:20:22:20:22 | passwd | testURL.swift:20:22:20:22 | passwd | This operation transmits 'passwd', which may contain unencrypted sensitive data from $@ | testURL.swift:20:22:20:22 | passwd | passwd |

0 commit comments

Comments
 (0)