Skip to content

Commit 87a08fe

Browse files
authored
Merge pull request #17891 from geoffw0/swift6models
Swift: Update models for better Swift 6 compatibility.
2 parents 1f35607 + 24c4e87 commit 87a08fe

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,35 @@ private class CollectionSummaries extends SummaryModelCsv {
1515
row =
1616
[
1717
";Collection;true;prefix(_:);;;Argument[-1];ReturnValue;taint",
18+
";Collection;true;prefix(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
1819
";Collection;true;prefix(through:);;;Argument[-1];ReturnValue;taint",
20+
";Collection;true;prefix(through:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
1921
";Collection;true;prefix(upTo:);;;Argument[-1];ReturnValue;taint",
22+
";Collection;true;prefix(upTo:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
2023
";Collection;true;prefix(while:);;;Argument[-1];ReturnValue;taint",
24+
";Collection;true;prefix(while:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
2125
";Collection;true;suffix(_:);;;Argument[-1];ReturnValue;taint",
26+
";Collection;true;suffix(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
2227
";Collection;true;suffix(from:);;;Argument[-1];ReturnValue;taint",
28+
";Collection;true;suffix(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
2329
";Collection;true;dropFirst(_:);;;Argument[-1];ReturnValue;taint",
30+
";Collection;true;dropFirst(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
2431
";Collection;true;dropLast(_:);;;Argument[-1];ReturnValue;taint",
32+
";Collection;true;dropLast(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
33+
";Collection;true;flatMap(_:);;;Argument[-1];ReturnValue;taint",
34+
";Collection;true;flatMap(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
35+
";Collection;true;map(_:);;;Argument[-1];ReturnValue;taint",
36+
";Collection;true;map(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
2537
";Collection;true;split(maxSplits:omittingEmptySubsequences:whereSeparator:);;;Argument[-1];ReturnValue;taint",
2638
";Collection;true;split(separator:maxSplits:omittingEmptySubsequences:);;;Argument[-1];ReturnValue;taint",
2739
";Collection;true;removeFirst();;;Argument[-1];ReturnValue;taint",
2840
";Collection;true;popFirst();;;Argument[-1];ReturnValue;taint",
2941
";Collection;true;randomElement();;;Argument[-1].CollectionElement;ReturnValue.OptionalSome;value",
42+
";Collection;true;randomElement(using:);;;Argument[-1].CollectionElement;ReturnValue.OptionalSome;value",
43+
";Collection;true;trimmingPrefix(_:);;;Argument[-1];ReturnValue;taint",
44+
";Collection;true;trimmingPrefix(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
45+
";Collection;true;trimmingPrefix(while:);;;Argument[-1];ReturnValue;taint",
46+
";Collection;true;trimmingPrefix(while:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
3047
";RangeReplaceableCollection;true;init(_:);;;Argument[0];ReturnValue.CollectionElement;taint",
3148
";RangeReplaceableCollection;true;init(_:);;;Argument[0].CollectionElement;ReturnValue.CollectionElement;value",
3249
";RangeReplaceableCollection;true;init(repeating:count:);;;Argument[0];ReturnValue.CollectionElement;value",
@@ -38,9 +55,19 @@ private class CollectionSummaries extends SummaryModelCsv {
3855
";RangeReplaceableCollection;true;insert(_:at:);;;Argument[0];Argument[-1];taint",
3956
";RangeReplaceableCollection;true;replaceSubrange(_:with:);;;Argument[1];Argument[-1];taint",
4057
";RangeReplaceableCollection;true;replaceSubrange(_:with:);;;Argument[1].CollectionElement;Argument[-1].CollectionElement;value",
58+
";BidirectionalCollection;true;dropLast(_:);;;Argument[-1];ReturnValue;taint",
59+
";BidirectionalCollection;true;dropLast(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
4160
";BidirectionalCollection;true;joined(separator:);;;Argument[-1..0];ReturnValue;taint",
61+
";BidirectionalCollection;true;joined(separator:);;;Argument[-1].CollectionElement;ReturnValue;taint",
62+
";BidirectionalCollection;true;joined(separator:);;;Argument[-1].CollectionElement.CollectionElement;ReturnValue.CollectionElement;value",
4263
";BidirectionalCollection;true;last(where:);;;Argument[-1];ReturnValue;taint",
4364
";BidirectionalCollection;true;popLast();;;Argument[-1];ReturnValue;taint",
65+
";BidirectionalCollection;true;reversed();;;Argument[-1];ReturnValue;taint",
66+
";BidirectionalCollection;true;reversed();;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
67+
";BidirectionalCollection;true;suffix(_:);;;Argument[-1];ReturnValue;taint",
68+
";BidirectionalCollection;true;suffix(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
69+
";BidirectionalCollection;true;suffix(from:);;;Argument[-1];ReturnValue;taint",
70+
";BidirectionalCollection;true;suffix(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
4471
";MutableCollection;true;withContiguousMutableStorageIfAvailable(_:);;;Argument[-1];Argument[0].Parameter[0].CollectionElement;taint",
4572
";MutableCollection;true;withContiguousMutableStorageIfAvailable(_:);;;Argument[-1].CollectionElement;Argument[0].Parameter[0].CollectionElement;value",
4673
";MutableCollection;true;withContiguousMutableStorageIfAvailable(_:);;;Argument[0].Parameter[0].CollectionElement;Argument[-1].CollectionElement;value",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ private class SequenceSummaries extends SummaryModelCsv {
4545
";Sequence;true;joined();;;Argument[-1].CollectionElement.CollectionElement;ReturnValue.CollectionElement;value",
4646
";Sequence;true;joined(separator:);;;Argument[0..-1];ReturnValue;taint",
4747
";Sequence;true;joined(separator:);;;Argument[-1].CollectionElement;ReturnValue;taint",
48+
";Sequence;true;joined(separator:);;;Argument[-1].CollectionElement.CollectionElement;ReturnValue.CollectionElement;value",
4849
";Sequence;true;first(where:);;;Argument[-1].CollectionElement;ReturnValue;value",
4950
";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[-1];Argument[0].Parameter[0].CollectionElement;taint",
5051
";Sequence;true;withContiguousStorageIfAvailable(_:);;;Argument[-1].CollectionElement;Argument[0].Parameter[0].CollectionElement;value",

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ private class StringFieldsInheritTaint extends TaintInheritingContent,
173173
namedTypeDecl.getFullName() = "CustomDebugStringConvertible" and
174174
fieldDecl.getName() = "debugDescription"
175175
or
176+
namedTypeDecl.getFullName() = "CustomTestStringConvertible" and
177+
fieldDecl.getName() = "testDescription"
178+
or
179+
namedTypeDecl.getFullName() = "CustomURLRepresentationParameterConvertible" and
180+
fieldDecl.getName() = "urlRepresentationParameter"
181+
or
176182
namedTypeDecl.getFullName() = "Substring" and
177183
fieldDecl.getName() = "base"
178184
) and
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
testFailures
22
| optionset.swift:60:49:61:1 | // $ tainted=60\n | Missing result: tainted=60 |
33
| optionset.swift:65:58:66:1 | // $ tainted=65\n | Missing result: tainted=65 |
4-
| string.swift:237:35:238:1 | // $ tainted=217\n | Missing result: tainted=217 |
5-
| string.swift:244:33:245:1 | // $ tainted=217\n | Missing result: tainted=217 |
6-
| string.swift:270:40:271:1 | // $ tainted=217\n | Missing result: tainted=217 |
7-
| string.swift:271:40:272:1 | // $ tainted=217\n | Missing result: tainted=217 |
8-
| string.swift:272:42:273:1 | // $ tainted=217\n | Missing result: tainted=217 |
9-
| string.swift:586:19:587:1 | // $ tainted=565\n | Missing result: tainted=565 |
10-
| string.swift:587:27:588:1 | // $ tainted=565\n | Missing result: tainted=565 |
114
| string.swift:599:35:600:1 | // $ tainted=599\n | Missing result: tainted=599 |
125
| string.swift:605:30:606:1 | // $ tainted=605\n | Missing result: tainted=605 |
136
failures

0 commit comments

Comments
 (0)