Skip to content

Commit 3e42b07

Browse files
author
Esben Sparre Andreasen
committed
JS: minor additions to ClientRequest::getAResponseDataNode
1 parent 6d8a438 commit 3e42b07

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

javascript/ql/src/semmle/javascript/frameworks/ClientRequests.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ module ClientRequest {
452452
or
453453
prop = "responseText" and responseType = "text"
454454
or
455+
prop = "responseUrl" and responseType = "text"
456+
or
455457
prop = "statusText" and responseType = "text"
456458
or
457459
prop = "responseXML" and responseType = "document"

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

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -735,34 +735,17 @@ module NodeJSLib {
735735
result = this.(DataFlow::SourceNode).getAMethodCall(name).getArgument(0)
736736
)
737737
}
738-
}
739738

740-
/**
741-
* A data flow node that is the parameter of a result callback for an HTTP or HTTPS request made by a Node.js process, for example `res` in `https.request(url, (res) => {})`.
742-
*/
743-
private class ClientRequestCallbackParam extends DataFlow::ParameterNode, RemoteFlowSource {
744-
ClientRequestCallbackParam() {
745-
exists(NodeJSClientRequest req |
746-
this = req.(DataFlow::MethodCallNode).getCallback(1).getParameter(0)
739+
override DataFlow::Node getAResponseDataNode(string responseType, boolean promise) {
740+
promise = false and
741+
exists(DataFlow::ParameterNode res, DataFlow::CallNode onData |
742+
res = getCallback(1).getParameter(0) and
743+
onData = res.getAMethodCall("on") and
744+
onData.getArgument(0).mayHaveStringValue("data") and
745+
result = onData.getCallback(1).getParameter(0) and
746+
responseType = "arraybuffer"
747747
)
748748
}
749-
750-
override string getSourceType() { result = "NodeJSClientRequest callback parameter" }
751-
}
752-
753-
/**
754-
* A data flow node that is the parameter of a data callback for an HTTP or HTTPS request made by a Node.js process, for example `body` in `http.request(url, (res) => {res.on('data', (body) => {})})`.
755-
*/
756-
private class ClientRequestCallbackData extends RemoteFlowSource {
757-
ClientRequestCallbackData() {
758-
exists(ClientRequestCallbackParam rcp, DataFlow::MethodCallNode mcn |
759-
rcp.getAMethodCall("on") = mcn and
760-
mcn.getArgument(0).mayHaveStringValue("data") and
761-
this = mcn.getCallback(1).getParameter(0)
762-
)
763-
}
764-
765-
override string getSourceType() { result = "http.request data parameter" }
766749
}
767750

768751
/**

0 commit comments

Comments
 (0)