JS: minor additions to ClientRequest::getAResponseDataNode

This commit is contained in:
Esben Sparre Andreasen
2019-09-06 09:15:26 +02:00
parent 6d8a4388cb
commit 3e42b078e8
2 changed files with 10 additions and 25 deletions

View File

@@ -452,6 +452,8 @@ module ClientRequest {
or
prop = "responseText" and responseType = "text"
or
prop = "responseUrl" and responseType = "text"
or
prop = "statusText" and responseType = "text"
or
prop = "responseXML" and responseType = "document"

View File

@@ -735,34 +735,17 @@ module NodeJSLib {
result = this.(DataFlow::SourceNode).getAMethodCall(name).getArgument(0)
)
}
}
/**
* 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) => {})`.
*/
private class ClientRequestCallbackParam extends DataFlow::ParameterNode, RemoteFlowSource {
ClientRequestCallbackParam() {
exists(NodeJSClientRequest req |
this = req.(DataFlow::MethodCallNode).getCallback(1).getParameter(0)
override DataFlow::Node getAResponseDataNode(string responseType, boolean promise) {
promise = false and
exists(DataFlow::ParameterNode res, DataFlow::CallNode onData |
res = getCallback(1).getParameter(0) and
onData = res.getAMethodCall("on") and
onData.getArgument(0).mayHaveStringValue("data") and
result = onData.getCallback(1).getParameter(0) and
responseType = "arraybuffer"
)
}
override string getSourceType() { result = "NodeJSClientRequest callback parameter" }
}
/**
* 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) => {})})`.
*/
private class ClientRequestCallbackData extends RemoteFlowSource {
ClientRequestCallbackData() {
exists(ClientRequestCallbackParam rcp, DataFlow::MethodCallNode mcn |
rcp.getAMethodCall("on") = mcn and
mcn.getArgument(0).mayHaveStringValue("data") and
this = mcn.getCallback(1).getParameter(0)
)
}
override string getSourceType() { result = "http.request data parameter" }
}
/**