mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
convert some leftovers to use dataflow nodes
This commit is contained in:
committed by
erik-krogh
parent
136124fbaa
commit
2f429e7d29
@@ -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()) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import javascript
|
||||
|
||||
query predicate test_RouteExpr(Express::RouteExpr e, Express::RouterDefinition res) {
|
||||
res = e.getRouter()
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import RouterDefinition_getASubRouter
|
||||
import HeaderDefinition_getNameExpr
|
||||
import appCreation
|
||||
import RouteSetup_getRequestMethod
|
||||
import RouteExpr
|
||||
import RouteHandler_getAResponseExpr
|
||||
import isResponse
|
||||
import ResponseBody
|
||||
|
||||
Reference in New Issue
Block a user