File tree Expand file tree Collapse file tree 3 files changed +5
-15
lines changed
java/ql/src/experimental/Security/CWE/CWE-489 Expand file tree Collapse file tree 3 files changed +5
-15
lines changed Original file line number Diff line number Diff line change 99
1010import java
1111import semmle.code.java.J2EE
12- import MainLib
12+ import TestLib
1313
1414/** The `main` method in an Enterprise Java Bean. */
1515class EnterpriseBeanMainMethod extends Method {
1616 EnterpriseBeanMainMethod ( ) {
1717 this .getDeclaringType ( ) instanceof EnterpriseBean and
18- isMainMethod ( this ) and
18+ this instanceof MainMethod and
1919 not isTestMethod ( this )
2020 }
2121}
Original file line number Diff line number Diff line change 1- /** Definitions related to the main method in a test program . */
1+ /** Definitions related to test methods . */
22
33import java
44
5- /** Holds if `m` is the main method of a Java class with the signature `public static void main(String[] args)`. */
6- predicate isMainMethod ( Method m ) {
7- m .hasName ( "main" ) and
8- m .isStatic ( ) and
9- m .getReturnType ( ) instanceof VoidType and
10- m .isPublic ( ) and
11- m .getNumberOfParameters ( ) = 1 and
12- m .getParameter ( 0 ) .getType ( ) instanceof Array
13- }
14-
155/**
166 * Holds if `m` is a test method indicated by:
177 * a) in a test directory such as `src/test/java`
Original file line number Diff line number Diff line change 99
1010import java
1111import semmle.code.java.frameworks.Servlets
12- import MainLib
12+ import TestLib
1313
1414/** The java type `javax.servlet.Filter`. */
1515class ServletFilterClass extends Class {
@@ -48,7 +48,7 @@ class WebComponentMainMethod extends Method {
4848 .getASupertype + ( )
4949 .hasQualifiedName ( "org.springframework.webflow.execution" , "Action" ) // Spring actions
5050 ) and
51- isMainMethod ( this ) and
51+ this instanceof MainMethod and
5252 not isTestMethod ( this )
5353 }
5454}
You can’t perform that action at this time.
0 commit comments