File tree Expand file tree Collapse file tree 10 files changed +16
-21
lines changed
javascript/ql/lib/semmle/javascript Expand file tree Collapse file tree 10 files changed +16
-21
lines changed Original file line number Diff line number Diff line change @@ -766,7 +766,7 @@ module Express {
766
766
private class ResponseSendArgument extends HTTP:: ResponseSendArgument {
767
767
ResponseSource response ;
768
768
769
- ResponseSendArgument ( ) { this = response .ref ( ) .getAMethodCall ( "send" ) .getArgument ( 0 ) . asExpr ( ) }
769
+ ResponseSendArgument ( ) { this = response .ref ( ) .getAMethodCall ( "send" ) .getArgument ( 0 ) }
770
770
771
771
override RouteHandler getRouteHandler ( ) { result = response .getRouteHandler ( ) }
772
772
}
@@ -794,7 +794,7 @@ module Express {
794
794
TemplateObjectInput obj ;
795
795
796
796
TemplateInput ( ) {
797
- obj .getALocalSource ( ) .( DataFlow:: ObjectLiteralNode ) .hasPropertyWrite ( _, this . flow ( ) )
797
+ obj .getALocalSource ( ) .( DataFlow:: ObjectLiteralNode ) .hasPropertyWrite ( _, this )
798
798
}
799
799
800
800
override RouteHandler getRouteHandler ( ) { result = obj .getRouteHandler ( ) }
Original file line number Diff line number Diff line change @@ -340,9 +340,9 @@ module Fastify {
340
340
RouteHandler rh ;
341
341
342
342
ResponseSendArgument ( ) {
343
- this = rh .getAResponseSource ( ) .ref ( ) .getAMethodCall ( "send" ) .getArgument ( 0 ) . asExpr ( )
343
+ this = rh .getAResponseSource ( ) .ref ( ) .getAMethodCall ( "send" ) .getArgument ( 0 )
344
344
or
345
- this = rh .( DataFlow:: FunctionNode ) .getAReturn ( ) . asExpr ( )
345
+ this = rh .( DataFlow:: FunctionNode ) .getAReturn ( )
346
346
}
347
347
348
348
override RouteHandler getRouteHandler ( ) { result = rh }
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ module HTTP {
117
117
/**
118
118
* An expression whose value is sent as (part of) the body of an HTTP response.
119
119
*/
120
- abstract class ResponseBody extends Expr {
120
+ abstract class ResponseBody extends DataFlow :: Node {
121
121
/**
122
122
* Gets the route handler that sends this expression.
123
123
*/
Original file line number Diff line number Diff line change @@ -270,7 +270,7 @@ module Hapi {
270
270
private class HandlerReturn extends HTTP:: ResponseSendArgument {
271
271
RouteHandler handler ;
272
272
273
- HandlerReturn ( ) { this = handler .( DataFlow:: FunctionNode ) .getAReturn ( ) . asExpr ( ) }
273
+ HandlerReturn ( ) { this = handler .( DataFlow:: FunctionNode ) .getAReturn ( ) }
274
274
275
275
override RouteHandler getRouteHandler ( ) { result = handler }
276
276
}
Original file line number Diff line number Diff line change @@ -412,8 +412,7 @@ module Koa {
412
412
413
413
ResponseSendArgument ( ) {
414
414
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 )
417
416
)
418
417
}
419
418
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ private module Micro {
104
104
105
105
MicroSendArgument ( ) {
106
106
send = moduleMember ( "micro" , [ "send" , "sendError" ] ) .getACall ( ) and
107
- this = send .getLastArgument ( ) . asExpr ( )
107
+ this = send .getLastArgument ( )
108
108
}
109
109
110
110
override HTTP:: RouteHandler getRouteHandler ( ) {
Original file line number Diff line number Diff line change @@ -349,10 +349,10 @@ module NestJS {
349
349
350
350
ReturnValueAsResponseSend ( ) {
351
351
handler .isReturnValueReflected ( ) and
352
- this = handler .getAReturn ( ) . asExpr ( ) and
352
+ this = handler .getAReturn ( ) and
353
353
// Only returned strings are sinks
354
354
not exists ( Type type |
355
- type = getType ( ) and
355
+ type = this . asExpr ( ) . getType ( ) and
356
356
not isStringType ( type .unfold ( ) )
357
357
)
358
358
}
Original file line number Diff line number Diff line change @@ -363,9 +363,9 @@ module NodeJSLib {
363
363
HTTP:: RouteHandler rh ;
364
364
365
365
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
369
369
// don't mistake callback functions as data
370
370
not this .analyze ( ) .getAValue ( ) instanceof AbstractFunction
371
371
)
Original file line number Diff line number Diff line change @@ -24,10 +24,8 @@ module ReflectedXss {
24
24
* a content type that does not (case-insensitively) contain the string "html". This
25
25
* is to prevent us from flagging plain-text or JSON responses as vulnerable.
26
26
*/
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 ) ) }
31
29
}
32
30
33
31
/**
Original file line number Diff line number Diff line change @@ -32,7 +32,5 @@ module StackTraceExposure {
32
32
* An expression that can become part of an HTTP response body, viewed
33
33
* as a data flow sink for stack trace exposure vulnerabilities.
34
34
*/
35
- class DefaultSink extends Sink , DataFlow:: ValueNode {
36
- override HTTP:: ResponseBody astNode ;
37
- }
35
+ class DefaultSink extends Sink instanceof HTTP:: ResponseBody { }
38
36
}
You can’t perform that action at this time.
0 commit comments