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
Java


JAVA.JS.UAFU : Universal JavaScript Access to File URLs (Java)

要旨

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().

プロパティ

クラス名 Universal JavaScript Access to File URLs (Java)
日本語クラス名 Universal JavaScript Access to File URLs (Java)
クラス分類 セキュリティ (security)
ニーモニック JAVA.JS.UAFU
カテゴリー
CWE CWE:749 Exposed Dangerous Method or Function
OWASP-2017 OWASP-2017:A5 Broken access control
OWASP-2021 OWASP-2021:A1 Broken access control
OWASP-2025 OWASP-2025:A01 Broken Access Control
対応言語 Available for Java and Kotlin.
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
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 
                                                       */ 
  }
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。

 

To report problems with this documentation, please visit https://support.codesecure.com/.