Skip to content

Commit dc79901

Browse files
committed
Add query for Struts and Spring actions
1 parent 3d9ac0d commit dc79901

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

java/ql/src/experimental/Security/CWE/CWE-489/ServletMain.ql

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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

1010
import java
1111
import semmle.code.java.frameworks.Servlets
1212

13-
/** The java type `javax.servlet.Filter` */
13+
/** The java type `javax.servlet.Filter`. */
1414
class 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

Comments
 (0)