JS: Address review comments

This commit is contained in:
Asger Feldthaus
2020-10-30 16:25:30 +00:00
parent 6ab7846e81
commit c7667d372e
2 changed files with 7 additions and 7 deletions

View File

@@ -124,11 +124,6 @@ private class ComposedFunctionTaintStep extends TaintTracking::AdditionalTaintSt
override predicate step(DataFlow::Node pred, DataFlow::Node succ) { override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
exists(int fnIndex, DataFlow::FunctionNode fn | fn = composed.getOperandFunction(fnIndex) | exists(int fnIndex, DataFlow::FunctionNode fn | fn = composed.getOperandFunction(fnIndex) |
// flow out of the composed call
fnIndex = 0 and
pred = fn.getReturnNode() and
succ = this
or
// flow into the first function // flow into the first function
fnIndex = composed.getNumOperand() - 1 and fnIndex = composed.getNumOperand() - 1 and
exists(int callArgIndex | exists(int callArgIndex |
@@ -141,6 +136,11 @@ private class ComposedFunctionTaintStep extends TaintTracking::AdditionalTaintSt
pred = predFn.getReturnNode() and pred = predFn.getReturnNode() and
succ = fn.getParameter(0) succ = fn.getParameter(0)
) )
or
// flow out of the composed call
fnIndex = 0 and
pred = fn.getReturnNode() and
succ = this
) )
} }
} }

View File

@@ -734,6 +734,8 @@ private class ReactRouterLocationSource extends DOM::LocationSource::Range {
* version of that component, which we model as a direct reference to the underlying component. * version of that component, which we model as a direct reference to the underlying component.
*/ */
private DataFlow::SourceNode higherOrderComponentBuilder() { private DataFlow::SourceNode higherOrderComponentBuilder() {
// `memo(f)` returns a function that behaves as `f` but caches results
// It is sometimes used to wrap an entire functional component.
result = react().getAPropertyRead("memo") result = react().getAPropertyRead("memo")
or or
result = DataFlow::moduleMember("react-redux", "connect").getACall() result = DataFlow::moduleMember("react-redux", "connect").getACall()
@@ -760,8 +762,6 @@ private class HigherOrderComponentStep extends PreCallGraphStep {
} }
override predicate step(DataFlow::Node pred, DataFlow::Node succ) { override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
// `memo(f)` returns a function behaves as `f` but caches results
// It is sometimes used to wrap an entire functional component.
exists(DataFlow::CallNode call | exists(DataFlow::CallNode call |
call = higherOrderComponentBuilder().getACall() and call = higherOrderComponentBuilder().getACall() and
pred = call.getArgument(0) and pred = call.getArgument(0) and