mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
JS: Decouple chaining from ExplicitResponseSource
This commit is contained in:
@@ -513,21 +513,6 @@ module Express {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `call` is a chainable method call on the response object of `handler`.
|
||||
*/
|
||||
private predicate isChainableResponseMethodCall(
|
||||
RouteHandler handler, DataFlow::MethodCallNode call
|
||||
) {
|
||||
exists(string name | call.calls(handler.getAResponseNode(), name) |
|
||||
name =
|
||||
[
|
||||
"append", "attachment", "location", "send", "sendStatus", "set", "status", "type", "vary",
|
||||
"clearCookie", "contentType", "cookie", "format", "header", "json", "jsonp", "links"
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
/** An Express response source. */
|
||||
abstract class ResponseSource extends Http::Servers::ResponseSource { }
|
||||
|
||||
@@ -538,11 +523,7 @@ module Express {
|
||||
private class ExplicitResponseSource extends ResponseSource {
|
||||
RouteHandler rh;
|
||||
|
||||
ExplicitResponseSource() {
|
||||
this = rh.getResponseParameter()
|
||||
or
|
||||
isChainableResponseMethodCall(rh, this)
|
||||
}
|
||||
ExplicitResponseSource() { this = rh.getResponseParameter() }
|
||||
|
||||
/**
|
||||
* Gets the route handler that provides this response.
|
||||
@@ -559,6 +540,22 @@ module Express {
|
||||
override RouteHandler getRouteHandler() { none() } // Not known.
|
||||
}
|
||||
|
||||
private class ChainedResponse extends ResponseSource {
|
||||
private ResponseSource base;
|
||||
|
||||
ChainedResponse() {
|
||||
this =
|
||||
base.ref()
|
||||
.getAMethodCall([
|
||||
"append", "attachment", "location", "send", "sendStatus", "set", "status", "type",
|
||||
"vary", "clearCookie", "contentType", "cookie", "format", "header", "json", "jsonp",
|
||||
"links"
|
||||
])
|
||||
}
|
||||
|
||||
override Http::RouteHandler getRouteHandler() { result = base.getRouteHandler() }
|
||||
}
|
||||
|
||||
/** An Express request source. */
|
||||
abstract class RequestSource extends Http::Servers::RequestSource { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user