Skip to content

Commit d4ccc75

Browse files
committed
refactor RedirectInvocation to a DataFlow::Node
1 parent a03e6a8 commit d4ccc75

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,12 @@ module Express {
697697
/**
698698
* An invocation of the `redirect` method of an HTTP response object.
699699
*/
700-
private class RedirectInvocation extends HTTP::RedirectInvocation, MethodCallExpr {
700+
private class RedirectInvocation extends HTTP::RedirectInvocation, DataFlow::MethodCallNode {
701701
ResponseSource response;
702702

703-
RedirectInvocation() { this = response.ref().getAMethodCall("redirect").asExpr() }
703+
RedirectInvocation() { this = response.ref().getAMethodCall("redirect") }
704704

705-
override Expr getUrlArgument() { result = this.getLastArgument() }
705+
override DataFlow::Node getUrlArgument() { result = this.getLastArgument() }
706706

707707
override RouteHandler getRouteHandler() { result = response.getRouteHandler() }
708708
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,12 @@ module Fastify {
351351
/**
352352
* An invocation of the `redirect` method of an HTTP response object.
353353
*/
354-
private class RedirectInvocation extends HTTP::RedirectInvocation, MethodCallExpr {
354+
private class RedirectInvocation extends HTTP::RedirectInvocation, DataFlow::MethodCallNode {
355355
RouteHandler rh;
356356

357-
RedirectInvocation() {
358-
this = rh.getAResponseSource().ref().getAMethodCall("redirect").asExpr()
359-
}
357+
RedirectInvocation() { this = rh.getAResponseSource().ref().getAMethodCall("redirect") }
360358

361-
override Expr getUrlArgument() { result = this.getLastArgument() }
359+
override DataFlow::Node getUrlArgument() { result = this.getLastArgument() }
362360

363361
override RouteHandler getRouteHandler() { result = rh }
364362
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ module HTTP {
1212
/**
1313
* A function invocation that causes a redirect response to be sent.
1414
*/
15-
abstract class RedirectInvocation extends InvokeExpr {
15+
abstract class RedirectInvocation extends DataFlow::CallNode {
1616
/** Gets the argument specifying the URL to redirect to. */
17-
abstract Expr getUrlArgument();
17+
abstract DataFlow::Node getUrlArgument();
1818

1919
/** Gets the route handler this redirect occurs in. */
2020
abstract RouteHandler getRouteHandler();

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,14 @@ module Koa {
422422
/**
423423
* An invocation of the `redirect` method of an HTTP response object.
424424
*/
425-
private class RedirectInvocation extends HTTP::RedirectInvocation, MethodCallExpr {
425+
private class RedirectInvocation extends HTTP::RedirectInvocation, DataFlow::MethodCallNode {
426426
RouteHandler rh;
427427

428-
RedirectInvocation() { this.(MethodCallExpr).calls(rh.getAResponseOrContextExpr(), "redirect") }
428+
RedirectInvocation() {
429+
this.asExpr().(MethodCallExpr).calls(rh.getAResponseOrContextExpr(), "redirect")
430+
} // TODO: Improve this.
429431

430-
override Expr getUrlArgument() { result = this.getArgument(0) }
432+
override DataFlow::Node getUrlArgument() { result = this.getArgument(0) }
431433

432434
override RouteHandler getRouteHandler() { result = rh }
433435
}

javascript/ql/lib/semmle/javascript/security/dataflow/ServerSideUrlRedirectCustomizations.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ module ServerSideUrlRedirect {
3333
/**
3434
* An HTTP redirect, considered as a sink for `Configuration`.
3535
*/
36-
class RedirectSink extends Sink, DataFlow::ValueNode {
37-
RedirectSink() { astNode = any(HTTP::RedirectInvocation redir).getUrlArgument() }
36+
class RedirectSink extends Sink {
37+
RedirectSink() { this = any(HTTP::RedirectInvocation redir).getUrlArgument() }
3838
}
3939

4040
/**

javascript/ql/test/library-tests/frameworks/koa/RedirectInvocation.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import javascript
22

33
query predicate test_RedirectInvocation(
4-
HTTP::RedirectInvocation redirect, Expr url, HTTP::RouteHandler rh
4+
HTTP::RedirectInvocation redirect, DataFlow::Node url, HTTP::RouteHandler rh
55
) {
66
redirect.getUrlArgument() = url and
77
redirect.getRouteHandler() = rh

0 commit comments

Comments
 (0)