Skip to content

Commit 52991dc

Browse files
committed
rewrite the axios model to use API graphs
1 parent 54f191c commit 52991dc

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,14 @@ module ClientRequest {
206206
/**
207207
* A model of a URL request made using the `axios` library.
208208
*/
209-
class AxiosUrlRequest extends ClientRequest::Range {
209+
class AxiosUrlRequest extends ClientRequest::Range, API::CallNode {
210210
string method;
211211

212212
AxiosUrlRequest() {
213-
exists(string moduleName, DataFlow::SourceNode callee | this = callee.getACall() |
214-
moduleName = "axios" and
215-
(
216-
callee = DataFlow::moduleImport(moduleName) and method = "request"
217-
or
218-
callee = DataFlow::moduleMember(moduleName, method) and
219-
(method = httpMethodName() or method = "request")
220-
)
221-
)
213+
this = API::moduleImport("axios").getACall() and method = "request"
214+
or
215+
this = API::moduleImport("axios").getMember(method).getACall() and
216+
method = [httpMethodName(), "request"]
222217
}
223218

224219
private int getOptionsArgIndex() {
@@ -247,12 +242,10 @@ module ClientRequest {
247242
method = "request" and
248243
result = getOptionArgument(0, "data")
249244
or
250-
(method = "post" or method = "put" or method = "put") and
251-
(result = getArgument(1) or result = getOptionArgument(2, "data"))
245+
method = ["post", "put", "put"] and
246+
result = [getArgument(1), getOptionArgument(2, "data")]
252247
or
253-
exists(string name | name = "headers" or name = "params" |
254-
result = getOptionArgument([0 .. 2], name)
255-
)
248+
result = getOptionArgument([0 .. 2], ["headers", "params"])
256249
}
257250

258251
/** Gets the response type from the options passed in. */

0 commit comments

Comments
 (0)