@@ -43,8 +43,8 @@ private class CrossOriginUrlResourceSink extends JavaScriptEnabledUrlResourceSin
4343private class JavaScriptEnabledUrlResourceSink extends UrlResourceSink {
4444 JavaScriptEnabledUrlResourceSink ( ) {
4545 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 ( ) )
4848 )
4949 }
5050
@@ -102,6 +102,35 @@ private predicate webViewLoadUrl(Argument urlArg, DataFlow::Node webview) {
102102 )
103103}
104104
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+
105134/** A method of the class `WebViewClient` that handles an event. */
106135private class WebViewClientEventMethod extends Method {
107136 WebViewClientEventMethod ( ) {
0 commit comments