11import java
22import semmle.code.java.dataflow.DataFlow
33
4- /**
5- * Methods that trigger evaluation of an expression.
6- */
7- class ExpressionEvaluationMethod extends Method {
8- ExpressionEvaluationMethod ( ) {
9- getDeclaringType ( ) instanceof Expression and
10- (
11- hasName ( "getValue" ) or
12- hasName ( "getValueTypeDescriptor" ) or
13- hasName ( "getValueType" ) or
14- hasName ( "setValue" )
15- )
16- }
17- }
18-
194/**
205 * `WebRequest` interface is a source of tainted data.
216 */
@@ -37,100 +22,6 @@ class WebRequestSource extends DataFlow::Node {
3722 }
3823}
3924
40- /**
41- * Holds if `node1` to `node2` is a dataflow step that converts `PropertyValues`
42- * to an array of `PropertyValue`, i.e. `tainted.getPropertyValues()`.
43- */
44- predicate getPropertyValuesStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
45- exists ( MethodAccess ma , Method m | m = ma .getMethod ( ) |
46- node1 .asExpr ( ) = ma .getQualifier ( ) and
47- node2 .asExpr ( ) = ma and
48- m .getDeclaringType ( ) instanceof PropertyValues and
49- m .hasName ( "getPropertyValues" )
50- )
51- }
52-
53- /**
54- * Holds if `node1` to `node2` is a dataflow step that constructs `MutablePropertyValues`,
55- * i.e. `new MutablePropertyValues(tainted)`.
56- */
57- predicate createMutablePropertyValuesStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
58- exists ( ConstructorCall cc | cc .getConstructedType ( ) instanceof MutablePropertyValues |
59- node1 .asExpr ( ) = cc .getAnArgument ( ) and
60- node2 .asExpr ( ) = cc
61- )
62- }
63-
64- /**
65- * Holds if `node1` to `node2` is a dataflow step that returns a name of `PropertyValue`,
66- * i.e. `tainted.getName()`.
67- */
68- predicate getPropertyNameStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
69- exists ( MethodAccess ma , Method m | m = ma .getMethod ( ) |
70- node1 .asExpr ( ) = ma .getQualifier ( ) and
71- node2 .asExpr ( ) = ma and
72- m .getDeclaringType ( ) instanceof PropertyValue and
73- m .hasName ( "getName" )
74- )
75- }
76-
77- /**
78- * Holds if `node1` to `node2` is a dataflow step that converts `MutablePropertyValues`
79- * to a list of `PropertyValue`, i.e. `tainted.getPropertyValueList()`.
80- */
81- predicate getPropertyValueListStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
82- exists ( MethodAccess ma , Method m | m = ma .getMethod ( ) |
83- node1 .asExpr ( ) = ma .getQualifier ( ) and
84- node2 .asExpr ( ) = ma and
85- m .getDeclaringType ( ) instanceof MutablePropertyValues and
86- m .hasName ( "getPropertyValueList" )
87- )
88- }
89-
90- /**
91- * Holds if `node1` to `node2` is one of the dataflow steps that propagate
92- * tainted data via Spring properties.
93- */
94- predicate springPropertiesStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
95- createMutablePropertyValuesStep ( node1 , node2 ) or
96- getPropertyNameStep ( node1 , node2 ) or
97- getPropertyValuesStep ( node1 , node2 ) or
98- getPropertyValueListStep ( node1 , node2 )
99- }
100-
101- class PropertyValue extends RefType {
102- PropertyValue ( ) { hasQualifiedName ( "org.springframework.beans" , "PropertyValue" ) }
103- }
104-
105- class PropertyValues extends RefType {
106- PropertyValues ( ) { hasQualifiedName ( "org.springframework.beans" , "PropertyValues" ) }
107- }
108-
109- class MutablePropertyValues extends RefType {
110- MutablePropertyValues ( ) { hasQualifiedName ( "org.springframework.beans" , "MutablePropertyValues" ) }
111- }
112-
113- class SimpleEvaluationContext extends RefType {
114- SimpleEvaluationContext ( ) {
115- hasQualifiedName ( "org.springframework.expression.spel.support" , "SimpleEvaluationContext" )
116- }
117- }
118-
119- class SimpleEvaluationContextBuilder extends RefType {
120- SimpleEvaluationContextBuilder ( ) {
121- hasQualifiedName ( "org.springframework.expression.spel.support" ,
122- "SimpleEvaluationContext$Builder" )
123- }
124- }
125-
12625class WebRequest extends RefType {
12726 WebRequest ( ) { hasQualifiedName ( "org.springframework.web.context.request" , "WebRequest" ) }
12827}
129-
130- class Expression extends RefType {
131- Expression ( ) { hasQualifiedName ( "org.springframework.expression" , "Expression" ) }
132- }
133-
134- class ExpressionParser extends RefType {
135- ExpressionParser ( ) { hasQualifiedName ( "org.springframework.expression" , "ExpressionParser" ) }
136- }
0 commit comments