Skip to content

Commit 659e2ff

Browse files
committed
JS: Tweak evaluation of route handler params
1 parent b9995b7 commit 659e2ff

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

javascript/ql/src/semmle/javascript/frameworks/ConnectExpressShared.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ module ConnectExpressShared {
8181
*
8282
* `kind` is one of: "error", "request", "response", "next".
8383
*/
84+
pragma[inline]
8485
Parameter getRouteParameterHandlerParameter(Function routeHandler, string kind) {
8586
result =
8687
getRouteHandlerParameter(routeHandler, RouteHandlerSignature::requestResponseNextParameter(),
@@ -92,6 +93,7 @@ module ConnectExpressShared {
9293
*
9394
* `kind` is one of: "error", "request", "response", "next".
9495
*/
96+
pragma[inline]
9597
Parameter getRouteHandlerParameter(Function routeHandler, string kind) {
9698
if routeHandler.getNumParameter() = 4
9799
then

javascript/ql/src/semmle/javascript/frameworks/Firebase.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,14 @@ module Firebase {
219219
*/
220220
private class RouteHandler extends Express::RouteHandler, HTTP::Servers::StandardRouteHandler,
221221
DataFlow::ValueNode {
222+
override Function astNode;
223+
222224
RouteHandler() { this = any(RouteSetup setup).getARouteHandler() }
223225

224226
override SimpleParameter getRouteHandlerParameter(string kind) {
225-
kind = "request" and result = this.(DataFlow::FunctionNode).getParameter(0).getParameter()
227+
kind = "request" and result = astNode.getParameter(0)
226228
or
227-
kind = "response" and result = this.(DataFlow::FunctionNode).getParameter(1).getParameter()
229+
kind = "response" and result = astNode.getParameter(1)
228230
}
229231
}
230232
}

javascript/ql/src/semmle/javascript/frameworks/HTTP.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ module HTTP {
370370
/**
371371
* Gets a route handler that is defined by this setup.
372372
*/
373+
pragma[nomagic]
373374
abstract DataFlow::SourceNode getARouteHandler();
374375

375376
/**

0 commit comments

Comments
 (0)