Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4243504

Browse files
committed
improve join-order for HTTP::isDecoratedCall
1 parent 724baaf commit 4243504

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • javascript/ql/src/semmle/javascript/frameworks

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,22 @@ module HTTP {
240240
*/
241241
private predicate isDecoratedCall(DataFlow::CallNode call, DataFlow::FunctionNode decoratee) {
242242
// indirect route-handler `result` is given to function `outer`, which returns function `inner` which calls the function `pred`.
243-
exists(int i, Function outer, Function inner |
243+
exists(int i, DataFlow::FunctionNode outer, HTTP::RouteHandlerCandidate inner |
244244
decoratee = call.getArgument(i).getALocalSource() and
245-
outer = call.getACallee() and
246-
inner = outer.getAReturnedExpr() and
247-
isAForwardingRouteHandlerCall(DataFlow::parameterNode(outer.getParameter(i)), inner.flow())
245+
outer.getFunction() = call.getACallee() and
246+
outer = returnsARouteHandler(inner) and
247+
isAForwardingRouteHandlerCall(outer.getParameter(i), inner)
248248
)
249249
}
250250

251+
/**
252+
* Gets a function that returns the route-handler-candidate `routeHandler`.
253+
*/
254+
pragma[noinline]
255+
private DataFlow::FunctionNode returnsARouteHandler(HTTP::RouteHandlerCandidate routeHandler) {
256+
routeHandler = result.getAReturn().getALocalSource()
257+
}
258+
251259
/**
252260
* Holds if `f` looks like a route-handler and a call to `callee` inside `f` forwards all of the parameters from `f` to that call.
253261
*/

0 commit comments

Comments
 (0)