Skip to content

Commit 8c5b6b2

Browse files
committed
JS: Remove globalFlowPred()
1 parent 96d9e66 commit 8c5b6b2

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

javascript/ql/src/semmle/javascript/Closure.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,18 @@ module Closure {
259259
DataFlow::SourceNode moduleImport(string moduleName) {
260260
getClosureNamespaceFromSourceNode(result) = moduleName
261261
}
262+
263+
private class ClosureNamespaceCall extends DataFlow::InvokeNode {
264+
override Function getACallee(int imprecision) {
265+
result = super.getACallee(imprecision)
266+
or
267+
imprecision = 0 and
268+
exists(string name |
269+
GlobalAccessPath::isAssignedInUniqueFile(name) and
270+
GlobalAccessPath::fromRhs(result.flow()) = name and
271+
GlobalAccessPath::fromReference(getCalleeNode()) = name and
272+
not result.getTopLevel().isExterns()
273+
)
274+
}
275+
}
262276
}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ class AnalyzedNode extends DataFlow::Node {
4747
*/
4848
AnalyzedNode localFlowPred() { result = getAPredecessor() }
4949

50-
/**
51-
* INTERNAL. Do not use.
52-
*
53-
* Gets another data flow node whose value flows into this node in a global step
54-
* (this is, involving global variables).
55-
*/
56-
AnalyzedNode globalFlowPred() { none() }
57-
5850
/**
5951
* Gets an abstract value that this node may evaluate to at runtime.
6052
*
@@ -92,9 +84,6 @@ class AnalyzedNode extends DataFlow::Node {
9284
exists(DataFlow::Incompleteness cause |
9385
isIncomplete(cause) and result = TIndefiniteAbstractValue(cause)
9486
)
95-
or
96-
result = globalFlowPred().getALocalValue() and
97-
shouldTrackGlobally(result)
9887
}
9988

10089
/** Gets a type inferred for this node. */
@@ -295,8 +284,3 @@ private class AnalyzedAsyncFunction extends AnalyzedFunction {
295284

296285
override AbstractValue getAReturnValue() { result = TAbstractOtherObject() }
297286
}
298-
299-
/**
300-
* Holds if the given value should be propagated along `globalFlowPred()` edges.
301-
*/
302-
private predicate shouldTrackGlobally(AbstractValue value) { value instanceof AbstractCallable }

javascript/ql/src/semmle/javascript/dataflow/internal/FlowSteps.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ private module CachedSteps {
119119
predicate calls(DataFlow::InvokeNode invk, Function f) {
120120
f = invk.getACallee(0)
121121
or
122+
not f.getTopLevel().isExterns() and
122123
exists(DataFlow::ClassNode cls, string name |
123124
callResolvesToMember(invk, cls, name) and
124125
f = cls.getInstanceMethod(name).getFunction()

javascript/ql/src/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,6 @@ private class AnalyzedClosureGlobalAccessPath extends AnalyzedNode, AnalyzedProp
394394
accessPath = Closure::getClosureNamespaceFromSourceNode(this)
395395
}
396396

397-
override AnalyzedNode globalFlowPred() {
398-
exists(DataFlow::PropWrite write |
399-
Closure::getWrittenClosureNamespace(write) = accessPath and
400-
result = write.getRhs()
401-
)
402-
}
403-
404397
override predicate reads(AbstractValue base, string propName) {
405398
exists(Closure::ClosureModule mod |
406399
mod.getClosureNamespace() = accessPath and

0 commit comments

Comments
 (0)