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 |
A file is world-readable or world-writable.
| Class Name | Permissive File Mode (Java) | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | security | |||||||||||||||||||||
| Mnemonic | JAVA.IO.PERM | |||||||||||||||||||||
| 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="Permissive File Mode (Java)" |
// MainActivity.java package example.fileaccessexample; import android.content.Context; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { FileOutputStream fileOutputStream1 = openFileOutput("foo.txt", Context.MODE_WORLD_READABLE); // Accessing File in Permissive Mode (Java) warning issued here FileOutputStream fileOutputStream2 = openFileOutput("foo.txt", Context.MODE_WORLD_WRITEABLE); // Accessing File in Permissive Mode (Java) warning issued here } catch (FileNotFoundException | SecurityException e) { e.printStackTrace(); } extendAccessPermission(new File("myfile.txt")); } public void extendAccessPermission(File f) { if ( !f.setReadable( true , false )) { // Permissive File Mode (Java) warning issued here Log.e(TAG,"Unable to set readable permission"); } if ( !f.setWritable( true , false )) { // Permissive File Mode (Java) warning issued here Log.e(TAG,"Unable to set writable permission"); } } }
Android's security design philosophy recommends the use of files only for the purpose of perpetuating or temporarily storing information. In principle the file access permissions should be private, in order to limit the risk of information leakage.
The Android API documentation includes guidelines for securely sharing files.
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.