@@ -43,8 +43,8 @@ private class CrossOriginUrlResourceSink extends JavaScriptEnabledUrlResourceSin
43
43
private class JavaScriptEnabledUrlResourceSink extends UrlResourceSink {
44
44
JavaScriptEnabledUrlResourceSink ( ) {
45
45
exists ( WebViewRef webview |
46
- isJSEnabled ( webview .getAnAccess ( ) ) and
47
- webViewLoadUrl ( this . asExpr ( ) , webview .getAnAccess ( ) )
46
+ webViewLoadUrl ( this . asExpr ( ) , webview .getAnAccess ( ) ) and
47
+ isJSEnabled ( webview .getAnAccess ( ) )
48
48
)
49
49
}
50
50
@@ -102,6 +102,35 @@ private predicate webViewLoadUrl(Argument urlArg, DataFlow::Node webview) {
102
102
)
103
103
}
104
104
105
+ /**
106
+ * Holds if `webview` is a `WebView` and its option `setJavascriptEnabled`
107
+ * has been set to `true` via a `WebSettings` object obtained from it.
108
+ */
109
+ private predicate isJSEnabled ( DataFlow:: Node webview ) {
110
+ webview .getType ( ) .( RefType ) .getASupertype * ( ) instanceof TypeWebView and
111
+ exists ( MethodAccess allowJs , MethodAccess settings |
112
+ allowJs .getMethod ( ) instanceof AllowJavaScriptMethod and
113
+ allowJs .getArgument ( 0 ) .( CompileTimeConstantExpr ) .getBooleanValue ( ) = true and
114
+ settings .getMethod ( ) instanceof WebViewGetSettingsMethod and
115
+ DataFlow:: localExprFlow ( settings , allowJs .getQualifier ( ) ) and
116
+ DataFlow:: localFlow ( webview , DataFlow:: getInstanceArgument ( settings ) )
117
+ )
118
+ }
119
+
120
+ /**
121
+ * Holds if `webview` is a `WebView` and its options `setAllowUniversalAccessFromFileURLs` or
122
+ * `setAllowFileAccessFromFileURLs` have been set to `true`.
123
+ */
124
+ private predicate isAllowFileAccessEnabled ( DataFlow:: Node webview ) {
125
+ exists ( MethodAccess allowFileAccess , MethodAccess settings |
126
+ allowFileAccess .getMethod ( ) instanceof CrossOriginAccessMethod and
127
+ allowFileAccess .getArgument ( 0 ) .( CompileTimeConstantExpr ) .getBooleanValue ( ) = true and
128
+ settings .getMethod ( ) instanceof WebViewGetSettingsMethod and
129
+ DataFlow:: localExprFlow ( settings , allowFileAccess .getQualifier ( ) ) and
130
+ DataFlow:: localFlow ( webview , DataFlow:: getInstanceArgument ( settings ) )
131
+ )
132
+ }
133
+
105
134
/** A method of the class `WebViewClient` that handles an event. */
106
135
private class WebViewClientEventMethod extends Method {
107
136
WebViewClientEventMethod ( ) {
0 commit comments