This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org

Difference between revisions of "Dead Code: Unused Method"

From OWASP
Jump to: navigation, search
m (Examples)
Line 2: Line 2:
 
{{Template:Fortify}}
 
{{Template:Fortify}}
  
==Abstract==
+
[[Category:FIXME|This is the text from the old template. This needs to be rewritten using the new template.]]
 +
 
 +
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}'''
 +
 
 +
[[ASDR_TOC_Vulnerabilities|Vulnerabilities Table of Contents]]
 +
 
 +
[[ASDR Table of Contents]]
 +
__TOC__
  
This method is not reachable from any method outside the class.
 
  
 
==Description==
 
==Description==
Line 10: Line 16:
 
This method is never called or is only called from other dead code.
 
This method is never called or is only called from other dead code.
  
==Examples ==
 
  
'''Example 1:''' In the following class, the method doWork() can never be called.
+
 
 +
==Risk Factors==
 +
 
 +
TBD
 +
 
 +
==Examples==
 +
 
 +
 
 +
===Example 1===
 +
 
 +
In the following class, the method doWork() can never be called.
  
 
<pre>
 
<pre>
Line 25: Line 40:
 
</pre>
 
</pre>
  
'''Example 2:''' In the following class, two private methods call each other, but since neither one is ever invoked from anywhere else, they are both dead code.
+
===Example 2===
 +
 
 +
In the following class, two private methods call each other, but since neither one is ever invoked from anywhere else, they are both dead code.
  
 
<pre>
 
<pre>
Line 43: Line 60:
 
(In this case it is a good thing that the methods are dead: invoking either one would cause an infinite loop.)
 
(In this case it is a good thing that the methods are dead: invoking either one would cause an infinite loop.)
  
==Related Threats==
+
==Related [[Attacks]]==
  
==Related Attacks==
+
* [[Attack 1]]
 +
* [[Attack 2]]
  
==Related Vulnerabilities==
 
  
==Related Countermeasures==
+
==Related [[Vulnerabilities]]==
  
==Categories==
+
* [[Vulnerability 1]]
 +
* [[Vulnerabiltiy 2]]
  
 +
 +
==Related [[Controls]]==
 +
 +
* [[Control 1]]
 +
* [[Control 2]]
 +
 +
 +
==Related [[Technical Impacts]]==
 +
 +
* [[Technical Impact 1]]
 +
* [[Technical Impact 2]]
 +
 +
 +
==References==
 +
TBD
 +
[[Category:FIXME|add links
 +
 +
In addition, one should classify vulnerability based on the following subcategories: Ex:<nowiki>[[Category:Error Handling Vulnerability]]</nowiki>
 +
 +
Availability Vulnerability
 +
 +
Authorization Vulnerability
 +
 +
Authentication Vulnerability
 +
 +
Concurrency Vulnerability
 +
 +
Configuration Vulnerability
 +
 +
Cryptographic Vulnerability
 +
 +
Encoding Vulnerability
 +
 +
Error Handling Vulnerability
 +
 +
Input Validation Vulnerability
 +
 +
Logging and Auditing Vulnerability
 +
 +
Session Management Vulnerability]]
 +
 +
__NOTOC__
 +
 +
 +
[[Category:OWASP ASDR Project]]
 
[[Category:Code Quality Vulnerability]]
 
[[Category:Code Quality Vulnerability]]
 
 
[[Category:Java]]
 
[[Category:Java]]
 
 
[[Category:Implementation]]
 
[[Category:Implementation]]
 
 
[[Category:Code Snippet]]
 
[[Category:Code Snippet]]

Revision as of 22:22, 23 September 2008

This is a Vulnerability. To view all vulnerabilities, please see the Vulnerability Category page.

This article includes content generously donated to OWASP by MicroFocus Logo.png

Last revision (mm/dd/yy): 09/23/2008

Vulnerabilities Table of Contents

ASDR Table of Contents


Description

This method is never called or is only called from other dead code.


Risk Factors

TBD

Examples

Example 1

In the following class, the method doWork() can never be called.

	public class Dead {
	  private void doWork() {
		System.out.println("doing work");
	  }
	  public static void main(String[] args) {
		System.out.println("running Dead");
	  }
	}

Example 2

In the following class, two private methods call each other, but since neither one is ever invoked from anywhere else, they are both dead code.

	public class DoubleDead {
	  private void doTweedledee() {
		doTweedledumb();
	  }
	  private void doTweedledumb() {
		doTweedledee();
	  }
	  public static void main(String[] args) {
		System.out.println("running DoubleDead");
	  }
	}

(In this case it is a good thing that the methods are dead: invoking either one would cause an infinite loop.)

Related Attacks


Related Vulnerabilities


Related Controls


Related Technical Impacts


References

TBD