@@ -12,7 +12,7 @@ module Spife {
12
12
/**
13
13
* A call to a Spife method that sets up a route.
14
14
*/
15
- private class RouteSetup extends API :: CallNode , Http:: Servers:: StandardRouteSetup {
15
+ private class RouteSetup extends DataFlow :: CallNode , Http:: Servers:: StandardRouteSetup {
16
16
TaggedTemplateExpr template ;
17
17
18
18
RouteSetup ( ) {
@@ -44,20 +44,22 @@ module Spife {
44
44
)
45
45
}
46
46
47
- API:: Node getHandlerByName ( string name ) { result = this .getParameter ( 0 ) .getMember ( name ) }
47
+ DataFlow:: Node getHandlerByName ( string name ) {
48
+ result = DataFlow:: parameterNode ( this .getACallee ( ) .getParameter ( 0 ) ) .getAPropertyRead ( name )
49
+ }
48
50
49
- API :: Node getHandlerByRoute ( string method , string path ) {
51
+ DataFlow :: Node getHandlerByRoute ( string method , string path ) {
50
52
exists ( string handlerName |
51
53
this .hasLine ( method , path , handlerName ) and
52
54
result = this .getHandlerByName ( handlerName )
53
55
)
54
56
}
55
57
56
58
override DataFlow:: SourceNode getARouteHandler ( ) {
57
- result = this .getHandlerByRoute ( _, _) .getAValueReachingSink ( ) .( DataFlow:: FunctionNode )
59
+ result = this .getHandlerByRoute ( _, _) .getALocalSource ( ) .( DataFlow:: FunctionNode )
58
60
or
59
61
exists ( DataFlow:: MethodCallNode validation |
60
- validation = this .getHandlerByRoute ( _, _) .getAValueReachingSink ( ) and
62
+ validation = this .getHandlerByRoute ( _, _) .getALocalSource ( ) and
61
63
result = validation .getArgument ( 1 ) .getAFunctionValue ( )
62
64
)
63
65
}
@@ -90,7 +92,7 @@ module Spife {
90
92
/**
91
93
* A function that looks like a Spife route handler.
92
94
*
93
- * For example, this could be the function `function(req, res, next ){...}`.
95
+ * For example, this could be the function `function(request, context ){...}`.
94
96
*/
95
97
class RouteHandlerCandidate extends Http:: RouteHandlerCandidate {
96
98
RouteHandlerCandidate ( ) {
@@ -139,22 +141,30 @@ module Spife {
139
141
string kind ;
140
142
141
143
RequestInputAccess ( ) {
144
+ // req.body
142
145
this = rh .getARequestSource ( ) .ref ( ) .getAPropertyRead ( "body" ) and
143
146
kind = "body"
144
147
or
148
+ // req.query['foo']
145
149
this = rh .getARequestSource ( ) .ref ( ) .getAPropertyRead ( "query" ) .getAPropertyRead ( ) and
146
150
kind = "parameter"
147
151
or
152
+ // req.raw
148
153
this = rh .getARequestSource ( ) .ref ( ) .getAPropertyRead ( "raw" ) and
149
154
kind = "raw"
150
155
or
156
+ // req.url
157
+ // req.urlObject
151
158
this = rh .getARequestSource ( ) .ref ( ) .getAPropertyRead ( [ "url" , "urlObject" ] ) and
152
159
kind = "url"
153
160
or
161
+ // req.cookie('foo')
162
+ // req.cookies()
154
163
this = rh .getARequestSource ( ) .ref ( ) .getAMethodCall ( ) and
155
164
this .( DataFlow:: MethodCallNode ) .getMethodName ( ) = [ "cookie" , "cookies" ] and
156
165
kind = "cookie"
157
166
or
167
+ // req.validatedBody.get('foo')
158
168
exists ( DataFlow:: PropRead validated , DataFlow:: MethodCallNode get |
159
169
rh .getARequestSource ( ) .ref ( ) .getAPropertyRead ( ) = validated and
160
170
validated .getPropertyName ( ) .matches ( "validated%" ) and
0 commit comments