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 method that always returns true is used to perform fragment validation.
| Class Name | Ineffective Cleansing of Fragment Taint (Java) | |||
|---|---|---|---|---|
| Significance | security | |||
| Mnemonic | JAVA.IO.TAINT.IC.FRAGMENT | |||
| 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="Ineffective Cleansing of Fragment Taint (Java)" |
// UncontrolledFragment1.java package com.juliasoft.julia.tests.checks.useOfUncontrolledExternalData; import android.app.Fragment; import android.app.FragmentTransaction; import android.os.Bundle; import android.preference.PreferenceActivity; import android.webkit.WebView; public class UncontrolledFragment1 extends PreferenceActivity // Missing isValidFragment Override (Java) warning issued here { WebView mWebView; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); final Fragment f = Fragment.instantiate(this, initialFragment, null); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); transaction.replace(11, f); transaction.commitAllowingStateLoss(); // Fragment Injection (Java) warning issued here } }
// UncontrolledFragment2.java package com.juliasoft.julia.tests.checks.useOfUncontrolledExternalData; import android.app.Fragment; import android.app.FragmentTransaction; import android.os.Bundle; import android.preference.PreferenceActivity; import android.webkit.WebView; public class UncontrolledFragment2 extends PreferenceActivity { WebView mWebView; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); if(isValidFragment(initialFragment)) { final Fragment f = Fragment.instantiate(this, initialFragment, null); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); transaction.replace(11, f); transaction.commitAllowingStateLoss(); } } @Override protected boolean isValidFragment(String fragmentName) { return true; // Ineffective Cleansing of Fragment Taint (Java) warning issued here } }
The warnings in this example are all relative to external fragments and their validation. The external fragments without or with a wrong validation could lead to security issues. As described in the Android API documentation for isValidFragment(), subclasses of PreferenceActivity should override the isValidFragment() method and verify that the given fragment is a valid type to be attached to this activity.
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.