Skip to content

Commit 463096e

Browse files
committed
Swift: Modernize tainted content in WebView.qll.
1 parent 892beea commit 463096e

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,15 @@ private class WKNavigationDelegateSource extends RemoteFlowSource {
7474
}
7575

7676
/**
77-
* A taint step implying that, if a `WKNavigationAction` is tainted, its `request` field is also tainted.
77+
* A content implying that, if a `WKNavigationAction` is tainted, its
78+
* `request` field is also tainted.
7879
*/
79-
private class WKNavigationActionTaintStep extends AdditionalTaintStep {
80-
override predicate step(DataFlow::Node n1, DataFlow::Node n2) {
81-
exists(MemberRefExpr e, Expr self, VarDecl member |
82-
self.getType().getName() = "WKNavigationAction" and
83-
member.getName() = "request"
84-
|
85-
e.getBase() = self and
86-
e.getMember() = member and
87-
n1.asExpr() = self and
88-
n2.asExpr() = e
89-
)
80+
private class UrlRequestFieldsInheritTaint extends TaintInheritingContent,
81+
DataFlow::Content::FieldContent
82+
{
83+
UrlRequestFieldsInheritTaint() {
84+
this.getField().getEnclosingDecl().asNominalTypeDecl().getName() = "WKNavigationAction" and
85+
this.getField().getName() = "request"
9086
}
9187
}
9288

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ func testWKNavigationAction() {
150150
sink(src.request) // $ tainted=WKNavigationAction
151151

152152
let keypath = \WKNavigationAction.request
153-
sink(src[keyPath: keypath]) // $ MISSING: tainted=WKNavigationAction
153+
sink(src[keyPath: keypath]) // $ tainted=WKNavigationAction
154154
}

0 commit comments

Comments
 (0)