Skip to content

Commit 8e52528

Browse files
author
Max Schaefer
committed
JavaScript: Refactor reachableFromInput to improve join.
1 parent 993345f commit 8e52528

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,24 @@ private predicate reachableFromInput(
570570
callInputStep(f, invk, input, nd, cfg) and
571571
summary = PathSummary::level()
572572
or
573-
exists(DataFlow::Node mid, PathSummary oldSummary, PathSummary newSummary |
573+
exists(DataFlow::Node mid, PathSummary oldSummary |
574574
reachableFromInput(f, invk, input, mid, cfg, oldSummary) and
575-
flowStep(mid, cfg, nd, newSummary) and
576-
summary = oldSummary.append(newSummary)
575+
appendStep(mid, cfg, oldSummary, nd, summary)
576+
)
577+
}
578+
579+
/**
580+
* Holds if there is a step from `pred` to `succ` under `cfg` that can be appended
581+
* to a path represented by `oldSummary` yielding a path represented by `newSummary`.
582+
*/
583+
pragma[noinline]
584+
private predicate appendStep(
585+
DataFlow::Node pred, DataFlow::Configuration cfg, PathSummary oldSummary, DataFlow::Node succ,
586+
PathSummary newSummary
587+
) {
588+
exists(PathSummary stepSummary |
589+
flowStep(pred, cfg, succ, stepSummary) and
590+
newSummary = oldSummary.append(stepSummary)
577591
)
578592
}
579593

0 commit comments

Comments
 (0)