diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Express.qll b/javascript/ql/lib/semmle/javascript/frameworks/Express.qll index 26e4bc20002..754d528159e 100644 --- a/javascript/ql/lib/semmle/javascript/frameworks/Express.qll +++ b/javascript/ql/lib/semmle/javascript/frameworks/Express.qll @@ -56,13 +56,11 @@ module Express { } /** + * DEPRECATED: Use `isRouter()` instead. * An expression that refers to a route. */ - class RouteExpr extends DataFlow::MethodCallNode { - RouteExpr() { isRouter(this) } - - /** Gets the router from which this route was created, if it is known. */ - RouterDefinition getRouter() { isRouter(this, result) } + deprecated class RouteExpr extends MethodCallExpr { + RouteExpr() { isRouter(this.flow()) } } /** diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Hapi.qll b/javascript/ql/lib/semmle/javascript/frameworks/Hapi.qll index 86053873549..b66ab8d484f 100644 --- a/javascript/ql/lib/semmle/javascript/frameworks/Hapi.qll +++ b/javascript/ql/lib/semmle/javascript/frameworks/Hapi.qll @@ -19,29 +19,24 @@ module Hapi { /** * A Hapi route handler. */ - class RouteHandler extends HTTP::Servers::StandardRouteHandler, DataFlow::ValueNode { - Function function; - - RouteHandler() { - function = astNode and - exists(RouteSetup setup | this = setup.getARouteHandler()) - } + class RouteHandler extends HTTP::Servers::StandardRouteHandler, DataFlow::FunctionNode { + RouteHandler() { exists(RouteSetup setup | this = setup.getARouteHandler()) } /** * Gets the parameter of the route handler that contains the request object. */ - Parameter getRequestParameter() { result = function.getParameter(0) } + DataFlow::ParameterNode getRequestParameter() { result = getParameter(0) } /** * Gets the parameter of the route handler that contains the "request toolkit", * usually named `h`. */ - Parameter getRequestToolkitParameter() { result = function.getParameter(1) } + DataFlow::ParameterNode getRequestToolkitParameter() { result = getParameter(1) } /** * Gets a source node referring to the request toolkit parameter, usually named `h`. */ - DataFlow::SourceNode getRequestToolkit() { result = getRequestToolkitParameter().flow() } + DataFlow::SourceNode getRequestToolkit() { result = getRequestToolkitParameter() } } /** @@ -66,7 +61,7 @@ module Hapi { private class RequestSource extends HTTP::Servers::RequestSource { RouteHandler rh; - RequestSource() { this = DataFlow::parameterNode(rh.getRequestParameter()) } + RequestSource() { this = rh.getRequestParameter() } /** * Gets the route handler that handles this request. diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Koa.qll b/javascript/ql/lib/semmle/javascript/frameworks/Koa.qll index 801ed7fc9e8..49104de9263 100644 --- a/javascript/ql/lib/semmle/javascript/frameworks/Koa.qll +++ b/javascript/ql/lib/semmle/javascript/frameworks/Koa.qll @@ -49,7 +49,7 @@ module Koa { * Gets an expression that contains the "context" object of * a route handler invocation. */ - deprecated Expr getAContextExpr() { result.(ContextExpr).getRouteHandler() = this } + deprecated Expr getAContextExpr() { result = this.getAContextNode().asExpr() } /** * Gets an expression that contains the "context" object of @@ -67,7 +67,7 @@ module Koa { * object of a route handler invocation. */ deprecated Expr getAResponseOrContextExpr() { - result = this.getAResponseNode().asExpr() or result = this.getAContextExpr() + result = this.getAResponseOrContextNode().asExpr() } /** @@ -83,9 +83,7 @@ module Koa { * Gets an expression that contains the context or request * object of a route handler invocation. */ - deprecated Expr getARequestOrContextExpr() { - result = this.getARequestNode().asExpr() or result = this.getAContextExpr() - } + deprecated Expr getARequestOrContextExpr() { result = this.getARequestOrContextNode().asExpr() } /** * Gets an expression that contains the context or request @@ -447,7 +445,7 @@ module Koa { override DataFlow::SourceNode getARouteHandler() { // `StandardRouteHandler` uses this predicate in it's charpred, so making this predicate return a `RouteHandler` would give an empty recursion. - result.flowsToExpr(this.getArgument(0).asExpr()) + result.flowsTo(this.getArgument(0)) or // For the route-handlers that does not depend on this predicate in their charpred. result.(RouteHandler).getARouteHandlerRegistrationObject().flowsTo(this.getArgument(0)) diff --git a/javascript/ql/test/library-tests/frameworks/Express/RouteExpr.qll b/javascript/ql/test/library-tests/frameworks/Express/RouteExpr.qll deleted file mode 100644 index bc8010494fd..00000000000 --- a/javascript/ql/test/library-tests/frameworks/Express/RouteExpr.qll +++ /dev/null @@ -1,5 +0,0 @@ -import javascript - -query predicate test_RouteExpr(Express::RouteExpr e, Express::RouterDefinition res) { - res = e.getRouter() -} diff --git a/javascript/ql/test/library-tests/frameworks/Express/tests.ql b/javascript/ql/test/library-tests/frameworks/Express/tests.ql index ec76c73df27..d708732267a 100644 --- a/javascript/ql/test/library-tests/frameworks/Express/tests.ql +++ b/javascript/ql/test/library-tests/frameworks/Express/tests.ql @@ -27,7 +27,6 @@ import RouterDefinition_getASubRouter import HeaderDefinition_getNameExpr import appCreation import RouteSetup_getRequestMethod -import RouteExpr import RouteHandler_getAResponseExpr import isResponse import ResponseBody