Skip to content

Commit 2f429e7

Browse files
committed
convert some leftovers to use dataflow nodes
1 parent 136124f commit 2f429e7

File tree

5 files changed

+13
-28
lines changed

5 files changed

+13
-28
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Express.qll

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ module Express {
5656
}
5757

5858
/**
59+
* DEPRECATED: Use `isRouter()` instead.
5960
* An expression that refers to a route.
6061
*/
61-
class RouteExpr extends DataFlow::MethodCallNode {
62-
RouteExpr() { isRouter(this) }
63-
64-
/** Gets the router from which this route was created, if it is known. */
65-
RouterDefinition getRouter() { isRouter(this, result) }
62+
deprecated class RouteExpr extends MethodCallExpr {
63+
RouteExpr() { isRouter(this.flow()) }
6664
}
6765

6866
/**

javascript/ql/lib/semmle/javascript/frameworks/Hapi.qll

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,24 @@ module Hapi {
1919
/**
2020
* A Hapi route handler.
2121
*/
22-
class RouteHandler extends HTTP::Servers::StandardRouteHandler, DataFlow::ValueNode {
23-
Function function;
24-
25-
RouteHandler() {
26-
function = astNode and
27-
exists(RouteSetup setup | this = setup.getARouteHandler())
28-
}
22+
class RouteHandler extends HTTP::Servers::StandardRouteHandler, DataFlow::FunctionNode {
23+
RouteHandler() { exists(RouteSetup setup | this = setup.getARouteHandler()) }
2924

3025
/**
3126
* Gets the parameter of the route handler that contains the request object.
3227
*/
33-
Parameter getRequestParameter() { result = function.getParameter(0) }
28+
DataFlow::ParameterNode getRequestParameter() { result = getParameter(0) }
3429

3530
/**
3631
* Gets the parameter of the route handler that contains the "request toolkit",
3732
* usually named `h`.
3833
*/
39-
Parameter getRequestToolkitParameter() { result = function.getParameter(1) }
34+
DataFlow::ParameterNode getRequestToolkitParameter() { result = getParameter(1) }
4035

4136
/**
4237
* Gets a source node referring to the request toolkit parameter, usually named `h`.
4338
*/
44-
DataFlow::SourceNode getRequestToolkit() { result = getRequestToolkitParameter().flow() }
39+
DataFlow::SourceNode getRequestToolkit() { result = getRequestToolkitParameter() }
4540
}
4641

4742
/**
@@ -66,7 +61,7 @@ module Hapi {
6661
private class RequestSource extends HTTP::Servers::RequestSource {
6762
RouteHandler rh;
6863

69-
RequestSource() { this = DataFlow::parameterNode(rh.getRequestParameter()) }
64+
RequestSource() { this = rh.getRequestParameter() }
7065

7166
/**
7267
* Gets the route handler that handles this request.

javascript/ql/lib/semmle/javascript/frameworks/Koa.qll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module Koa {
4949
* Gets an expression that contains the "context" object of
5050
* a route handler invocation.
5151
*/
52-
deprecated Expr getAContextExpr() { result.(ContextExpr).getRouteHandler() = this }
52+
deprecated Expr getAContextExpr() { result = this.getAContextNode().asExpr() }
5353

5454
/**
5555
* Gets an expression that contains the "context" object of
@@ -67,7 +67,7 @@ module Koa {
6767
* object of a route handler invocation.
6868
*/
6969
deprecated Expr getAResponseOrContextExpr() {
70-
result = this.getAResponseNode().asExpr() or result = this.getAContextExpr()
70+
result = this.getAResponseOrContextNode().asExpr()
7171
}
7272

7373
/**
@@ -83,9 +83,7 @@ module Koa {
8383
* Gets an expression that contains the context or request
8484
* object of a route handler invocation.
8585
*/
86-
deprecated Expr getARequestOrContextExpr() {
87-
result = this.getARequestNode().asExpr() or result = this.getAContextExpr()
88-
}
86+
deprecated Expr getARequestOrContextExpr() { result = this.getARequestOrContextNode().asExpr() }
8987

9088
/**
9189
* Gets an expression that contains the context or request
@@ -447,7 +445,7 @@ module Koa {
447445

448446
override DataFlow::SourceNode getARouteHandler() {
449447
// `StandardRouteHandler` uses this predicate in it's charpred, so making this predicate return a `RouteHandler` would give an empty recursion.
450-
result.flowsToExpr(this.getArgument(0).asExpr())
448+
result.flowsTo(this.getArgument(0))
451449
or
452450
// For the route-handlers that does not depend on this predicate in their charpred.
453451
result.(RouteHandler).getARouteHandlerRegistrationObject().flowsTo(this.getArgument(0))

javascript/ql/test/library-tests/frameworks/Express/RouteExpr.qll

Lines changed: 0 additions & 5 deletions
This file was deleted.

javascript/ql/test/library-tests/frameworks/Express/tests.ql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import RouterDefinition_getASubRouter
2727
import HeaderDefinition_getNameExpr
2828
import appCreation
2929
import RouteSetup_getRequestMethod
30-
import RouteExpr
3130
import RouteHandler_getAResponseExpr
3231
import isResponse
3332
import ResponseBody

0 commit comments

Comments
 (0)