mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
Add a new test for
This commit is contained in:
@@ -78,10 +78,7 @@ private class JavaScriptEnabledUrlResourceSink extends UrlResourceSink {
|
|||||||
private class CrossOriginAccessMethod extends Method {
|
private class CrossOriginAccessMethod extends Method {
|
||||||
CrossOriginAccessMethod() {
|
CrossOriginAccessMethod() {
|
||||||
this.getDeclaringType() instanceof TypeWebSettings and
|
this.getDeclaringType() instanceof TypeWebSettings and
|
||||||
(
|
this.hasName(["setAllowUniversalAccessFromFileURLs", "setAllowFileAccessFromFileURLs"])
|
||||||
this.hasName("setAllowUniversalAccessFromFileURLs") or
|
|
||||||
this.hasName("setAllowFileAccessFromFileURLs")
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ public class UnsafeAndroidAccess extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.webview);
|
setContentView(R.layout.webview);
|
||||||
testJavaScriptEnabledWebView();
|
testJavaScriptEnabledWebView();
|
||||||
testCrossOriginEnabledWebView();
|
testUniversalFileAccessEnabledWebView();
|
||||||
|
testFileAccessEnabledWebView();
|
||||||
testSafeWebView();
|
testSafeWebView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testJavaScriptEnabledWebView() {
|
private void testJavaScriptEnabledWebView() {
|
||||||
WebView wv = (WebView) findViewById(R.id.my_webview);
|
WebView wv = (WebView) findViewById(R.id.my_webview);
|
||||||
WebSettings webSettings = wv.getSettings();
|
WebSettings webSettings = wv.getSettings();
|
||||||
|
|
||||||
webSettings.setJavaScriptEnabled(true);
|
webSettings.setJavaScriptEnabled(true);
|
||||||
|
|
||||||
wv.setWebViewClient(new WebViewClient() {
|
wv.setWebViewClient(new WebViewClient() {
|
||||||
@@ -36,7 +36,7 @@ public class UnsafeAndroidAccess extends Activity {
|
|||||||
wv.loadUrl("https://www.mycorp.com"); // Safe
|
wv.loadUrl("https://www.mycorp.com"); // Safe
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testCrossOriginEnabledWebView() {
|
private void testUniversalFileAccessEnabledWebView() {
|
||||||
WebView wv = (WebView) findViewById(R.id.my_webview);
|
WebView wv = (WebView) findViewById(R.id.my_webview);
|
||||||
WebSettings webSettings = wv.getSettings();
|
WebSettings webSettings = wv.getSettings();
|
||||||
webSettings.setAllowUniversalAccessFromFileURLs(true);
|
webSettings.setAllowUniversalAccessFromFileURLs(true);
|
||||||
@@ -55,6 +55,25 @@ public class UnsafeAndroidAccess extends Activity {
|
|||||||
wv.loadUrl("https://www.mycorp.com"); // Safe
|
wv.loadUrl("https://www.mycorp.com"); // Safe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void testFileAccessEnabledWebView() {
|
||||||
|
WebView wv = (WebView) findViewById(R.id.my_webview);
|
||||||
|
WebSettings webSettings = wv.getSettings();
|
||||||
|
webSettings.setAllowFileAccessFromFileURLs(true);
|
||||||
|
|
||||||
|
wv.setWebViewClient(new WebViewClient() {
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
view.loadUrl(url);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
String thisUrl = getIntent().getStringExtra("url");
|
||||||
|
wv.loadUrl(thisUrl); // $hasUnsafeAndroidAccess
|
||||||
|
wv.loadUrl("https://www.mycorp.com/" + thisUrl); // Safe
|
||||||
|
wv.loadUrl("https://www.mycorp.com"); // Safe
|
||||||
|
}
|
||||||
|
|
||||||
private void testSafeWebView() {
|
private void testSafeWebView() {
|
||||||
WebView wv = (WebView) findViewById(-1);
|
WebView wv = (WebView) findViewById(-1);
|
||||||
|
|
||||||
|
|||||||
@@ -28,4 +28,7 @@ public abstract class WebSettings {
|
|||||||
|
|
||||||
public void setAllowUniversalAccessFromFileURLs(boolean b) {
|
public void setAllowUniversalAccessFromFileURLs(boolean b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAllowFileAccessFromFileURLs(boolean b) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user