File tree Expand file tree Collapse file tree
java/ql/src/Security/CWE/CWE-200 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * @id java/android-websettings-permit-contentacces
3+ */
4+
5+ import java
6+ import semmle.code.java.dataflow.DataFlow
7+ import semmle.code.java.frameworks.android.WebView
8+
9+ private class TypeWebViewOrSubclass extends RefType {
10+ TypeWebViewOrSubclass ( ) { this .getASupertype * ( ) instanceof TypeWebView }
11+ }
12+
13+ // source: WebView
14+ // sink: settings.setAllowContentAccess(false)
15+ class WebViewDisallowContentAccessConfiguration extends DataFlow:: Configuration {
16+ WebViewDisallowContentAccessConfiguration ( ) { this = "WebViewDisallowContentAccessConfiguration" }
17+
18+ override predicate isSource ( DataFlow:: Node source ) {
19+ source .asExpr ( ) .getType ( ) instanceof TypeWebViewOrSubclass and
20+ (
21+ source .asExpr ( ) instanceof ClassInstanceExpr or
22+ source .asExpr ( ) instanceof MethodAccess or
23+ source .asExpr ( ) .( CastExpr ) .getAChildExpr ( ) instanceof MethodAccess
24+ )
25+ }
26+
27+ override predicate isSink ( DataFlow:: Node sink ) {
28+ exists ( MethodAccess ma |
29+ ma = sink .asExpr ( ) and
30+ ma .getMethod ( ) .hasName ( "setAllowContentAccess" ) and
31+ ma .getArgument ( 0 ) .( CompileTimeConstantExpr ) .getBooleanValue ( ) = false
32+ )
33+ }
34+ }
35+
36+ from DataFlow:: Node e , WebViewDisallowContentAccessConfiguration cfg
37+ where cfg .isSource ( e ) and not cfg .hasFlow ( e , _)
38+ select e
You can’t perform that action at this time.
0 commit comments