-
Notifications
You must be signed in to change notification settings - Fork 2k
JS: superagent modeling
#19068
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
JS: superagent modeling
#19068
Changes from 6 commits
e5c179d
2e1734e
cdf4f53
539e2ef
af567b4
38624a0
13e90c1
401c6ea
d61d038
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Extended support for `superagent` to include function call syntax and agent-based requests. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -513,17 +513,36 @@ module ClientRequest { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets the name of a superagent request method. | ||
| */ | ||
| private string getSuperagentRequestMethodName() { | ||
| result = [httpMethodName(), any(Http::RequestMethodName m), "del", "DEL"] | ||
| } | ||
|
|
||
| /** | ||
| * A model of a URL request made using the `superagent` library. | ||
| */ | ||
| class SuperAgentUrlRequest extends ClientRequest::Range { | ||
| DataFlow::Node url; | ||
|
|
||
| SuperAgentUrlRequest() { | ||
| exists(string moduleName, DataFlow::SourceNode callee | this = callee.getACall() | | ||
| moduleName = "superagent" and | ||
| callee = DataFlow::moduleMember(moduleName, httpMethodName()) and | ||
| exists(string moduleName | moduleName = "superagent" | | ||
| // Handle method calls like superagent.get(url) | ||
| this = DataFlow::moduleMember(moduleName, getSuperagentRequestMethodName()).getACall() and | ||
| url = this.getArgument(0) | ||
| or | ||
| // Handle direct calls like superagent('GET', url) | ||
| this = DataFlow::moduleImport(moduleName).getACall() and | ||
| this.getArgument(0).mayHaveStringValue(getSuperagentRequestMethodName()) and | ||
| url = this.getArgument(1) | ||
| or | ||
| // Handle agent calls like superagent.agent().get(url) | ||
| exists(DataFlow::SourceNode agent | | ||
| agent = DataFlow::moduleMember(moduleName, "agent").getACall() and | ||
| this = agent.getAMethodCall(httpMethodName()) and | ||
| url = this.getArgument(0) | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you feel like going a step further you could switch to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have tried to remake it to use |
||
| ) | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.