Skip to content

Commit e099b94

Browse files
authored
Merge pull request #9081 from asgerf/js/global-step-refactor
Approved by erik-krogh
2 parents 28dca3f + 88b5bbe commit e099b94

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
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

javascript/ql/test/library-tests/TypeTracking/PredicateStyle.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ connection
4444
| type tracker without call steps | tst.js:120:21:120:24 | conn |
4545
| type tracker without call steps | tst.js:126:22:126:25 | conn |
4646
| type tracker without call steps | tst_conflict.js:6:38:6:77 | api.cha ... ction() |
47-
| type tracker without call steps with property MyApplication.namespace.connection | file://:0:0:0:0 | global access path |
4847
| type tracker without call steps with property conflict | tst.js:63:3:63:25 | MyAppli ... mespace |
4948
| type tracker without call steps with property conflict | tst_conflict.js:6:3:6:25 | MyAppli ... mespace |
5049
| type tracker without call steps with property connection | tst.js:62:3:62:25 | MyAppli ... mespace |

0 commit comments

Comments
 (0)