@@ -26,20 +26,20 @@ module Fastify {
2626 /**
2727 * A function used as a Fastify route handler.
2828 *
29- * By default, only handlers installed by an Fastify route setup are recognized,
29+ * By default, only handlers installed by a Fastify route setup are recognized,
3030 * but support for other kinds of route handlers can be added by implementing
3131 * additional subclasses of this class.
3232 */
3333 abstract class RouteHandler extends HTTP:: Servers:: StandardRouteHandler , DataFlow:: ValueNode {
3434 /**
3535 * Gets the parameter of the route handler that contains the request object.
3636 */
37- abstract SimpleParameter getRequestParameter ( ) ;
37+ abstract DataFlow :: ParameterNode getRequestParameter ( ) ;
3838
3939 /**
4040 * Gets the parameter of the route handler that contains the reply object.
4141 */
42- abstract SimpleParameter getReplyParameter ( ) ;
42+ abstract DataFlow :: ParameterNode getReplyParameter ( ) ;
4343 }
4444
4545 /**
@@ -48,9 +48,9 @@ module Fastify {
4848 class StandardRouteHandler extends RouteHandler , DataFlow:: FunctionNode {
4949 StandardRouteHandler ( ) { this = any ( RouteSetup setup ) .getARouteHandler ( ) }
5050
51- override SimpleParameter getRequestParameter ( ) { result = this .getParameter ( 0 ) . getParameter ( ) }
51+ override DataFlow :: ParameterNode getRequestParameter ( ) { result = this .getParameter ( 0 ) }
5252
53- override SimpleParameter getReplyParameter ( ) { result = this .getParameter ( 1 ) . getParameter ( ) }
53+ override DataFlow :: ParameterNode getReplyParameter ( ) { result = this .getParameter ( 1 ) }
5454 }
5555
5656 /**
@@ -60,7 +60,7 @@ module Fastify {
6060 private class ReplySource extends HTTP:: Servers:: ResponseSource {
6161 RouteHandler rh ;
6262
63- ReplySource ( ) { this = DataFlow :: parameterNode ( rh .getReplyParameter ( ) ) }
63+ ReplySource ( ) { this = rh .getReplyParameter ( ) }
6464
6565 /**
6666 * Gets the route handler that provides this response.
@@ -75,7 +75,7 @@ module Fastify {
7575 private class RequestSource extends HTTP:: Servers:: RequestSource {
7676 RouteHandler rh ;
7777
78- RequestSource ( ) { this = DataFlow :: parameterNode ( rh .getRequestParameter ( ) ) }
78+ RequestSource ( ) { this = rh .getRequestParameter ( ) }
7979
8080 /**
8181 * Gets the route handler that handles this request.
@@ -132,7 +132,9 @@ module Fastify {
132132 string kind ;
133133
134134 RequestInputAccess ( ) {
135- exists ( string name | this .( DataFlow:: PropRead ) .accesses ( rh .getARequestExpr ( ) .flow ( ) , name ) |
135+ exists ( DataFlow:: PropRead read , string name |
136+ this = read and read = rh .getARequestSource ( ) .ref ( ) .getAPropertyRead ( name )
137+ |
136138 kind = "parameter" and
137139 name = [ "params" , "query" ]
138140 or
@@ -153,10 +155,7 @@ module Fastify {
153155 RouteHandler rh ;
154156
155157 RequestHeaderAccess ( ) {
156- exists ( DataFlow:: PropRead headers |
157- headers .accesses ( rh .getARequestExpr ( ) .flow ( ) , "headers" ) and
158- this = headers .getAPropertyRead ( )
159- )
158+ this = rh .getARequestSource ( ) .ref ( ) .getAPropertyRead ( "headers" ) .getAPropertyRead ( )
160159 }
161160
162161 override string getAHeaderName ( ) {
@@ -175,16 +174,9 @@ module Fastify {
175174 RouteHandler rh ;
176175
177176 ResponseSendArgument ( ) {
178- exists ( MethodCallExpr mce |
179- mce .calls ( rh .getAResponseExpr ( ) , "send" ) and
180- this = mce .getArgument ( 0 )
181- )
177+ this = rh .getAResponseSource ( ) .ref ( ) .getAMethodCall ( "send" ) .getArgument ( 0 ) .asExpr ( )
182178 or
183- exists ( Function f |
184- f = rh .( DataFlow:: FunctionNode ) .getFunction ( ) and
185- f .isAsync ( ) and
186- f .getAReturnedExpr ( ) = this
187- )
179+ this = rh .( DataFlow:: FunctionNode ) .getAReturn ( ) .asExpr ( )
188180 }
189181
190182 override RouteHandler getRouteHandler ( ) { result = rh }
@@ -196,7 +188,9 @@ module Fastify {
196188 private class RedirectInvocation extends HTTP:: RedirectInvocation , MethodCallExpr {
197189 RouteHandler rh ;
198190
199- RedirectInvocation ( ) { this .calls ( rh .getAResponseExpr ( ) , "redirect" ) }
191+ RedirectInvocation ( ) {
192+ this = rh .getAResponseSource ( ) .ref ( ) .getAMethodCall ( "redirect" ) .asExpr ( )
193+ }
200194
201195 override Expr getUrlArgument ( ) { result = this .getLastArgument ( ) }
202196
@@ -206,12 +200,13 @@ module Fastify {
206200 /**
207201 * An invocation that sets a single header of the HTTP response.
208202 */
209- private class SetOneHeader extends HTTP:: Servers:: StandardHeaderDefinition {
203+ private class SetOneHeader extends HTTP:: Servers:: StandardHeaderDefinition ,
204+ DataFlow:: MethodCallNode {
210205 RouteHandler rh ;
211206
212207 SetOneHeader ( ) {
213- astNode . calls ( rh . getAResponseExpr ( ) , "header" ) and
214- astNode .getNumArgument ( ) = 2
208+ this = rh . getAResponseSource ( ) . ref ( ) . getAMethodCall ( "header" ) and
209+ this .getNumArgument ( ) = 2
215210 }
216211
217212 override RouteHandler getRouteHandler ( ) { result = rh }
@@ -224,7 +219,7 @@ module Fastify {
224219 RouteHandler rh ;
225220
226221 SetMultipleHeaders ( ) {
227- this . calls ( rh .getAResponseExpr ( ) .flow ( ) , "headers" ) and
222+ this = rh .getAResponseSource ( ) .ref ( ) . getAMethodCall ( "headers" ) and
228223 this .getNumArgument ( ) = 1
229224 }
230225
0 commit comments