Skip to content

Commit 24b8455

Browse files
committed
change ResponseBody to a DataFlow::Node
1 parent 19e8081 commit 24b8455

File tree

10 files changed

+16
-21
lines changed

10 files changed

+16
-21
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ module Express {
766766
private class ResponseSendArgument extends HTTP::ResponseSendArgument {
767767
ResponseSource response;
768768

769-
ResponseSendArgument() { this = response.ref().getAMethodCall("send").getArgument(0).asExpr() }
769+
ResponseSendArgument() { this = response.ref().getAMethodCall("send").getArgument(0) }
770770

771771
override RouteHandler getRouteHandler() { result = response.getRouteHandler() }
772772
}
@@ -794,7 +794,7 @@ module Express {
794794
TemplateObjectInput obj;
795795

796796
TemplateInput() {
797-
obj.getALocalSource().(DataFlow::ObjectLiteralNode).hasPropertyWrite(_, this.flow())
797+
obj.getALocalSource().(DataFlow::ObjectLiteralNode).hasPropertyWrite(_, this)
798798
}
799799

800800
override RouteHandler getRouteHandler() { result = obj.getRouteHandler() }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ module Fastify {
340340
RouteHandler rh;
341341

342342
ResponseSendArgument() {
343-
this = rh.getAResponseSource().ref().getAMethodCall("send").getArgument(0).asExpr()
343+
this = rh.getAResponseSource().ref().getAMethodCall("send").getArgument(0)
344344
or
345-
this = rh.(DataFlow::FunctionNode).getAReturn().asExpr()
345+
this = rh.(DataFlow::FunctionNode).getAReturn()
346346
}
347347

348348
override RouteHandler getRouteHandler() { result = rh }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ module HTTP {
117117
/**
118118
* An expression whose value is sent as (part of) the body of an HTTP response.
119119
*/
120-
abstract class ResponseBody extends Expr {
120+
abstract class ResponseBody extends DataFlow::Node {
121121
/**
122122
* Gets the route handler that sends this expression.
123123
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ module Hapi {
270270
private class HandlerReturn extends HTTP::ResponseSendArgument {
271271
RouteHandler handler;
272272

273-
HandlerReturn() { this = handler.(DataFlow::FunctionNode).getAReturn().asExpr() }
273+
HandlerReturn() { this = handler.(DataFlow::FunctionNode).getAReturn() }
274274

275275
override RouteHandler getRouteHandler() { result = handler }
276276
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,7 @@ module Koa {
412412

413413
ResponseSendArgument() {
414414
exists(DataFlow::PropWrite pwn |
415-
pwn.writes(DataFlow::valueNode(rh.getAResponseOrContextExpr()), "body",
416-
DataFlow::valueNode(this))
415+
pwn.writes(DataFlow::valueNode(rh.getAResponseOrContextExpr()), "body", this)
417416
)
418417
}
419418

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private module Micro {
104104

105105
MicroSendArgument() {
106106
send = moduleMember("micro", ["send", "sendError"]).getACall() and
107-
this = send.getLastArgument().asExpr()
107+
this = send.getLastArgument()
108108
}
109109

110110
override HTTP::RouteHandler getRouteHandler() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ module NestJS {
349349

350350
ReturnValueAsResponseSend() {
351351
handler.isReturnValueReflected() and
352-
this = handler.getAReturn().asExpr() and
352+
this = handler.getAReturn() and
353353
// Only returned strings are sinks
354354
not exists(Type type |
355-
type = getType() and
355+
type = this.asExpr().getType() and
356356
not isStringType(type.unfold())
357357
)
358358
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ module NodeJSLib {
363363
HTTP::RouteHandler rh;
364364

365365
ResponseSendArgument() {
366-
exists(MethodCallExpr mce, string m | m = "write" or m = "end" |
367-
mce.calls(any(ResponseExpr e | e.getRouteHandler() = rh), m) and
368-
this = mce.getArgument(0) and
366+
exists(DataFlow::MethodCallNode mcn, string m | m = "write" or m = "end" |
367+
mcn.calls(any(ResponseExpr e | e.getRouteHandler() = rh).flow(), m) and
368+
this = mcn.getArgument(0) and
369369
// don't mistake callback functions as data
370370
not this.analyze().getAValue() instanceof AbstractFunction
371371
)

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ module ReflectedXss {
2424
* a content type that does not (case-insensitively) contain the string "html". This
2525
* is to prevent us from flagging plain-text or JSON responses as vulnerable.
2626
*/
27-
class HttpResponseSink extends Sink, DataFlow::ValueNode {
28-
override HTTP::ResponseSendArgument astNode;
29-
30-
HttpResponseSink() { not exists(getANonHtmlHeaderDefinition(astNode)) }
27+
class HttpResponseSink extends Sink instanceof HTTP::ResponseSendArgument {
28+
HttpResponseSink() { not exists(getANonHtmlHeaderDefinition(this)) }
3129
}
3230

3331
/**

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,5 @@ module StackTraceExposure {
3232
* An expression that can become part of an HTTP response body, viewed
3333
* as a data flow sink for stack trace exposure vulnerabilities.
3434
*/
35-
class DefaultSink extends Sink, DataFlow::ValueNode {
36-
override HTTP::ResponseBody astNode;
37-
}
35+
class DefaultSink extends Sink instanceof HTTP::ResponseBody { }
3836
}

0 commit comments

Comments
 (0)