Skip to content

Commit b678467

Browse files
committed
Move things around
1 parent d68311e commit b678467

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

java/ql/lib/semmle/code/java/frameworks/android/WebView.qll

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,6 @@ class ShouldOverrideUrlLoading extends Method {
7777
}
7878
}
7979

80-
/**
81-
* Holds if `webview` is a `WebView` and its option `setJavascriptEnabled`
82-
* has been set to `true` via a `WebSettings` object obtained from it.
83-
*/
84-
predicate isJSEnabled(DataFlow::Node webview) {
85-
webview.getType().(RefType).getASupertype*() instanceof TypeWebView and
86-
exists(MethodAccess allowJs, MethodAccess settings |
87-
allowJs.getMethod() instanceof AllowJavaScriptMethod and
88-
allowJs.getArgument(0).(CompileTimeConstantExpr).getBooleanValue() = true and
89-
settings.getMethod() instanceof WebViewGetSettingsMethod and
90-
DataFlow::localExprFlow(settings, allowJs.getQualifier()) and
91-
DataFlow::localFlow(webview, DataFlow::getInstanceArgument(settings))
92-
)
93-
}
94-
95-
/**
96-
* Holds if `webview` is a `WebView` and its options `setAllowUniversalAccessFromFileURLs` or
97-
* `setAllowFileAccessFromFileURLs` have been set to `true`.
98-
*/
99-
predicate isAllowFileAccessEnabled(DataFlow::Node webview) {
100-
exists(MethodAccess allowFileAccess, MethodAccess settings |
101-
allowFileAccess.getMethod() instanceof CrossOriginAccessMethod and
102-
allowFileAccess.getArgument(0).(CompileTimeConstantExpr).getBooleanValue() = true and
103-
settings.getMethod() instanceof WebViewGetSettingsMethod and
104-
DataFlow::localExprFlow(settings, allowFileAccess.getQualifier()) and
105-
DataFlow::localFlow(webview, DataFlow::getInstanceArgument(settings))
106-
)
107-
}
108-
10980
private class WebkitSourceModels extends SourceModelCsv {
11081
override predicate row(string row) {
11182
row =

java/ql/lib/semmle/code/java/security/UnsafeAndroidAccess.qll

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ private class CrossOriginUrlResourceSink extends JavaScriptEnabledUrlResourceSin
4343
private 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. */
106135
private class WebViewClientEventMethod extends Method {
107136
WebViewClientEventMethod() {

0 commit comments

Comments
 (0)