Skip to content

Commit 1c52836

Browse files
committed
Swift: Additional test cases.
1 parent dd51b7f commit 1c52836

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ func test2(obj : MyManagedObject, password : String, password_file : String) {
6565
obj.myValue = password_file // GOOD (not sensitive)
6666
}
6767

68+
class MyClass {
69+
var harmless = "abc"
70+
var password = "123"
71+
}
72+
6873
func test3(obj : NSManagedObject, x : String) {
6974
// alternative evidence of sensitivity...
7075

@@ -74,6 +79,10 @@ func test3(obj : NSManagedObject, x : String) {
7479

7580
var y = getPassword();
7681
obj.setValue(y, forKey: "myKey") // BAD
82+
83+
var z = MyClass()
84+
obj.setValue(z.harmless, forKey: "myKey") // GOOD (not sensitive)
85+
obj.setValue(z.password, forKey: "myKey") // BAD
7786
}
7887

7988
func test4(obj : NSManagedObject, pwd : String) {

0 commit comments

Comments
 (0)