Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1abdf2f

Browse files
author
Esben Sparre Andreasen
committed
JS: refactor DefaultUrlRequest: extract the http library
1 parent 5f26c23 commit 1abdf2f

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ private class DefaultUrlRequest extends CustomUrlRequest {
6868
url = getArgument(0)
6969
)
7070
or
71-
(
72-
(moduleName = "http" or moduleName = "https") and
73-
callee = DataFlow::moduleMember(moduleName, httpMethodName()) and
74-
url = getArgument(0)
75-
)
76-
or
7771
(
7872
moduleName = "got" and
7973
(
@@ -186,3 +180,26 @@ private class FetchUrlRequest extends CustomUrlRequest {
186180
}
187181

188182
}
183+
184+
185+
/**
186+
* A model of a URL request in the Node.js `http` library.
187+
*/
188+
private class NodeHttpUrlRequest extends CustomUrlRequest {
189+
190+
DataFlow::Node url;
191+
192+
NodeHttpUrlRequest() {
193+
exists (string moduleName, DataFlow::SourceNode callee |
194+
this = callee.getACall() |
195+
(moduleName = "http" or moduleName = "https") and
196+
callee = DataFlow::moduleMember(moduleName, httpMethodName()) and
197+
url = getArgument(0)
198+
)
199+
}
200+
201+
override DataFlow::Node getUrl() {
202+
result = url
203+
}
204+
205+
}

0 commit comments

Comments
 (0)