Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Handling of axios in functions and making axios create function recur… #19337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Handling of axios in functions and making axios create function recur…
…sive
  • Loading branch information
rotem-cider committed Apr 19, 2025
commit a49296b381a65b6cfd4d486b2012c4bd3733b107
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,36 @@ module ClientRequest {
override DataFlow::SourceNode getASource() { result = DataFlow::globalVarRef("axios") }
}

/** An API entry-point for the `axios` library inside a function */
private class AxiosInFunction extends API::EntryPoint {
AxiosInFunction() { this = "axios" }

override DataFlow::SourceNode getASource() {
// Handle direct parameter naming: function(axios){}
exists(Function f, Parameter p |
p.getName() = "axios" and
result = DataFlow::parameterNode(p)
)
or
// Handle destructured parameters: function({axios}){}
exists(DataFlow::ParameterNode param, DataFlow::SourceNode prop |
prop = param.getAPropertyRead("axios") and
result = prop
)
}
}
/** Gets a reference to the `axios` library. */
private API::Node axios() {
result = API::moduleImport("axios")
or
result = API::root().getASuccessor(API::Label::entryPoint(any(AxiosGlobalEntryPoint entry)))
or
result = API::root().getASuccessor(API::Label::entryPoint(any(AxiosInFunction entry)))
}

/** Recursively gets the `create` method of an axios instance. */
private API::Node axiosWithCreate() {
result = [axios(), axios().getMember("create").getReturn()]
}

/**
Expand All @@ -218,14 +243,11 @@ module ClientRequest {
string method;

AxiosUrlRequest() {
this = axios().getACall() and
this = axiosWithCreate().getACall() and
method = "request"
or
this = axios().getMember(method).getACall() and
this = axiosWithCreate().getMember(method).getACall() and
method = [httpMethodName(), "request", "postForm", "putForm", "patchForm", "getUri"]
or
this = axios().getMember("create").getReturn().getACall() and
method = "request"
}

private int getOptionsArgIndex() {
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.