JavaScript: Refactor trackUseNode to avoid bad join order.

This commit is contained in:
Max Schaefer
2020-11-24 15:13:04 +00:00
parent 7a229d9381
commit c9132ca6f8

View File

@@ -716,11 +716,27 @@ module API {
boundArgs <= 10
)
or
exists(DataFlow::TypeTracker t2 |
result = trackUseNode(nd, promisified, boundArgs, t2).track(t2, t)
exists(StepSummary summary |
t = useStep(nd, promisified, boundArgs, result, summary).append(summary)
)
}
private import semmle.javascript.dataflow.internal.StepSummary
/**
* Holds if `nd`, which is a use of an API-graph node, flows in zero or more potentially
* inter-procedural steps to some intermediate node, and then from that intermediate node to
* `res` in one step described by `summary`.
*
* This predicate exists solely to enforce a better join order in `trackUseNode` above.
*/
pragma[noinline]
private DataFlow::TypeTracker useStep(
DataFlow::Node nd, boolean promisified, int boundArgs, DataFlow::Node res, StepSummary summary
) {
StepSummary::step(trackUseNode(nd, promisified, boundArgs, result), res, summary)
}
private DataFlow::SourceNode trackUseNode(
DataFlow::SourceNode nd, boolean promisified, int boundArgs
) {