File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
java/ql/src/semmle/code/java Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import semmle.code.java.frameworks.JaxWS
1818import semmle.code.java.frameworks.android.Intent
1919import semmle.code.java.frameworks.SpringWeb
2020import semmle.code.java.frameworks.Guice
21+ import semmle.code.java.frameworks.struts.StrutsActions
2122
2223/** Class for `tainted` user input. */
2324abstract class UserInput extends DataFlow:: Node { }
@@ -75,6 +76,8 @@ class RemoteUserInput extends UserInput {
7576 a = this .asParameter ( ) .getAnAnnotation ( ) or
7677 a = this .asExpr ( ) .( FieldRead ) .getField ( ) .getAnAnnotation ( )
7778 )
79+ or
80+ exists ( Struts2ActionSupportClass c | c .getASetterMethod ( ) .getField ( ) = this .asExpr ( ) .( FieldRead ) .getField ( ) )
7881 }
7982
8083 /**
Original file line number Diff line number Diff line change @@ -124,3 +124,24 @@ class Struts2PrepareMethod extends Method {
124124 exists ( Struts2ActionClass actionClass | this = actionClass .getPrepareMethod ( ) )
125125 }
126126}
127+
128+ /**
129+ * A subclass of the Struts 2 `ActionSupport` class.
130+ */
131+ class Struts2ActionSupportClass extends Class {
132+ Struts2ActionSupportClass ( ) {
133+ this .getASupertype + ( ) .hasQualifiedName ( "com.opensymphony.xwork2" , "ActionSupport" )
134+ }
135+
136+ /**
137+ * Gets a setter method declared on a subclass of `ActionSupport`.
138+ */
139+ SetterMethod getASetterMethod ( ) {
140+ result .getDeclaringType ( ) = this and
141+ result .isPublic ( ) and
142+ exists ( string name | result .getField ( ) .getName ( ) .toLowerCase ( ) = name |
143+ result .getName ( ) .toLowerCase ( ) .substring ( 3 , result .getName ( ) .length ( ) ) = name and
144+ result .getName ( ) .matches ( "set%" )
145+ )
146+ }
147+ }
You can’t perform that action at this time.
0 commit comments