Skip to content

Commit feadd71

Browse files
committed
Swift: Add tests with some different container types.
1 parent 63c71f0 commit feadd71

File tree

1 file changed

+29
-0
lines changed
  • swift/ql/test/library-tests/dataflow/taint/libraries

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,32 @@ func taintThroughMutablePointer() {
137137
sink(arg: myMutableBuffer)
138138
sink(arg: myMutableBuffer[0]) // $ MISSING: tainted=131
139139
}
140+
141+
func taintCollections(array: inout Array<Int>, contiguousArray: inout ContiguousArray<Int>, dictionary: inout Dictionary<Int, Int>) {
142+
array[0] = source2()
143+
sink(arg: array)
144+
sink(arg: array[0]) // $ tainted=142
145+
array.withContiguousStorageIfAvailable({
146+
buffer in
147+
sink(arg: array)
148+
sink(arg: array[0]) // $ MISSING: tainted=142
149+
})
150+
151+
contiguousArray[0] = source2()
152+
sink(arg: contiguousArray)
153+
sink(arg: contiguousArray[0]) // $ MISSING: tainted=151
154+
contiguousArray.withContiguousStorageIfAvailable({
155+
buffer in
156+
sink(arg: buffer)
157+
sink(arg: buffer[0]) // $ MISSING: tainted=151
158+
})
159+
160+
dictionary[0] = source2()
161+
sink(arg: dictionary)
162+
sink(arg: dictionary[0]!) // $ MISSING: tainted=160
163+
dictionary.withContiguousStorageIfAvailable({
164+
buffer in
165+
sink(arg: buffer)
166+
sink(arg: buffer[0]) // $ MISSING: tainted=160
167+
})
168+
}

0 commit comments

Comments
 (0)