Skip to content

Commit 1132572

Browse files
committed
Java: add test cases for setJavaScriptEnabled query
1 parent a7e7334 commit 1132572

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.example.test;
2+
3+
import android.webkit.WebView;
4+
import android.webkit.WebSettings;
5+
6+
public class SetJavascriptEnabled {
7+
public static void configureWebViewUnsafe(WebView view) {
8+
WebSettings settings = view.getSettings();
9+
settings.setJavaScriptEnabled(true); // $javascriptEnabled
10+
}
11+
12+
public static void configureWebViewSafe(WebView view) {
13+
WebSettings settings = view.getSettings();
14+
15+
// Safe: Javascript disabled
16+
settings.setJavaScriptEnabled(false);
17+
}
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| SetJavascriptEnabled.java:9:9:9:43 | setJavaScriptEnabled(...) | JavaScript execution enabled in WebView. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Security/CWE/CWE-079/AndroidWebViewSettingsEnabledJavaScript.ql
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../../stubs/servlet-api-2.4:${testdir}/../../../../../stubs/javax-ws-rs-api-2.1.1/:${testdir}/../../../../../stubs/springframework-5.3.8:${testdir}/../../../../../stubs/javax-faces-2.3/
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../../stubs/servlet-api-2.4:${testdir}/../../../../../stubs/javax-ws-rs-api-2.1.1/:${testdir}/../../../../../stubs/springframework-5.3.8:${testdir}/../../../../../stubs/javax-faces-2.3/:${testdir}/../../../../../stubs/google-android-9.0.0

0 commit comments

Comments
 (0)