Skip to content

Commit c4d597d

Browse files
committed
JS: Enumerate type-tracking steps through global access paths
1 parent 66a9759 commit c4d597d

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/StepSummary.qll

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ private module Cached {
5656
exists(DataFlow::Node mid | pred.flowsTo(mid) | StepSummary::smallstep(mid, succ, summary))
5757
}
5858

59+
pragma[nomagic]
60+
private DataFlow::Node getAGlobalStepPredecessor(string global) {
61+
result = AccessPath::getAnAssignmentTo(global) and
62+
AccessPath::isAssignedInUniqueFile(global)
63+
}
64+
65+
pragma[nomagic]
66+
private DataFlow::Node getAGlobalStepSuccessor(string global) {
67+
result = AccessPath::getAReferenceTo(global) and
68+
AccessPath::isAssignedInUniqueFile(global)
69+
}
70+
5971
/**
6072
* INTERNAL: Use `TypeBackTracker.smallstep()` instead.
6173
*/
@@ -106,20 +118,10 @@ private module Cached {
106118
SharedTypeTrackingStep::step(pred, succ) and
107119
summary = LevelStep()
108120
or
109-
// Store to global access path
110-
exists(string name |
111-
pred = AccessPath::getAnAssignmentTo(name) and
112-
AccessPath::isAssignedInUniqueFile(name) and
113-
succ = DataFlow::globalAccessPathRootPseudoNode() and
114-
summary = StoreStep(name)
115-
)
116-
or
117-
// Load from global access path
118-
exists(string name |
119-
succ = AccessPath::getAReferenceTo(name) and
120-
AccessPath::isAssignedInUniqueFile(name) and
121-
pred = DataFlow::globalAccessPathRootPseudoNode() and
122-
summary = LoadStep(name)
121+
summary = LevelStep() and
122+
exists(string global |
123+
pred = getAGlobalStepPredecessor(global) and
124+
succ = getAGlobalStepSuccessor(global)
123125
)
124126
or
125127
// Store to non-global access path

0 commit comments

Comments
 (0)