JS: refactor DefaultUrlRequest: extract the http library

This commit is contained in:
Esben Sparre Andreasen
2018-09-03 13:07:02 +02:00
parent 5f26c23582
commit 1abdf2ffd5

View File

@@ -68,12 +68,6 @@ private class DefaultUrlRequest extends CustomUrlRequest {
url = getArgument(0)
)
or
(
(moduleName = "http" or moduleName = "https") and
callee = DataFlow::moduleMember(moduleName, httpMethodName()) and
url = getArgument(0)
)
or
(
moduleName = "got" and
(
@@ -186,3 +180,26 @@ private class FetchUrlRequest extends CustomUrlRequest {
}
}
/**
* A model of a URL request in the Node.js `http` library.
*/
private class NodeHttpUrlRequest extends CustomUrlRequest {
DataFlow::Node url;
NodeHttpUrlRequest() {
exists (string moduleName, DataFlow::SourceNode callee |
this = callee.getACall() |
(moduleName = "http" or moduleName = "https") and
callee = DataFlow::moduleMember(moduleName, httpMethodName()) and
url = getArgument(0)
)
}
override DataFlow::Node getUrl() {
result = url
}
}