Skip to content

Commit 730532f

Browse files
committed
Swift: Add some (limited) test coverage for NSString <-> Data conversion.
1 parent 1332309 commit 730532f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

swift/ql/test/library-tests/dataflow/taint/libraries/nsstring.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,12 @@ func taintThroughConversions() {
476476
let str7 = str5 as! String // in real-world Swift you can just use `as` here
477477
sink(arg: str7) // $ tainted=473
478478
}
479+
480+
func taintThroughData() {
481+
// additional tests through the `Data` class
482+
let str1 = sourceNSString()
483+
let data1 = str1.data(using: 0)!
484+
sink(arg: data1) // $ tainted=482
485+
let str2 = NSString(data: data1, encoding: 0)!
486+
sink(arg: str2) // $ tainted=482
487+
}

0 commit comments

Comments
 (0)