Skip to content

Commit d0f214a

Browse files
committed
Swift: Widen the model to include things that are not strictly RawRepresentable but which appear similar. This fixes the XXE test cases. Unclear whether xmlParserOption in the test should in fact extend RawRepresentable, or not.
1 parent 4e29ed5 commit d0f214a

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,12 @@ private class RawRepresentableSummaries extends SummaryModelCsv {
1717
}
1818

1919
/**
20-
* A content implying that, if an `RawRepresentable` is tainted, then
21-
* the `rawValue` field is tainted as well.
20+
* A content implying that, if a `RawRepresentable` is tainted, then the
21+
* `rawValue` field is tainted as well. This model has been extended to assume
22+
* that any object's `rawValue` field also inherits taint.
2223
*/
2324
private class RawRepresentableFieldsInheritTaint extends TaintInheritingContent,
2425
DataFlow::Content::FieldContent
2526
{
26-
RawRepresentableFieldsInheritTaint() {
27-
exists(FieldDecl fieldDecl, Decl declaringDecl, TypeDecl namedTypeDecl |
28-
namedTypeDecl.getFullName() = "RawRepresentable" and
29-
fieldDecl.getName() = "rawValue" and
30-
declaringDecl.getAMember() = fieldDecl and
31-
declaringDecl.asNominalTypeDecl() = namedTypeDecl.getADerivedTypeDecl*() and
32-
this.getField() = fieldDecl
33-
)
34-
}
27+
RawRepresentableFieldsInheritTaint() { this.getField().getName() = "rawValue" }
3528
}
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,2 @@
11
testFailures
2-
| testLibxmlXXE.swift:101:78:102:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
3-
| testLibxmlXXE.swift:102:80:103:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
4-
| testLibxmlXXE.swift:103:107:104:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
5-
| testLibxmlXXE.swift:104:82:105:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
6-
| testLibxmlXXE.swift:106:78:107:1 | // $ hasXXE=95\n | Missing result:hasXXE=95 |
7-
| testLibxmlXXE.swift:107:80:108:1 | // $ hasXXE=95\n | Missing result:hasXXE=95 |
8-
| testLibxmlXXE.swift:109:87:110:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
9-
| testLibxmlXXE.swift:110:89:111:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
10-
| testLibxmlXXE.swift:112:99:113:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
11-
| testLibxmlXXE.swift:113:97:114:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
12-
| testLibxmlXXE.swift:115:87:116:1 | // $ hasXXE=95\n | Missing result:hasXXE=95 |
13-
| testLibxmlXXE.swift:116:89:117:1 | // $ hasXXE=95\n | Missing result:hasXXE=95 |
14-
| testLibxmlXXE.swift:118:89:119:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
15-
| testLibxmlXXE.swift:119:91:120:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
16-
| testLibxmlXXE.swift:121:98:122:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
17-
| testLibxmlXXE.swift:122:100:123:1 | // $ hasXXE=96\n | Missing result:hasXXE=96 |
182
failures

0 commit comments

Comments
 (0)