forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUnsafeActivity5.java
More file actions
43 lines (36 loc) · 1.23 KB
/
UnsafeActivity5.java
File metadata and controls
43 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.example.app;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class UnsafeActivity5 extends BaseActivity {
/*
* Test onCreate with both JavaScript and cross-origin resource access enabled while taking
* remote user inputs from bundle extras.
*
* The Activity is explicitly exported.
*
* Note this case of invoking a helper method from a base class that then calls to
* `getIntent().getStringExtra(...)` is not yet detected thus is beyond what the query is
* capable of.
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(-1);
WebView wv = (WebView) findViewById(-1);
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowFileAccessFromFileURLs(true);
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
String thisUrl = getIntentUrl();
wv.loadUrl(thisUrl); // $ MISSING: hasUnsafeAndroidAccess
thisUrl = getBundleUrl();
wv.loadUrl(thisUrl); // $ MISSING: hasUnsafeAndroidAccess
}
}