Skip to content

Commit c9132ca

Browse files
author
Max Schaefer
committed
JavaScript: Refactor trackUseNode to avoid bad join order.
1 parent 7a229d9 commit c9132ca

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

javascript/ql/src/semmle/javascript/ApiGraphs.qll

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,27 @@ module API {
716716
boundArgs <= 10
717717
)
718718
or
719-
exists(DataFlow::TypeTracker t2 |
720-
result = trackUseNode(nd, promisified, boundArgs, t2).track(t2, t)
719+
exists(StepSummary summary |
720+
t = useStep(nd, promisified, boundArgs, result, summary).append(summary)
721721
)
722722
}
723723

724+
private import semmle.javascript.dataflow.internal.StepSummary
725+
726+
/**
727+
* Holds if `nd`, which is a use of an API-graph node, flows in zero or more potentially
728+
* inter-procedural steps to some intermediate node, and then from that intermediate node to
729+
* `res` in one step described by `summary`.
730+
*
731+
* This predicate exists solely to enforce a better join order in `trackUseNode` above.
732+
*/
733+
pragma[noinline]
734+
private DataFlow::TypeTracker useStep(
735+
DataFlow::Node nd, boolean promisified, int boundArgs, DataFlow::Node res, StepSummary summary
736+
) {
737+
StepSummary::step(trackUseNode(nd, promisified, boundArgs, result), res, summary)
738+
}
739+
724740
private DataFlow::SourceNode trackUseNode(
725741
DataFlow::SourceNode nd, boolean promisified, int boundArgs
726742
) {

0 commit comments

Comments
 (0)