Skip to content

Commit 2aa6dd2

Browse files
committed
Swift: Make tests more accurate and don't use 'pwd' as a variable name (it has alternative meanings so is not a good test).
1 parent 1c52836 commit 2aa6dd2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ class NSObject
77

88
class NSManagedObject : NSObject
99
{
10-
func value(forKey: String) -> Any? { return "" }
11-
func setValue(_: Any?, forKey: String) {}
12-
func primitiveValue(forKey: String) -> Any? { return "" }
13-
func setPrimitiveValue(_: Any?, forKey: String) {}
10+
func value(forKey key: String) -> Any? { return "" }
11+
func setValue(_ value: Any?, forKey key: String) {}
12+
func primitiveValue(forKey key: String) -> Any? { return "" }
13+
func setPrimitiveValue(_ value: Any?, forKey key: String) {}
1414
}
1515

1616
class MyManagedObject : NSManagedObject
@@ -85,12 +85,12 @@ func test3(obj : NSManagedObject, x : String) {
8585
obj.setValue(z.password, forKey: "myKey") // BAD
8686
}
8787

88-
func test4(obj : NSManagedObject, pwd : String) {
88+
func test4(obj : NSManagedObject, passwd : String) {
8989
// sanitizers...
9090

91-
var x = pwd;
92-
var y = pwd;
93-
var z = pwd;
91+
var x = passwd;
92+
var y = passwd;
93+
var z = passwd;
9494

9595
obj.setValue(x, forKey: "myKey") // BAD
9696
obj.setValue(y, forKey: "myKey") // BAD

0 commit comments

Comments
 (0)