11/**
2- * @name Main Method in Servlet
2+ * @name Main Method in Java EE Web Components
33 * @description Jave EE web applications with a main method.
44 * @kind problem
5- * @id java/main-method-in-servlet
5+ * @id java/main-method-in-web-components
66 * @tags security
77 * external/cwe-489
88 */
99
1010import java
1111import semmle.code.java.frameworks.Servlets
1212
13- /** The java type `javax.servlet.Filter` */
13+ /** The java type `javax.servlet.Filter`. */
1414class ServletFilterClass extends Class {
1515 ServletFilterClass ( ) { this .getASupertype * ( ) .hasQualifiedName ( "javax.servlet" , "Filter" ) }
1616}
@@ -33,7 +33,19 @@ class ServletMainMethod extends Method {
3333 (
3434 this .getDeclaringType ( ) instanceof ServletClass or
3535 this .getDeclaringType ( ) instanceof ServletFilterClass or
36- this .getDeclaringType ( ) instanceof ServletListenerClass
36+ this .getDeclaringType ( ) instanceof ServletListenerClass or
37+ this .getDeclaringType ( )
38+ .getASupertype * ( )
39+ .hasQualifiedName ( "org.apache.struts.action" , "Action" ) or // Struts actions
40+ this .getDeclaringType ( )
41+ .getASupertype + ( )
42+ .hasQualifiedName ( "com.opensymphony.xwork2" , "ActionSupport" ) or // Struts 2 actions
43+ this .getDeclaringType ( )
44+ .getASupertype + ( )
45+ .hasQualifiedName ( "org.springframework.web.struts" , "ActionSupport" ) or // Spring/Struts 2 actions
46+ this .getDeclaringType ( )
47+ .getASupertype + ( )
48+ .hasQualifiedName ( "org.springframework.webflow.execution" , "Action" ) // Spring actions
3749 ) and
3850 this .hasName ( "main" ) and
3951 this .isStatic ( ) and
0 commit comments