Skip to content

Commit b62ede1

Browse files
committed
Fix issue in JsExportedSource
Model the source as an access to the tainted field, instead of the field itself (which didn't work)
1 parent 2402504 commit b62ede1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private class JsExportedSource extends RemoteFlowSource {
125125
base.getEnclosingDecl() instanceof JsExportedProto and
126126
adopter.getEnclosingDecl() instanceof JsExportedType
127127
|
128-
this.asDefinition().getSourceVariable() = adopter and adopter.getName() = base.getName()
128+
this.asExpr().(MemberRefExpr).getMember() = adopter and adopter.getName() = base.getName()
129129
)
130130
}
131131

swift/ql/test/library-tests/dataflow/flowsources/FlowSources.expected

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
| webview.swift:20:82:20:102 | message | external |
1212
| webview.swift:25:5:25:13 | .globalObject | external |
1313
| webview.swift:26:5:26:39 | call to objectForKeyedSubscript(_:) | external |
14-
| webview.swift:38:10:38:10 | self | Member of a type exposed through JSExport |
15-
| webview.swift:38:18:38:24 | arg1 | Member of a type exposed through JSExport |
16-
| webview.swift:38:29:38:35 | arg2 | Member of a type exposed through JSExport |
14+
| webview.swift:39:9:39:9 | .tainted | Member of a type exposed through JSExport |
15+
| webview.swift:43:10:43:10 | self | Member of a type exposed through JSExport |
16+
| webview.swift:43:18:43:24 | arg1 | Member of a type exposed through JSExport |
17+
| webview.swift:43:29:43:35 | arg2 | Member of a type exposed through JSExport |

swift/ql/test/library-tests/dataflow/flowsources/webview.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ protocol Exported : JSExport {
3131
func tainted(arg1: Any, arg2: Any)
3232
}
3333
class ExportedImpl : Exported {
34-
var tainted: Any { get { return "" } } // SOURCE
34+
var tainted: Any { get { return "" } }
3535

3636
var notTainted: Any { get { return ""} }
3737

38+
func readFields() {
39+
tainted // SOURCE
40+
notTainted
41+
}
42+
3843
func tainted(arg1: Any, arg2: Any) { // SOURCES
3944
}
4045

0 commit comments

Comments
 (0)