mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
@@ -183,6 +183,11 @@ module API {
|
||||
*/
|
||||
Node getPromised() { result = getASuccessor(Label::promised()) }
|
||||
|
||||
/**
|
||||
* Gets a node representing the error wrapped in the `Promise` object represented by this node.
|
||||
*/
|
||||
Node getPromisedError() { result = getASuccessor(Label::promisedError()) }
|
||||
|
||||
/**
|
||||
* Gets a string representation of the lexicographically least among all shortest access paths
|
||||
* from the root to this node.
|
||||
@@ -468,6 +473,9 @@ module API {
|
||||
or
|
||||
lbl = Label::promised() and
|
||||
PromiseFlow::storeStep(rhs, pred, Promises::valueProp())
|
||||
or
|
||||
lbl = Label::promisedError() and
|
||||
PromiseFlow::storeStep(rhs, pred, Promises::errorProp())
|
||||
)
|
||||
or
|
||||
exists(DataFlow::ClassNode cls, string name |
|
||||
@@ -482,6 +490,12 @@ module API {
|
||||
rhs = f.getAReturn()
|
||||
)
|
||||
or
|
||||
exists(DataFlow::FunctionNode f |
|
||||
base = MkAsyncFuncResult(f) and
|
||||
lbl = Label::promisedError() and
|
||||
rhs = f.getExceptionalReturn()
|
||||
)
|
||||
or
|
||||
exists(int i |
|
||||
lbl = Label::parameter(i) and
|
||||
argumentPassing(base, i, rhs)
|
||||
@@ -559,6 +573,9 @@ module API {
|
||||
or
|
||||
lbl = Label::promised() and
|
||||
PromiseFlow::loadStep(pred, ref, Promises::valueProp())
|
||||
or
|
||||
lbl = Label::promisedError() and
|
||||
PromiseFlow::loadStep(pred, ref, Promises::errorProp())
|
||||
)
|
||||
or
|
||||
exists(DataFlow::Node def, DataFlow::FunctionNode fn |
|
||||
@@ -962,6 +979,9 @@ private module Label {
|
||||
|
||||
/** Gets the `promised` edge label connecting a promise to its contained value. */
|
||||
string promised() { result = "promised" }
|
||||
|
||||
/** Gets the `promisedError` edge label connecting a promise to its rejected value. */
|
||||
string promisedError() { result = "promisedError" }
|
||||
}
|
||||
|
||||
private class NodeModuleSourcesNodes extends DataFlow::SourceNode::Range {
|
||||
|
||||
@@ -206,19 +206,14 @@ module ClientRequest {
|
||||
/**
|
||||
* A model of a URL request made using the `axios` library.
|
||||
*/
|
||||
class AxiosUrlRequest extends ClientRequest::Range {
|
||||
class AxiosUrlRequest extends ClientRequest::Range, API::CallNode {
|
||||
string method;
|
||||
|
||||
AxiosUrlRequest() {
|
||||
exists(string moduleName, DataFlow::SourceNode callee | this = callee.getACall() |
|
||||
moduleName = "axios" and
|
||||
(
|
||||
callee = DataFlow::moduleImport(moduleName) and method = "request"
|
||||
or
|
||||
callee = DataFlow::moduleMember(moduleName, method) and
|
||||
(method = httpMethodName() or method = "request")
|
||||
)
|
||||
)
|
||||
this = API::moduleImport("axios").getACall() and method = "request"
|
||||
or
|
||||
this = API::moduleImport("axios").getMember(method).getACall() and
|
||||
method = [httpMethodName(), "request"]
|
||||
}
|
||||
|
||||
private int getOptionsArgIndex() {
|
||||
@@ -247,12 +242,10 @@ module ClientRequest {
|
||||
method = "request" and
|
||||
result = getOptionArgument(0, "data")
|
||||
or
|
||||
(method = "post" or method = "put" or method = "put") and
|
||||
(result = getArgument(1) or result = getOptionArgument(2, "data"))
|
||||
method = ["post", "put"] and
|
||||
result = [getArgument(1), getOptionArgument(2, "data")]
|
||||
or
|
||||
exists(string name | name = "headers" or name = "params" |
|
||||
result = getOptionArgument([0 .. 2], name)
|
||||
)
|
||||
result = getOptionArgument([0 .. 2], ["headers", "params"])
|
||||
}
|
||||
|
||||
/** Gets the response type from the options passed in. */
|
||||
@@ -275,6 +268,10 @@ module ClientRequest {
|
||||
responseType = getResponseType() and
|
||||
promise = true and
|
||||
result = this
|
||||
or
|
||||
responseType = getResponseType() and
|
||||
promise = false and
|
||||
result = getReturn().getPromisedError().getMember("response").getAnImmediateUse()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user