Skip to content

Commit 75dd95f

Browse files
committed
Swift: Correct one of the tests.
1 parent 99caafb commit 75dd95f

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

swift/ql/test/library-tests/dataflow/taint/LocalTaint.expected

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,33 +1014,22 @@
10141014
| nsstring.swift:294:13:294:13 | harmless | nsstring.swift:294:13:294:47 | call to appendingPathExtension(_:) |
10151015
| nsstring.swift:294:13:294:13 | harmless | nsstring.swift:295:13:295:13 | harmless |
10161016
| nsstring.swift:294:45:294:45 | | nsstring.swift:294:13:294:47 | call to appendingPathExtension(_:) |
1017-
| nsstring.swift:295:13:295:13 | [post] harmless | nsstring.swift:298:14:298:14 | harmless |
1017+
| nsstring.swift:295:13:295:13 | [post] harmless | nsstring.swift:298:13:298:13 | harmless |
10181018
| nsstring.swift:295:13:295:13 | harmless | nsstring.swift:295:13:295:59 | call to appendingPathExtension(_:) |
1019-
| nsstring.swift:295:13:295:13 | harmless | nsstring.swift:298:14:298:14 | harmless |
1019+
| nsstring.swift:295:13:295:13 | harmless | nsstring.swift:298:13:298:13 | harmless |
10201020
| nsstring.swift:295:45:295:58 | call to sourceString() | nsstring.swift:295:13:295:59 | call to appendingPathExtension(_:) |
10211021
| nsstring.swift:296:13:296:28 | call to sourceNSString() | nsstring.swift:296:13:296:55 | call to appendingPathExtension(_:) |
10221022
| nsstring.swift:296:53:296:53 | | nsstring.swift:296:13:296:55 | call to appendingPathExtension(_:) |
1023-
| nsstring.swift:298:7:298:7 | SSA def(str1) | nsstring.swift:299:13:299:13 | str1 |
1024-
| nsstring.swift:298:14:298:14 | harmless | nsstring.swift:298:7:298:7 | SSA def(str1) |
1025-
| nsstring.swift:298:14:298:14 | harmless | nsstring.swift:307:13:307:13 | harmless |
1026-
| nsstring.swift:299:13:299:13 | [post] str1 | nsstring.swift:300:3:300:3 | str1 |
1027-
| nsstring.swift:299:13:299:13 | str1 | nsstring.swift:300:3:300:3 | str1 |
1028-
| nsstring.swift:300:3:300:3 | [post] str1 | nsstring.swift:301:13:301:13 | str1 |
1029-
| nsstring.swift:300:3:300:3 | str1 | nsstring.swift:300:3:300:20 | call to appending(_:) |
1030-
| nsstring.swift:300:3:300:3 | str1 | nsstring.swift:301:13:301:13 | str1 |
1031-
| nsstring.swift:300:18:300:18 | | nsstring.swift:300:3:300:20 | call to appending(_:) |
1032-
| nsstring.swift:301:13:301:13 | [post] str1 | nsstring.swift:302:3:302:3 | str1 |
1033-
| nsstring.swift:301:13:301:13 | str1 | nsstring.swift:302:3:302:3 | str1 |
1034-
| nsstring.swift:302:3:302:3 | [post] str1 | nsstring.swift:303:13:303:13 | str1 |
1035-
| nsstring.swift:302:3:302:3 | str1 | nsstring.swift:302:3:302:32 | call to appending(_:) |
1036-
| nsstring.swift:302:3:302:3 | str1 | nsstring.swift:303:13:303:13 | str1 |
1037-
| nsstring.swift:302:18:302:31 | call to sourceString() | nsstring.swift:302:3:302:32 | call to appending(_:) |
1038-
| nsstring.swift:303:13:303:13 | [post] str1 | nsstring.swift:304:3:304:3 | str1 |
1039-
| nsstring.swift:303:13:303:13 | str1 | nsstring.swift:304:3:304:3 | str1 |
1040-
| nsstring.swift:304:3:304:3 | [post] str1 | nsstring.swift:305:13:305:13 | str1 |
1041-
| nsstring.swift:304:3:304:3 | str1 | nsstring.swift:304:3:304:20 | call to appending(_:) |
1042-
| nsstring.swift:304:3:304:3 | str1 | nsstring.swift:305:13:305:13 | str1 |
1043-
| nsstring.swift:304:18:304:18 | | nsstring.swift:304:3:304:20 | call to appending(_:) |
1023+
| nsstring.swift:298:13:298:13 | [post] harmless | nsstring.swift:300:13:300:13 | harmless |
1024+
| nsstring.swift:298:13:298:13 | harmless | nsstring.swift:298:13:298:34 | call to appending(_:) |
1025+
| nsstring.swift:298:13:298:13 | harmless | nsstring.swift:300:13:300:13 | harmless |
1026+
| nsstring.swift:298:32:298:32 | | nsstring.swift:298:13:298:34 | call to appending(_:) |
1027+
| nsstring.swift:299:13:299:28 | call to sourceNSString() | nsstring.swift:299:13:299:42 | call to appending(_:) |
1028+
| nsstring.swift:299:40:299:40 | | nsstring.swift:299:13:299:42 | call to appending(_:) |
1029+
| nsstring.swift:300:13:300:13 | [post] harmless | nsstring.swift:307:13:307:13 | harmless |
1030+
| nsstring.swift:300:13:300:13 | harmless | nsstring.swift:300:13:300:46 | call to appending(_:) |
1031+
| nsstring.swift:300:13:300:13 | harmless | nsstring.swift:307:13:307:13 | harmless |
1032+
| nsstring.swift:300:32:300:45 | call to sourceString() | nsstring.swift:300:13:300:46 | call to appending(_:) |
10441033
| nsstring.swift:307:13:307:13 | [post] harmless | nsstring.swift:308:13:308:13 | harmless |
10451034
| nsstring.swift:307:13:307:13 | harmless | nsstring.swift:307:13:307:52 | call to strings(byAppendingPaths:) |
10461035
| nsstring.swift:307:13:307:13 | harmless | nsstring.swift:308:13:308:13 | harmless |

