File tree Expand file tree Collapse file tree 2 files changed +15
-16
lines changed
lib/codeql/swift/frameworks/StandardLibrary
test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree 2 files changed +15
-16
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ struct URLRequest {}
7676
7777// --- tests ---
7878
79- func source( ) -> Any { return " " }
79+ func source( _ label : String ? = " " ) -> Any { return " " }
8080func sink( _: Any ) { }
8181
8282func testInheritBodyTaint( ) {
@@ -146,6 +146,9 @@ func testWKUserScript() {
146146}
147147
148148func testWKNavigationAction( ) {
149- let src = source ( ) as! WKNavigationAction
150- sink ( src. request) // $ tainted=149
151- }
149+ let src = source ( " WKNavigationAction " ) as! WKNavigationAction
150+ sink ( src. request) // $ tainted=WKNavigationAction
151+
152+ let keypath = \WKNavigationAction . request
153+ sink ( src [ keyPath: keypath] ) // $ tainted=WKNavigationAction
154+ }
You can’t perform that action at this time.
0 commit comments