@@ -51,23 +51,22 @@ class SpringUrlRedirectSink extends DataFlow::Node {
5151 SpringUrlRedirectSink ( ) {
5252 exists ( RedirectBuilderExpr rbe |
5353 rbe .getRightOperand ( ) = this .asExpr ( ) and
54- exists ( RedirectBuilderFlowConfig rbfc | rbfc . hasFlow ( exprNode ( rbe ) , _ ) )
54+ any ( SpringRequestMappingMethod sqmm ) . polyCalls * ( this . getEnclosingCallable ( ) )
5555 )
5656 or
5757 exists ( MethodAccess ma , RedirectAppendCall rac |
5858 DataFlow2:: localExprFlow ( rac .getQualifier ( ) , ma .getQualifier ( ) ) and
5959 ma .getMethod ( ) .hasName ( "append" ) and
6060 ma .getArgument ( 0 ) = this .asExpr ( ) and
61- exists ( RedirectBuilderFlowConfig rbfc | rbfc . hasFlow ( exprNode ( ma . getQualifier ( ) ) , _ ) )
61+ any ( SpringRequestMappingMethod sqmm ) . polyCalls * ( this . getEnclosingCallable ( ) )
6262 )
6363 or
6464 exists ( MethodAccess ma |
6565 ma .getMethod ( ) .hasName ( "setUrl" ) and
6666 ma .getMethod ( )
6767 .getDeclaringType ( )
6868 .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 ( )
7170 )
7271 or
7372 exists ( ClassInstanceExpr cie |
@@ -84,57 +83,3 @@ class SpringUrlRedirectSink extends DataFlow::Node {
8483 )
8584 }
8685}
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