swift/ql/test/library-tests/dataflow/taint/Taint.expected

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ edges
363363
| nsstring.swift:69:3:69:61 | [summary param] this in lossyCString() : | file://:0:0:0:0 | [summary] to write: return (return) in lossyCString() : |
364364
| nsstring.swift:72:3:72:106 | [summary param] 0 in appendingFormat(_:_:) : | file://:0:0:0:0 | [summary] to write: return (return) in appendingFormat(_:_:) : |
365365
| nsstring.swift:72:3:72:106 | [summary param] this in appendingFormat(_:_:) : | file://:0:0:0:0 | [summary] to write: return (return) in appendingFormat(_:_:) : |
366+
| nsstring.swift:73:3:73:59 | [summary param] 0 in appending(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in appending(_:) : |
367+
| nsstring.swift:73:3:73:59 | [summary param] this in appending(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in appending(_:) : |
366368
| nsstring.swift:74:3:74:116 | [summary param] 1 in padding(toLength:withPad:startingAt:) : | file://:0:0:0:0 | [summary] to write: return (return) in padding(toLength:withPad:startingAt:) : |
367369
| nsstring.swift:74:3:74:116 | [summary param] this in padding(toLength:withPad:startingAt:) : | file://:0:0:0:0 | [summary] to write: return (return) in padding(toLength:withPad:startingAt:) : |
368370
| nsstring.swift:75:3:75:63 | [summary param] this in lowercased(with:) : | file://:0:0:0:0 | [summary] to write: return (return) in lowercased(with:) : |
@@ -552,6 +554,10 @@ edges
552554
| nsstring.swift:295:45:295:58 | call to sourceString() : | nsstring.swift:295:13:295:59 | call to appendingPathExtension(_:) |
553555
| nsstring.swift:296:13:296:28 | call to sourceNSString() : | nsstring.swift:94:3:94:69 | [summary param] this in appendingPathExtension(_:) : |
554556
| nsstring.swift:296:13:296:28 | call to sourceNSString() : | nsstring.swift:296:13:296:55 | call to appendingPathExtension(_:) |
557+
| nsstring.swift:299:13:299:28 | call to sourceNSString() : | nsstring.swift:73:3:73:59 | [summary param] this in appending(_:) : |
558+
| nsstring.swift:299:13:299:28 | call to sourceNSString() : | nsstring.swift:299:13:299:42 | call to appending(_:) |
559+
| nsstring.swift:300:32:300:45 | call to sourceString() : | nsstring.swift:73:3:73:59 | [summary param] 0 in appending(_:) : |
560+
| nsstring.swift:300:32:300:45 | call to sourceString() : | nsstring.swift:300:13:300:46 | call to appending(_:) |
555561
| nsstring.swift:311:13:311:28 | call to sourceNSString() : | nsstring.swift:95:3:95:74 | [summary param] this in strings(byAppendingPaths:) : |
556562
| nsstring.swift:311:13:311:28 | call to sourceNSString() : | nsstring.swift:311:13:311:60 | call to strings(byAppendingPaths:) |
557563
| nsstring.swift:312:13:312:28 | call to sourceNSString() : | nsstring.swift:95:3:95:74 | [summary param] this in strings(byAppendingPaths:) : |
@@ -1441,6 +1447,8 @@ nodes
14411447
| file://:0:0:0:0 | [summary] to write: return (return) in WKUserScript.init(source:injectionTime:forMainFrameOnly:in:) : | semmle.label | [summary] to write: return (return) in WKUserScript.init(source:injectionTime:forMainFrameOnly:in:) : |
14421448
| file://:0:0:0:0 | [summary] to write: return (return) in appending(_:) : | semmle.label | [summary] to write: return (return) in appending(_:) : |
14431449
| file://:0:0:0:0 | [summary] to write: return (return) in appending(_:) : | semmle.label | [summary] to write: return (return) in appending(_:) : |
1450+
| file://:0:0:0:0 | [summary] to write: return (return) in appending(_:) : | semmle.label | [summary] to write: return (return) in appending(_:) : |
1451+
| file://:0:0:0:0 | [summary] to write: return (return) in appending(_:) : | semmle.label | [summary] to write: return (return) in appending(_:) : |
14441452
| file://:0:0:0:0 | [summary] to write: return (return) in appendingFormat(_:_:) : | semmle.label | [summary] to write: return (return) in appendingFormat(_:_:) : |
14451453
| file://:0:0:0:0 | [summary] to write: return (return) in appendingFormat(_:_:) : | semmle.label | [summary] to write: return (return) in appendingFormat(_:_:) : |
14461454
| file://:0:0:0:0 | [summary] to write: return (return) in appendingPathComponent(_:) : | semmle.label | [summary] to write: return (return) in appendingPathComponent(_:) : |
@@ -1710,6 +1718,8 @@ nodes
17101718
| nsstring.swift:69:3:69:61 | [summary param] this in lossyCString() : | semmle.label | [summary param] this in lossyCString() : |
17111719
| nsstring.swift:72:3:72:106 | [summary param] 0 in appendingFormat(_:_:) : | semmle.label | [summary param] 0 in appendingFormat(_:_:) : |
17121720
| nsstring.swift:72:3:72:106 | [summary param] this in appendingFormat(_:_:) : | semmle.label | [summary param] this in appendingFormat(_:_:) : |
1721+
| nsstring.swift:73:3:73:59 | [summary param] 0 in appending(_:) : | semmle.label | [summary param] 0 in appending(_:) : |
1722+
| nsstring.swift:73:3:73:59 | [summary param] this in appending(_:) : | semmle.label | [summary param] this in appending(_:) : |
17131723
| nsstring.swift:74:3:74:116 | [summary param] 1 in padding(toLength:withPad:startingAt:) : | semmle.label | [summary param] 1 in padding(toLength:withPad:startingAt:) : |
17141724
| nsstring.swift:74:3:74:116 | [summary param] this in padding(toLength:withPad:startingAt:) : | semmle.label | [summary param] this in padding(toLength:withPad:startingAt:) : |
17151725
| nsstring.swift:75:3:75:63 | [summary param] this in lowercased(with:) : | semmle.label | [summary param] this in lowercased(with:) : |
@@ -1896,6 +1906,10 @@ nodes
18961906
| nsstring.swift:295:45:295:58 | call to sourceString() : | semmle.label | call to sourceString() : |
18971907
| nsstring.swift:296:13:296:28 | call to sourceNSString() : | semmle.label | call to sourceNSString() : |
18981908
| nsstring.swift:296:13:296:55 | call to appendingPathExtension(_:) | semmle.label | call to appendingPathExtension(_:) |
1909+
| nsstring.swift:299:13:299:28 | call to sourceNSString() : | semmle.label | call to sourceNSString() : |
1910+
| nsstring.swift:299:13:299:42 | call to appending(_:) | semmle.label | call to appending(_:) |
1911+
| nsstring.swift:300:13:300:46 | call to appending(_:) | semmle.label | call to appending(_:) |
1912+
| nsstring.swift:300:32:300:45 | call to sourceString() : | semmle.label | call to sourceString() : |
18991913
| nsstring.swift:311:13:311:28 | call to sourceNSString() : | semmle.label | call to sourceNSString() : |
19001914
| nsstring.swift:311:13:311:60 | call to strings(byAppendingPaths:) | semmle.label | call to strings(byAppendingPaths:) |
19011915
| nsstring.swift:312:13:312:28 | call to sourceNSString() : | semmle.label | call to sourceNSString() : |
@@ -2548,6 +2562,8 @@ subpaths
25482562
| nsstring.swift:292:13:292:28 | call to sourceNSString() : | nsstring.swift:93:3:93:110 | [summary param] this in appendingPathComponent(_:conformingTo:) : | file://:0:0:0:0 | [summary] to write: return (return) in appendingPathComponent(_:conformingTo:) : | nsstring.swift:292:13:292:88 | call to appendingPathComponent(_:conformingTo:) |
25492563
| nsstring.swift:295:45:295:58 | call to sourceString() : | nsstring.swift:94:3:94:69 | [summary param] 0 in appendingPathExtension(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in appendingPathExtension(_:) : | nsstring.swift:295:13:295:59 | call to appendingPathExtension(_:) |
25502564
| nsstring.swift:296:13:296:28 | call to sourceNSString() : | nsstring.swift:94:3:94:69 | [summary param] this in appendingPathExtension(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in appendingPathExtension(_:) : | nsstring.swift:296:13:296:55 | call to appendingPathExtension(_:) |
2565+
| nsstring.swift:299:13:299:28 | call to sourceNSString() : | nsstring.swift:73:3:73:59 | [summary param] this in appending(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in appending(_:) : | nsstring.swift:299:13:299:42 | call to appending(_:) |
2566+
| nsstring.swift:300:32:300:45 | call to sourceString() : | nsstring.swift:73:3:73:59 | [summary param] 0 in appending(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in appending(_:) : | nsstring.swift:300:13:300:46 | call to appending(_:) |
25512567
| nsstring.swift:311:13:311:28 | call to sourceNSString() : | nsstring.swift:95:3:95:74 | [summary param] this in strings(byAppendingPaths:) : | file://:0:0:0:0 | [summary] to write: return (return) in strings(byAppendingPaths:) : | nsstring.swift:311:13:311:60 | call to strings(byAppendingPaths:) |
25522568
| nsstring.swift:312:13:312:28 | call to sourceNSString() : | nsstring.swift:95:3:95:74 | [summary param] this in strings(byAppendingPaths:) : | file://:0:0:0:0 | [summary] to write: return (return) in strings(byAppendingPaths:) : | nsstring.swift:312:13:312:60 | call to strings(byAppendingPaths:) : |
25532569
| nsstring.swift:334:3:334:18 | call to sourceNSString() : | nsstring.swift:66:3:66:281 | [summary param] this in getBytes(_:maxLength:usedLength:encoding:options:range:remaining:) : | file://:0:0:0:0 | [summary] to write: argument 0 in getBytes(_:maxLength:usedLength:encoding:options:range:remaining:) : | nsstring.swift:334:29:334:29 | [post] ptr3 : |
@@ -2813,6 +2829,8 @@ subpaths
28132829
| nsstring.swift:292:13:292:88 | call to appendingPathComponent(_:conformingTo:) | nsstring.swift:292:13:292:28 | call to sourceNSString() : | nsstring.swift:292:13:292:88 | call to appendingPathComponent(_:conformingTo:) | result |
28142830
| nsstring.swift:295:13:295:59 | call to appendingPathExtension(_:) | nsstring.swift:295:45:295:58 | call to sourceString() : | nsstring.swift:295:13:295:59 | call to appendingPathExtension(_:) | result |
28152831
| nsstring.swift:296:13:296:55 | call to appendingPathExtension(_:) | nsstring.swift:296:13:296:28 | call to sourceNSString() : | nsstring.swift:296:13:296:55 | call to appendingPathExtension(_:) | result |
2832+
| nsstring.swift:299:13:299:42 | call to appending(_:) | nsstring.swift:299:13:299:28 | call to sourceNSString() : | nsstring.swift:299:13:299:42 | call to appending(_:) | result |
2833+
| nsstring.swift:300:13:300:46 | call to appending(_:) | nsstring.swift:300:32:300:45 | call to sourceString() : | nsstring.swift:300:13:300:46 | call to appending(_:) | result |
28162834
| nsstring.swift:311:13:311:60 | call to strings(byAppendingPaths:) | nsstring.swift:311:13:311:28 | call to sourceNSString() : | nsstring.swift:311:13:311:60 | call to strings(byAppendingPaths:) | result |
28172835
| nsstring.swift:312:13:312:63 | ...[...] | nsstring.swift:312:13:312:28 | call to sourceNSString() : | nsstring.swift:312:13:312:63 | ...[...] | result |
28182836
| nsstring.swift:335:13:335:13 | ptr3 | nsstring.swift:334:3:334:18 | call to sourceNSString() : | nsstring.swift:335:13:335:13 | ptr3 | result |

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ func taintThroughInterpolatedStrings() {
295295
sink(arg: harmless.appendingPathExtension(sourceString())) // $ tainted=295
296296
sink(arg: sourceNSString().appendingPathExtension("")) // $ tainted=296
297297

298-
var str1 = harmless
299-
sink(arg: str1)
300-
str1.appending("")
301-
sink(arg: str1)
302-
str1.appending(sourceString())
303-
sink(arg: str1) // $ MISSING: tainted=
304-
str1.appending("")
305-
sink(arg: str1) // $ MISSING: tainted=
298+
sink(arg: harmless.appending(""))
299+
sink(arg: sourceNSString().appending("")) // $ tainted=299
300+
sink(arg: harmless.appending(sourceString())) // $ tainted=300
301+
302+
303+
304+
305+
306306

307307
sink(arg: harmless.strings(byAppendingPaths: [""]))
308308
sink(arg: harmless.strings(byAppendingPaths: [""])[0])

0 commit comments

Comments
 (0)