mirror of
https://github.com/github/codeql.git
synced 2026-05-04 05:05:12 +02:00
JS: Add getForwardingFunction() to API graphs
This commit is contained in:
@@ -347,6 +347,16 @@ module API {
|
||||
result = this.getASuccessor(Label::promisedError())
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a node representing a function that wraps the current value, forwarding arguments and
|
||||
* return values.
|
||||
*/
|
||||
cached
|
||||
Node getForwardingFunction() {
|
||||
Stages::ApiStage::ref() and
|
||||
result = this.getASuccessor(Label::forwardingFunction())
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets any class that has this value as a decorator.
|
||||
*
|
||||
@@ -901,6 +911,9 @@ module API {
|
||||
or
|
||||
lbl = Label::return() and
|
||||
ref = pred.getAnInvocation()
|
||||
or
|
||||
lbl = Label::forwardingFunction() and
|
||||
DataFlow::functionForwardingStep(pred.getALocalUse(), ref)
|
||||
)
|
||||
or
|
||||
exists(DataFlow::Node def, DataFlow::FunctionNode fn |
|
||||
@@ -1431,6 +1444,9 @@ module API {
|
||||
/** Gets the `return` edge label. */
|
||||
LabelReturn return() { any() }
|
||||
|
||||
/** Gets the label representing a function wrapper that forwards to an underlying function. */
|
||||
LabelForwardingFunction forwardingFunction() { any() }
|
||||
|
||||
/** Gets the `promised` edge label connecting a promise to its contained value. */
|
||||
LabelPromised promised() { any() }
|
||||
|
||||
@@ -1483,6 +1499,7 @@ module API {
|
||||
MkLabelDecoratedClass() or
|
||||
MkLabelDecoratedMember() or
|
||||
MkLabelDecoratedParameter() or
|
||||
MkLabelForwardingFunction() or
|
||||
MkLabelEntryPoint(API::EntryPoint e)
|
||||
|
||||
/** A label for an entry-point. */
|
||||
@@ -1566,6 +1583,11 @@ module API {
|
||||
override string toString() { result = "getReceiver()" }
|
||||
}
|
||||
|
||||
/** A label for a function that is a wrapper around another function. */
|
||||
class LabelForwardingFunction extends ApiLabel, MkLabelForwardingFunction {
|
||||
override string toString() { result = "getForwardingFunction()" }
|
||||
}
|
||||
|
||||
/** A label for a class decorated by the current value. */
|
||||
class LabelDecoratedClass extends ApiLabel, MkLabelDecoratedClass {
|
||||
override string toString() { result = "getADecoratedClass()" }
|
||||
|
||||
@@ -985,7 +985,9 @@ module Redux {
|
||||
*/
|
||||
private module ReactRedux {
|
||||
/** Gets an API node referring to the `useSelector` function. */
|
||||
API::Node useSelector() { result = API::moduleImport("react-redux").getMember("useSelector") }
|
||||
API::Node useSelector() {
|
||||
result = API::moduleImport("react-redux").getMember("useSelector").getForwardingFunction*()
|
||||
}
|
||||
|
||||
/**
|
||||
* A step out of a `useSelector` call, such as from `state.x` to the result of `useSelector(state => state.x)`.
|
||||
|
||||
@@ -277,6 +277,7 @@ module Stages {
|
||||
.getUnknownMember()
|
||||
.getInstance()
|
||||
.getReceiver()
|
||||
.getForwardingFunction()
|
||||
.getPromisedError()
|
||||
.getADecoratedClass()
|
||||
.getADecoratedMember()
|
||||
|
||||
Reference in New Issue
Block a user