Skip to content

Commit daa8141

Browse files
committed
Swift: Add test case.
1 parent beb7d9d commit daa8141

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@
111111
| testGRDB.swift:208:81:208:81 | password | label:password, type:credential |
112112
| testGRDB.swift:210:85:210:85 | password | label:password, type:credential |
113113
| testGRDB.swift:212:99:212:99 | password | label:password, type:credential |
114+
| testRealm.swift:31:20:31:20 | .password | label:password, type:credential |
114115
| testRealm.swift:41:11:41:11 | myPassword | label:myPassword, type:credential |
115116
| testRealm.swift:49:11:49:11 | myPassword | label:myPassword, type:credential |
116117
| testRealm.swift:59:12:59:12 | myPassword | label:myPassword, type:credential |
117118
| testRealm.swift:66:11:66:11 | myPassword | label:myPassword, type:credential |
119+
| testRealm.swift:73:2:73:4 | .password | label:password, type:credential |
120+
| testRealm.swift:73:15:73:15 | myPassword | label:myPassword, type:credential |
118121
| testSend.swift:29:19:29:19 | passwordPlain | label:passwordPlain, type:credential |
119122
| testSend.swift:33:19:33:19 | passwordPlain | label:passwordPlain, type:credential |
120123
| testSend.swift:45:13:45:13 | password | label:password, type:credential |

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ class MyRealmSwiftObject : RealmSwiftObject {
2727
var data: String
2828
}
2929

30+
class MyRealmSwiftObject2 : Object {
31+
override init() { password = "" }
3032

33+
var username: String?
34+
var password: String?
35+
}
3136

32-
33-
34-
35-
36-
37-
func test1(realm : Realm, myPassword : String, myHashedPassword : String) {
37+
func test1(realm : Realm, myUsername: String, myPassword : String, myHashedPassword : String) {
3838
// add objects (within a transaction) ...
3939

4040
let a = MyRealmSwiftObject()
@@ -65,6 +65,13 @@ func test1(realm : Realm, myPassword : String, myHashedPassword : String) {
6565
g.data = "" // GOOD (not sensitive)
6666
g.data = myPassword // BAD
6767
g.data = "" // GOOD (not sensitive)
68+
69+
// MyRealmSwiftObject2...
70+
71+
let h = MyRealmSwiftObject2()
72+
h.username = myUsername // GOOD (not sensitive)
73+
h.password = myPassword // BAD [NOT DETECTED]
74+
realm.add(h)
6875
}
6976

7077
// limitation: its possible to configure a Realm DB to be stored encrypted, if this is done correctly

0 commit comments

Comments
 (0)