JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
Access to a file scheme URL from any origin is enabled by default.
Android 4.1 (androidAPI16) and later provide methods android.webkit.WebSettings.WebSettings.setAllowUniversalAccessFromFileURLs() and android.webkit.WebSettings.WebSettings.setAllowFileAccessFromFileURLs(). When JavaScript is running in the context of a file scheme URL, these methods can be used to enable/disable access to content from, respectively, other file scheme URLs and any origin (including other file scheme URLs). The Android API documentation for setAllowFileAccessFromFileURLs() recommends disabling these settings to enable the most restrictive, and therefore secure, policy.
Android 4.0.4 (androidAPI15) and earlier permit access to potentially untrusted content by default, through the android.webkit.WebSettings.WebSettings of android.webkit.WebView. For more information, see the Android API documentation for setAllowUniversalAccessFromFileURLs().
| Class Name | Universal JavaScript Access to File URLs (Java) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | security | ||||||||||||
| Mnemonic | JAVA.JS.UAFU | ||||||||||||
| Categories |
|
||||||||||||
| Availability | Available for Java and Kotlin. Android Only. Warnings of this class will only be reported in Android code: that is, code that uses the Android API. |
||||||||||||
| Enabling | Checks for this warning class are enabled by
default. To disable them, add the following WARNING_FILTER rule to the
project configuration file.
WARNING_FILTER += discard class="Universal JavaScript Access to File URLs (Java)" |
package example.javascriptExecutionChecker;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class JavascriptExecutionExample {
public class Test1 extends Activity {
WebView mWebView;
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
this.mWebView = new WebView(this); // "Universal JavaScript Access to File URLs (Java)" warning issued here
this.mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
setContentView(this.mWebView);
}
}
public class Test2 extends Activity {
WebView mWebView;
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
this.mWebView = new WebView(this);
this.mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true); /* "Universal JavaScript Access to File URLs (Java)"
* warning issued here for Android API version 16 or later
*/
setContentView(this.mWebView);
}
}
}
package example.javascriptExecutionChecker;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class JavascriptExecutionExample {
public class Test1 extends Activity {
WebView mWebView;
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
this.mWebView = new WebView(this); /* "Universal JavaScript Access to File URLs (Java)"
* warning issued here for Android API version 15 or earlier
*/
setContentView(this.mWebView);
}
}
}
import android.os.Bundle;
import android.webkit.WebView;
public class MyClass {
WebView mWebView;
public MyClass(WebView view)
{
this.mWebView = view;
this.mWebView.getSettings().setAllowFileAccessFromFileURLs(true); /* "Universal JavaScript Access to File URLs (Java)"
* warning issued here for Android API version 16 or later
*/
}
}
import android.os.Bundle;
import android.webkit.WebView;
public class AnotherMyClass {
WebView mWebView;
public AnotherMyClass(WebView view)
{
this.mWebView = view;
this.mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true); /* "Universal JavaScript Access to File URLs (Java)"
* warning issued here for Android API version 16 or later
*/
}
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.