Skip to content

Commit 6ded66f

Browse files
committed
Simplified SuperAgentUrlRequest.
1 parent 53ac6b5 commit 6ded66f

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

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

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -520,26 +520,21 @@ module ClientRequest {
520520
DataFlow::Node url;
521521

522522
SuperAgentUrlRequest() {
523-
exists(string moduleName, DataFlow::SourceNode callee |
524-
moduleName = "superagent" and
525-
(
526-
this = callee.getACall() and
527-
// Handle method calls like superagent.get(url)
528-
callee = DataFlow::moduleMember(moduleName, httpMethodName()) and
523+
exists(string moduleName | moduleName = "superagent" |
524+
// Handle method calls like superagent.get(url)
525+
this = DataFlow::moduleMember(moduleName, httpMethodName()).getACall() and
526+
url = this.getArgument(0)
527+
or
528+
// Handle direct calls like superagent('GET', url)
529+
this = DataFlow::moduleImport(moduleName).getACall() and
530+
this.getArgument(0).mayHaveStringValue([httpMethodName().toUpperCase(), httpMethodName()]) and
531+
url = this.getArgument(1)
532+
or
533+
// Handle agent calls like superagent.agent().get(url)
534+
exists(DataFlow::SourceNode agent |
535+
agent = DataFlow::moduleMember(moduleName, "agent").getACall() and
536+
this = agent.getAMethodCall(httpMethodName()) and
529537
url = this.getArgument(0)
530-
or
531-
this = callee.getACall() and
532-
// Handle direct calls like superagent('GET', url)
533-
callee = DataFlow::moduleImport(moduleName) and
534-
this.getArgument(0).mayHaveStringValue([httpMethodName().toUpperCase(), httpMethodName()]) and
535-
url = this.getArgument(1)
536-
or
537-
// Handle agent calls like superagent.agent().get(url)
538-
exists(DataFlow::SourceNode agent |
539-
agent = DataFlow::moduleMember(moduleName, "agent").getACall() and
540-
this = agent.getAMethodCall(httpMethodName()) and
541-
url = this.getArgument(0)
542-
)
543538
)
544539
)
545540
}

0 commit comments

Comments
 (0)