Skip to content

Commit 5a451e9

Browse files
committed
Swift: Model mainDocumentURL.
1 parent b157d73 commit 5a451e9

File tree

2 files changed

+6
-4
lines changed
  • swift/ql
    • lib/codeql/swift/frameworks/StandardLibrary
    • test/library-tests/dataflow/taint/libraries

2 files changed

+6
-4
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ private class UriFieldsInheritTaint extends TaintInheritingContent, DataFlow::Co
2222
}
2323

2424
/**
25-
* A content implying that, if a `URLRequest` is tainted, then its fields `url`, `httpBody`,
26-
* `httpBodyStream`, `mainDocument` and `allHTTPHeaderFields` are tainted.
25+
* A content implying that, if a `URLRequest` is tainted, then certain fields tainted.
2726
*/
2827
private class UrlRequestFieldsInheritTaint extends TaintInheritingContent,
2928
DataFlow::Content::FieldContent
3029
{
3130
UrlRequestFieldsInheritTaint() {
3231
this.getField().getEnclosingDecl().asNominalTypeDecl().getName() = "URLRequest" and
3332
this.getField().getName() =
34-
["url", "httpBody", "httpBodyStream", "mainDocument", "allHTTPHeaderFields"]
33+
[
34+
"url", "httpBody", "httpBodyStream", "mainDocument", "mainDocumentURL",
35+
"allHTTPHeaderFields"
36+
]
3537
}
3638
}
3739

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ func taintThroughUrlRequest() {
445445
sink(any: clean.mainDocument)
446446
sink(any: tainted.mainDocument) // $ tainted=431
447447
sink(any: clean.mainDocumentURL!)
448-
sink(any: tainted.mainDocumentURL!) // $ MISSING: tainted=431
448+
sink(any: tainted.mainDocumentURL!) // $ tainted=431
449449
sink(any: clean.allHTTPHeaderFields!)
450450
sink(any: tainted.allHTTPHeaderFields!) // $ tainted=431
451451
sink(any: clean.timeoutInterval)

0 commit comments

Comments
 (0)