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 {
74
74
}
75
75
76
76
/**
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.
78
79
*/
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"
90
86
}
91
87
}
92
88
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ struct URLRequest {}
76
76
77
77
// --- tests ---
78
78
79
- func source( ) -> Any { return " " }
79
+ func source( _ label : String ? = " " ) -> Any { return " " }
80
80
func sink( _: Any ) { }
81
81
82
82
func testInheritBodyTaint( ) {
@@ -146,6 +146,9 @@ func testWKUserScript() {
146
146
}
147
147
148
148
func 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