JS: refactor DefaultUrlRequest: extract the got library

This commit is contained in:
Esben Sparre Andreasen
2018-09-03 13:08:31 +02:00
parent 1abdf2ffd5
commit de6b83548a

View File

@@ -67,17 +67,6 @@ private class DefaultUrlRequest extends CustomUrlRequest {
callee = DataFlow::moduleMember(moduleName, httpMethodName()) and
url = getArgument(0)
)
or
(
moduleName = "got" and
(
callee = DataFlow::moduleImport(moduleName) or
callee = DataFlow::moduleMember(moduleName, "stream")
) and
(
url = getArgument(0) and not exists (getOptionArgument(1, "baseUrl"))
)
)
)
}
@@ -203,3 +192,29 @@ private class NodeHttpUrlRequest extends CustomUrlRequest {
}
}
/**
* A model of a URL request in the `got` library.
*/
private class GotUrlRequest extends CustomUrlRequest {
DataFlow::Node url;
GotUrlRequest() {
exists (string moduleName, DataFlow::SourceNode callee |
this = callee.getACall() |
moduleName = "got" and
(
callee = DataFlow::moduleImport(moduleName) or
callee = DataFlow::moduleMember(moduleName, "stream")
) and
url = getArgument(0) and not exists (getOptionArgument(1, "baseUrl"))
)
}
override DataFlow::Node getUrl() {
result = url
}
}