Skip to content

Commit b508ad4

Browse files
committed
don't have a separate fetch module
1 parent 46cd014 commit b508ad4

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

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

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -278,44 +278,34 @@ module ClientRequest {
278278
}
279279

280280
/**
281-
* Provides predicates for working with `fetch` and its platform-specific instances as a single module.
281+
* A model of a URL request made using an implementation of the `fetch` API.
282282
*/
283-
module Fetch {
284-
/**
285-
* Gets a node that refers to `fetch`, or an import of one of its platform-specific instances.
286-
*/
287-
DataFlow::SourceNode moduleImport() {
288-
result = DataFlow::moduleImport(["node-fetch", "cross-fetch", "isomorphic-fetch"])
289-
or
290-
result = DataFlow::globalVarRef("fetch") // https://fetch.spec.whatwg.org/#fetch-api
291-
}
292-
293-
/**
294-
* A model of a URL request made using an implementation of the `fetch` API.
295-
*/
296-
class FetchUrlRequest extends ClientRequest::Range {
297-
DataFlow::Node url;
283+
class FetchUrlRequest extends ClientRequest::Range {
284+
DataFlow::Node url;
298285

299-
FetchUrlRequest() {
300-
this = moduleImport().getACall() and
286+
FetchUrlRequest() {
287+
exists(DataFlow::SourceNode fetch |
288+
fetch = DataFlow::moduleImport(["node-fetch", "cross-fetch", "isomorphic-fetch"])
289+
or
290+
fetch = DataFlow::globalVarRef("fetch") // https://fetch.spec.whatwg.org/#fetch-api
291+
|
292+
this = fetch.getACall() and
301293
url = getArgument(0)
302-
}
294+
)
295+
}
303296

304-
override DataFlow::Node getUrl() { result = url }
297+
override DataFlow::Node getUrl() { result = url }
305298

306-
override DataFlow::Node getHost() { none() }
299+
override DataFlow::Node getHost() { none() }
307300

308-
override DataFlow::Node getADataNode() {
309-
exists(string name | name = "headers" or name = "body" |
310-
result = getOptionArgument(1, name)
311-
)
312-
}
301+
override DataFlow::Node getADataNode() {
302+
exists(string name | name = "headers" or name = "body" | result = getOptionArgument(1, name))
303+
}
313304

314-
override DataFlow::Node getAResponseDataNode(string responseType, boolean promise) {
315-
responseType = "fetch.response" and
316-
promise = true and
317-
result = this
318-
}
305+
override DataFlow::Node getAResponseDataNode(string responseType, boolean promise) {
306+
responseType = "fetch.response" and
307+
promise = true and
308+
result = this
319309
}
320310
}
321311

0 commit comments

Comments
 (0)