add support for rejected promise values in API graphs

This commit is contained in:
Erik Krogh Kristensen
2021-05-11 11:23:03 +02:00
parent 744c495ac2
commit 54f191cfe3

View File

@@ -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 {