Skip to content

Commit 9cd9627

Browse files
committed
Swift: Fix identical rows.
1 parent 981f232 commit 9cd9627

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

swift/ql/lib/codeql/swift/frameworks/StandardLibrary/NsString.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ private class NsStringSummaries extends SummaryModelCsv {
8888
";NSString;true;applyingTransform(_:reverse:);;;Argument[-1];ReturnValue;taint",
8989
";NSString;true;replacingOccurrences(of:with:);;;Argument[-1];ReturnValue;taint",
9090
";NSString;true;replacingOccurrences(of:with:);;;Argument[1];ReturnValue;taint",
91-
";NSString;true;replacingOccurrences(of:with:);;;Argument[-1];ReturnValue;taint",
92-
";NSString;true;replacingOccurrences(of:with:);;;Argument[1];ReturnValue;taint",
91+
";NSString;true;replacingOccurrences(of:with:options:range:);;;Argument[-1];ReturnValue;taint",
92+
";NSString;true;replacingOccurrences(of:with:options:range:);;;Argument[1];ReturnValue;taint",
9393
";NSString;true;replacingCharacters(in:with:);;;Argument[-1];ReturnValue;taint",
9494
";NSString;true;replacingCharacters(in:with:);;;Argument[1];ReturnValue;taint",
9595
";NSString;true;propertyList();;;Argument[-1];ReturnValue;taint",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,12 @@
973973
| nsstring.swift:274:13:274:13 | harmless | nsstring.swift:274:13:274:72 | call to replacingOccurrences(of:with:) |
974974
| nsstring.swift:274:13:274:13 | harmless | nsstring.swift:276:13:276:13 | harmless |
975975
| nsstring.swift:274:58:274:71 | call to sourceString() | nsstring.swift:274:13:274:72 | call to replacingOccurrences(of:with:) |
976+
| nsstring.swift:275:13:275:28 | call to sourceNSString() | nsstring.swift:275:13:275:110 | call to replacingOccurrences(of:with:options:range:) |
977+
| nsstring.swift:275:66:275:66 | b | nsstring.swift:275:13:275:110 | call to replacingOccurrences(of:with:options:range:) |
976978
| nsstring.swift:276:13:276:13 | [post] harmless | nsstring.swift:287:13:287:13 | harmless |
979+
| nsstring.swift:276:13:276:13 | harmless | nsstring.swift:276:13:276:113 | call to replacingOccurrences(of:with:options:range:) |
977980
| nsstring.swift:276:13:276:13 | harmless | nsstring.swift:287:13:287:13 | harmless |
981+
| nsstring.swift:276:58:276:71 | call to sourceString() | nsstring.swift:276:13:276:113 | call to replacingOccurrences(of:with:options:range:) |
978982
| nsstring.swift:277:43:277:57 | [...] | nsstring.swift:277:13:277:58 | call to path(withComponents:) |
979983
| nsstring.swift:278:43:278:61 | call to sourceStringArray() | nsstring.swift:278:13:278:62 | call to path(withComponents:) |
980984
| nsstring.swift:279:43:279:68 | [...] | nsstring.swift:279:13:279:69 | call to path(withComponents:) |

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ edges
384384
| nsstring.swift:84:3:84:94 | [summary param] this in applyingTransform(_:reverse:) : | file://:0:0:0:0 | [summary] to write: return (return) in applyingTransform(_:reverse:) : |
385385
| nsstring.swift:86:3:86:96 | [summary param] 1 in replacingOccurrences(of:with:) : | file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:) : |
386386
| nsstring.swift:86:3:86:96 | [summary param] this in replacingOccurrences(of:with:) : | file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:) : |
387+
| nsstring.swift:87:3:87:163 | [summary param] 1 in replacingOccurrences(of:with:options:range:) : | file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:options:range:) : |
388+
| nsstring.swift:87:3:87:163 | [summary param] this in replacingOccurrences(of:with:options:range:) : | file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:options:range:) : |
387389
| nsstring.swift:88:3:88:41 | [summary param] this in propertyList() : | file://:0:0:0:0 | [summary] to write: return (return) in propertyList() : |
388390
| nsstring.swift:89:3:89:80 | [summary param] this in propertyListFromStringsFileFormat() : | file://:0:0:0:0 | [summary] to write: return (return) in propertyListFromStringsFileFormat() : |
389391
| nsstring.swift:90:3:90:76 | [summary param] this in variantFittingPresentationWidth(_:) : | file://:0:0:0:0 | [summary] to write: return (return) in variantFittingPresentationWidth(_:) : |
@@ -543,6 +545,10 @@ edges
543545
| nsstring.swift:273:13:273:28 | call to sourceNSString() : | nsstring.swift:273:13:273:69 | call to replacingOccurrences(of:with:) |
544546
| nsstring.swift:274:58:274:71 | call to sourceString() : | nsstring.swift:86:3:86:96 | [summary param] 1 in replacingOccurrences(of:with:) : |
545547
| nsstring.swift:274:58:274:71 | call to sourceString() : | nsstring.swift:274:13:274:72 | call to replacingOccurrences(of:with:) |
548+
| nsstring.swift:275:13:275:28 | call to sourceNSString() : | nsstring.swift:87:3:87:163 | [summary param] this in replacingOccurrences(of:with:options:range:) : |
549+
| nsstring.swift:275:13:275:28 | call to sourceNSString() : | nsstring.swift:275:13:275:110 | call to replacingOccurrences(of:with:options:range:) |
550+
| nsstring.swift:276:58:276:71 | call to sourceString() : | nsstring.swift:87:3:87:163 | [summary param] 1 in replacingOccurrences(of:with:options:range:) : |
551+
| nsstring.swift:276:58:276:71 | call to sourceString() : | nsstring.swift:276:13:276:113 | call to replacingOccurrences(of:with:options:range:) |
546552
| nsstring.swift:278:43:278:61 | call to sourceStringArray() : | nsstring.swift:56:3:56:78 | [summary param] 0 in path(withComponents:) : |
547553
| nsstring.swift:278:43:278:61 | call to sourceStringArray() : | nsstring.swift:278:13:278:62 | call to path(withComponents:) |
548554
| nsstring.swift:280:42:280:56 | call to sourceCString() : | nsstring.swift:57:3:57:83 | [summary param] 0 in string(withCString:) : |
@@ -1562,6 +1568,8 @@ nodes
15621568
| file://:0:0:0:0 | [summary] to write: return (return) in removeLast() : | semmle.label | [summary] to write: return (return) in removeLast() : |
15631569
| file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:) : | semmle.label | [summary] to write: return (return) in replacingOccurrences(of:with:) : |
15641570
| file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:) : | semmle.label | [summary] to write: return (return) in replacingOccurrences(of:with:) : |
1571+
| file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:options:range:) : | semmle.label | [summary] to write: return (return) in replacingOccurrences(of:with:options:range:) : |
1572+
| file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:options:range:) : | semmle.label | [summary] to write: return (return) in replacingOccurrences(of:with:options:range:) : |
15651573
| file://:0:0:0:0 | [summary] to write: return (return) in reversed() : | semmle.label | [summary] to write: return (return) in reversed() : |
15661574
| file://:0:0:0:0 | [summary] to write: return (return) in reversed() : | semmle.label | [summary] to write: return (return) in reversed() : |
15671575
| file://:0:0:0:0 | [summary] to write: return (return) in shuffled() : | semmle.label | [summary] to write: return (return) in shuffled() : |
@@ -1794,6 +1802,8 @@ nodes
17941802
| nsstring.swift:84:3:84:94 | [summary param] this in applyingTransform(_:reverse:) : | semmle.label | [summary param] this in applyingTransform(_:reverse:) : |
17951803
| nsstring.swift:86:3:86:96 | [summary param] 1 in replacingOccurrences(of:with:) : | semmle.label | [summary param] 1 in replacingOccurrences(of:with:) : |
17961804
| nsstring.swift:86:3:86:96 | [summary param] this in replacingOccurrences(of:with:) : | semmle.label | [summary param] this in replacingOccurrences(of:with:) : |
1805+
| nsstring.swift:87:3:87:163 | [summary param] 1 in replacingOccurrences(of:with:options:range:) : | semmle.label | [summary param] 1 in replacingOccurrences(of:with:options:range:) : |
1806+
| nsstring.swift:87:3:87:163 | [summary param] this in replacingOccurrences(of:with:options:range:) : | semmle.label | [summary param] this in replacingOccurrences(of:with:options:range:) : |
17971807
| nsstring.swift:88:3:88:41 | [summary param] this in propertyList() : | semmle.label | [summary param] this in propertyList() : |
17981808
| nsstring.swift:89:3:89:80 | [summary param] this in propertyListFromStringsFileFormat() : | semmle.label | [summary param] this in propertyListFromStringsFileFormat() : |
17991809
| nsstring.swift:90:3:90:76 | [summary param] this in variantFittingPresentationWidth(_:) : | semmle.label | [summary param] this in variantFittingPresentationWidth(_:) : |
@@ -1950,6 +1960,10 @@ nodes
19501960
| nsstring.swift:273:13:273:69 | call to replacingOccurrences(of:with:) | semmle.label | call to replacingOccurrences(of:with:) |
19511961
| nsstring.swift:274:13:274:72 | call to replacingOccurrences(of:with:) | semmle.label | call to replacingOccurrences(of:with:) |
19521962
| nsstring.swift:274:58:274:71 | call to sourceString() : | semmle.label | call to sourceString() : |
1963+
| nsstring.swift:275:13:275:28 | call to sourceNSString() : | semmle.label | call to sourceNSString() : |
1964+
| nsstring.swift:275:13:275:110 | call to replacingOccurrences(of:with:options:range:) | semmle.label | call to replacingOccurrences(of:with:options:range:) |
1965+
| nsstring.swift:276:13:276:113 | call to replacingOccurrences(of:with:options:range:) | semmle.label | call to replacingOccurrences(of:with:options:range:) |
1966+
| nsstring.swift:276:58:276:71 | call to sourceString() : | semmle.label | call to sourceString() : |
19531967
| nsstring.swift:278:13:278:62 | call to path(withComponents:) | semmle.label | call to path(withComponents:) |
19541968
| nsstring.swift:278:43:278:61 | call to sourceStringArray() : | semmle.label | call to sourceStringArray() : |
19551969
| nsstring.swift:280:13:280:57 | call to string(withCString:) | semmle.label | call to string(withCString:) |
@@ -2647,6 +2661,8 @@ subpaths
26472661
| nsstring.swift:272:13:272:28 | call to sourceNSString() : | nsstring.swift:92:3:92:91 | [summary param] this in data(using:allowLossyConversion:) : | file://:0:0:0:0 | [summary] to write: return (return) in data(using:allowLossyConversion:) : | nsstring.swift:272:13:272:72 | call to data(using:allowLossyConversion:) |
26482662
| nsstring.swift:273:13:273:28 | call to sourceNSString() : | nsstring.swift:86:3:86:96 | [summary param] this in replacingOccurrences(of:with:) : | file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:) : | nsstring.swift:273:13:273:69 | call to replacingOccurrences(of:with:) |
26492663
| nsstring.swift:274:58:274:71 | call to sourceString() : | nsstring.swift:86:3:86:96 | [summary param] 1 in replacingOccurrences(of:with:) : | file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:) : | nsstring.swift:274:13:274:72 | call to replacingOccurrences(of:with:) |
2664+
| nsstring.swift:275:13:275:28 | call to sourceNSString() : | nsstring.swift:87:3:87:163 | [summary param] this in replacingOccurrences(of:with:options:range:) : | file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:options:range:) : | nsstring.swift:275:13:275:110 | call to replacingOccurrences(of:with:options:range:) |
2665+
| nsstring.swift:276:58:276:71 | call to sourceString() : | nsstring.swift:87:3:87:163 | [summary param] 1 in replacingOccurrences(of:with:options:range:) : | file://:0:0:0:0 | [summary] to write: return (return) in replacingOccurrences(of:with:options:range:) : | nsstring.swift:276:13:276:113 | call to replacingOccurrences(of:with:options:range:) |
26502666
| nsstring.swift:278:43:278:61 | call to sourceStringArray() : | nsstring.swift:56:3:56:78 | [summary param] 0 in path(withComponents:) : | file://:0:0:0:0 | [summary] to write: return (return) in path(withComponents:) : | nsstring.swift:278:13:278:62 | call to path(withComponents:) |
26512667
| nsstring.swift:280:42:280:56 | call to sourceCString() : | nsstring.swift:57:3:57:83 | [summary param] 0 in string(withCString:) : | file://:0:0:0:0 | [summary] to write: return (return) in string(withCString:) : | nsstring.swift:280:13:280:57 | call to string(withCString:) |
26522668
| nsstring.swift:281:42:281:56 | call to sourceCString() : | nsstring.swift:58:3:58:96 | [summary param] 0 in string(withCString:length:) : | file://:0:0:0:0 | [summary] to write: return (return) in string(withCString:length:) : | nsstring.swift:281:13:281:70 | call to string(withCString:length:) |
@@ -2925,6 +2941,8 @@ subpaths
29252941
| nsstring.swift:272:13:272:72 | call to data(using:allowLossyConversion:) | nsstring.swift:272:13:272:28 | call to sourceNSString() : | nsstring.swift:272:13:272:72 | call to data(using:allowLossyConversion:) | result |
29262942
| nsstring.swift:273:13:273:69 | call to replacingOccurrences(of:with:) | nsstring.swift:273:13:273:28 | call to sourceNSString() : | nsstring.swift:273:13:273:69 | call to replacingOccurrences(of:with:) | result |
29272943
| nsstring.swift:274:13:274:72 | call to replacingOccurrences(of:with:) | nsstring.swift:274:58:274:71 | call to sourceString() : | nsstring.swift:274:13:274:72 | call to replacingOccurrences(of:with:) | result |
2944+
| nsstring.swift:275:13:275:110 | call to replacingOccurrences(of:with:options:range:) | nsstring.swift:275:13:275:28 | call to sourceNSString() : | nsstring.swift:275:13:275:110 | call to replacingOccurrences(of:with:options:range:) | result |
2945+
| nsstring.swift:276:13:276:113 | call to replacingOccurrences(of:with:options:range:) | nsstring.swift:276:58:276:71 | call to sourceString() : | nsstring.swift:276:13:276:113 | call to replacingOccurrences(of:with:options:range:) | result |
29282946
| nsstring.swift:278:13:278:62 | call to path(withComponents:) | nsstring.swift:278:43:278:61 | call to sourceStringArray() : | nsstring.swift:278:13:278:62 | call to path(withComponents:) | result |
29292947
| nsstring.swift:280:13:280:57 | call to string(withCString:) | nsstring.swift:280:42:280:56 | call to sourceCString() : | nsstring.swift:280:13:280:57 | call to string(withCString:) | result |
29302948
| nsstring.swift:281:13:281:70 | call to string(withCString:length:) | nsstring.swift:281:42:281:56 | call to sourceCString() : | nsstring.swift:281:13:281:70 | call to string(withCString:length:) | result |

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ func taintThroughInterpolatedStrings() {
272272
sink(arg: sourceNSString().data(using: 0, allowLossyConversion: false)) // $ tainted=272
273273
sink(arg: sourceNSString().replacingOccurrences(of: "a", with: "b")) // $ tainted=273
274274
sink(arg: harmless.replacingOccurrences(of: "a", with: sourceString())) // $ tainted=274
275-
sink(arg: sourceNSString().replacingOccurrences(of: "a", with: "b", range: NSRange(location: 0, length: 10))) // $ MISSING: tainted=
276-
sink(arg: harmless.replacingOccurrences(of: "a", with: sourceString(), range: NSRange(location: 0, length: 10))) // $ MISSING: tainted=
275+
sink(arg: sourceNSString().replacingOccurrences(of: "a", with: "b", range: NSRange(location: 0, length: 10))) // $ tainted=275
276+
sink(arg: harmless.replacingOccurrences(of: "a", with: sourceString(), range: NSRange(location: 0, length: 10))) // $ tainted=276
277277
sink(arg: NSString.path(withComponents: ["a", "b", "c"]))
278278
sink(arg: NSString.path(withComponents: sourceStringArray())) // $ tainted=278
279279
sink(arg: NSString.path(withComponents: ["a", sourceString(), "c"])) // $ MISSING: tainted=

0 commit comments

Comments
 (0)