@@ -51,23 +51,22 @@ class SpringUrlRedirectSink extends DataFlow::Node {
51
51
SpringUrlRedirectSink ( ) {
52
52
exists ( RedirectBuilderExpr rbe |
53
53
rbe .getRightOperand ( ) = this .asExpr ( ) and
54
- exists ( RedirectBuilderFlowConfig rbfc | rbfc . hasFlow ( exprNode ( rbe ) , _ ) )
54
+ any ( SpringRequestMappingMethod sqmm ) . polyCalls * ( this . getEnclosingCallable ( ) )
55
55
)
56
56
or
57
57
exists ( MethodAccess ma , RedirectAppendCall rac |
58
58
DataFlow2:: localExprFlow ( rac .getQualifier ( ) , ma .getQualifier ( ) ) and
59
59
ma .getMethod ( ) .hasName ( "append" ) and
60
60
ma .getArgument ( 0 ) = this .asExpr ( ) and
61
- exists ( RedirectBuilderFlowConfig rbfc | rbfc . hasFlow ( exprNode ( ma . getQualifier ( ) ) , _ ) )
61
+ any ( SpringRequestMappingMethod sqmm ) . polyCalls * ( this . getEnclosingCallable ( ) )
62
62
)
63
63
or
64
64
exists ( MethodAccess ma |
65
65
ma .getMethod ( ) .hasName ( "setUrl" ) and
66
66
ma .getMethod ( )
67
67
.getDeclaringType ( )
68
68
.hasQualifiedName ( "org.springframework.web.servlet.view" , "AbstractUrlBasedView" ) and
69
- ma .getArgument ( 0 ) = this .asExpr ( ) and
70
- exists ( RedirectViewFlowConfig rvfc | rvfc .hasFlowToExpr ( ma .getQualifier ( ) ) )
69
+ ma .getArgument ( 0 ) = this .asExpr ( )
71
70
)
72
71
or
73
72
exists ( ClassInstanceExpr cie |
@@ -84,57 +83,3 @@ class SpringUrlRedirectSink extends DataFlow::Node {
84
83
)
85
84
}
86
85
}
87
-
88
- /** A data flow configuration tracing flow from redirect builder expression to spring controller method return expression. */
89
- private class RedirectBuilderFlowConfig extends DataFlow2:: Configuration {
90
- RedirectBuilderFlowConfig ( ) { this = "RedirectBuilderFlowConfig" }
91
-
92
- override predicate isSource ( DataFlow:: Node src ) {
93
- exists ( RedirectBuilderExpr rbe | rbe = src .asExpr ( ) )
94
- or
95
- exists ( MethodAccess ma , RedirectAppendCall rac |
96
- DataFlow2:: localExprFlow ( rac .getQualifier ( ) , ma .getQualifier ( ) ) and
97
- ma .getMethod ( ) .hasName ( "append" ) and
98
- ma .getQualifier ( ) = src .asExpr ( )
99
- )
100
- }
101
-
102
- override predicate isSink ( DataFlow:: Node sink ) {
103
- exists ( ReturnStmt rs , SpringRequestMappingMethod sqmm |
104
- rs .getResult ( ) = sink .asExpr ( ) and
105
- sqmm .getBody ( ) .getAStmt ( ) = rs
106
- )
107
- }
108
-
109
- override predicate isAdditionalFlowStep ( Node prod , Node succ ) {
110
- exists ( MethodAccess ma |
111
- ma .getMethod ( ) .hasName ( "toString" ) and
112
- ma .getMethod ( ) .getDeclaringType ( ) instanceof StringBuildingType and
113
- ma .getQualifier ( ) = prod .asExpr ( ) and
114
- ma = succ .asExpr ( )
115
- )
116
- }
117
- }
118
-
119
- /** A data flow configuration tracing flow from RedirectView object to calling setUrl method. */
120
- private class RedirectViewFlowConfig extends DataFlow2:: Configuration {
121
- RedirectViewFlowConfig ( ) { this = "RedirectViewFlowConfig" }
122
-
123
- override predicate isSource ( DataFlow:: Node src ) {
124
- exists ( ClassInstanceExpr cie |
125
- cie .getConstructedType ( )
126
- .hasQualifiedName ( "org.springframework.web.servlet.view" , "RedirectView" ) and
127
- cie = src .asExpr ( )
128
- )
129
- }
130
-
131
- override predicate isSink ( DataFlow:: Node sink ) {
132
- exists ( MethodAccess ma |
133
- ma .getMethod ( ) .hasName ( "setUrl" ) and
134
- ma .getMethod ( )
135
- .getDeclaringType ( )
136
- .hasQualifiedName ( "org.springframework.web.servlet.view" , "AbstractUrlBasedView" ) and
137
- ma .getQualifier ( ) = sink .asExpr ( )
138
- )
139
- }
140
- }
0 commit comments