@@ -24,7 +24,8 @@ module Connect {
24
24
* but support for other kinds of route handlers can be added by implementing
25
25
* additional subclasses of this class.
26
26
*/
27
- abstract class RouteHandler extends HTTP:: Servers:: StandardRouteHandler , DataFlow:: ValueNode {
27
+ abstract class RouteHandler extends HTTP:: Servers:: StandardRouteHandler , NodeJSLib:: RouteHandler ,
28
+ DataFlow:: ValueNode {
28
29
/**
29
30
* Gets the parameter of kind `kind` of this route handler.
30
31
*
@@ -35,12 +36,12 @@ module Connect {
35
36
/**
36
37
* Gets the parameter of the route handler that contains the request object.
37
38
*/
38
- Parameter getRequestParameter ( ) { result = getRouteHandlerParameter ( "request" ) }
39
+ override Parameter getRequestParameter ( ) { result = getRouteHandlerParameter ( "request" ) }
39
40
40
41
/**
41
42
* Gets the parameter of the route handler that contains the response object.
42
43
*/
43
- Parameter getResponseParameter ( ) { result = getRouteHandlerParameter ( "response" ) }
44
+ override Parameter getResponseParameter ( ) { result = getRouteHandlerParameter ( "response" ) }
44
45
}
45
46
46
47
/**
@@ -56,50 +57,6 @@ module Connect {
56
57
}
57
58
}
58
59
59
- /**
60
- * A Connect response source, that is, the response parameter of a
61
- * route handler.
62
- */
63
- private class ResponseSource extends HTTP:: Servers:: ResponseSource {
64
- RouteHandler rh ;
65
-
66
- ResponseSource ( ) { this = DataFlow:: parameterNode ( rh .getResponseParameter ( ) ) }
67
-
68
- /**
69
- * Gets the route handler that provides this response.
70
- */
71
- override RouteHandler getRouteHandler ( ) { result = rh }
72
- }
73
-
74
- /**
75
- * A Connect request source, that is, the request parameter of a
76
- * route handler.
77
- */
78
- private class RequestSource extends HTTP:: Servers:: RequestSource {
79
- RouteHandler rh ;
80
-
81
- RequestSource ( ) { this = DataFlow:: parameterNode ( rh .getRequestParameter ( ) ) }
82
-
83
- /**
84
- * Gets the route handler that handles this request.
85
- */
86
- override RouteHandler getRouteHandler ( ) { result = rh }
87
- }
88
-
89
- /**
90
- * A Node.js HTTP response provided by Connect.
91
- */
92
- class ResponseExpr extends NodeJSLib:: ResponseExpr {
93
- ResponseExpr ( ) { src instanceof ResponseSource }
94
- }
95
-
96
- /**
97
- * A Node.js HTTP request provided by Connect.
98
- */
99
- class RequestExpr extends NodeJSLib:: RequestExpr {
100
- RequestExpr ( ) { src instanceof RequestSource }
101
- }
102
-
103
60
/**
104
61
* A call to a Connect method that sets up a route.
105
62
*/
@@ -156,10 +113,11 @@ module Connect {
156
113
* An access to a user-controlled Connect request input.
157
114
*/
158
115
private class RequestInputAccess extends HTTP:: RequestInputAccess {
159
- RequestExpr request ;
116
+ NodeJSLib :: RequestExpr request ;
160
117
string kind ;
161
118
162
119
RequestInputAccess ( ) {
120
+ request .getRouteHandler ( ) instanceof StandardRouteHandler and
163
121
exists ( PropAccess cookies |
164
122
// `req.cookies.get(<name>)`
165
123
kind = "cookie" and
@@ -172,33 +130,4 @@ module Connect {
172
130
173
131
override string getKind ( ) { result = kind }
174
132
}
175
-
176
- /**
177
- * A function that flows to a route setup.
178
- */
179
- private class TrackedRouteHandlerCandidateWithSetup extends RouteHandler ,
180
- HTTP:: Servers:: StandardRouteHandler , DataFlow:: FunctionNode {
181
- TrackedRouteHandlerCandidateWithSetup ( ) { this = any ( RouteSetup s ) .getARouteHandler ( ) }
182
-
183
- override Parameter getRouteHandlerParameter ( string kind ) {
184
- result = getRouteHandlerParameter ( astNode , kind )
185
- }
186
- }
187
-
188
- /**
189
- * A call that looks like a route setup on a Connect server.
190
- *
191
- * For example, this could be the call `router.use(handler)` where
192
- * it is unknown if `router` is a Connect router.
193
- */
194
- class RouteSetupCandidate extends HTTP:: RouteSetupCandidate , DataFlow:: MethodCallNode {
195
- DataFlow:: ValueNode routeHandlerArg ;
196
-
197
- RouteSetupCandidate ( ) {
198
- getMethodName ( ) = "use" and
199
- routeHandlerArg = getAnArgument ( )
200
- }
201
-
202
- override DataFlow:: ValueNode getARouteHandlerArg ( ) { result = routeHandlerArg }
203
- }
204
133
}
0 commit comments