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
Weilin Zhong (talk | contribs) |
(Reverting to last version not containing links to www.textlaronoe.com) |
||
| (6 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
| − | {{ | + | {{template:CandidateForDeletion}} |
| − | {{ | + | |
| + | #REDIRECT [[Failure to follow guideline/specification]] | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' | ||
| − | |||
| − | |||
==Description== | ==Description== | ||
| Line 10: | Line 14: | ||
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. | ||
| − | |||
| − | + | ||
| + | ==Risk Factors== | ||
| + | |||
| + | TBD | ||
| + | |||
| + | ==Examples== | ||
| + | |||
| + | |||
| + | ===Example 1=== | ||
| + | |||
| + | In the following class, the method doWork() can never be called. | ||
<pre> | <pre> | ||
| Line 23: | Line 36: | ||
} | } | ||
} | } | ||
| − | <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. | |
<pre> | <pre> | ||
| Line 43: | Line 58: | ||
(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 | + | ==Related [[Attacks]]== |
| + | |||
| + | * [[Attack 1]] | ||
| + | * [[Attack 2]] | ||
| + | |||
| + | |||
| + | ==Related [[Vulnerabilities]]== | ||
| + | |||
| + | * [[Vulnerability 1]] | ||
| + | * [[Vulnerabiltiy 2]] | ||
| − | |||
| − | ==Related | + | ==Related [[Controls]]== |
| − | + | * [[Control 1]] | |
| + | * [[Control 2]] | ||
| − | |||
| − | [[ | + | ==Related [[Technical Impacts]]== |
| − | [[ | + | * [[Technical Impact 1]] |
| + | * [[Technical Impact 2]] | ||
| − | |||
| − | + | ==References== | |
| + | TBD | ||
Latest revision as of 18:27, 27 May 2009
#REDIRECT Failure to follow guideline/specification
Last revision (mm/dd/yy): 05/27/2009
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