JS: Remove globalFlowPred()

This commit is contained in:
Asger F
2019-07-31 16:18:45 +01:00
parent 96d9e66ced
commit 8c5b6b256b
4 changed files with 15 additions and 23 deletions

View File

@@ -259,4 +259,18 @@ module Closure {
DataFlow::SourceNode moduleImport(string moduleName) {
getClosureNamespaceFromSourceNode(result) = moduleName
}
private class ClosureNamespaceCall extends DataFlow::InvokeNode {
override Function getACallee(int imprecision) {
result = super.getACallee(imprecision)
or
imprecision = 0 and
exists(string name |
GlobalAccessPath::isAssignedInUniqueFile(name) and
GlobalAccessPath::fromRhs(result.flow()) = name and
GlobalAccessPath::fromReference(getCalleeNode()) = name and
not result.getTopLevel().isExterns()
)
}
}
}

View File

@@ -47,14 +47,6 @@ class AnalyzedNode extends DataFlow::Node {
*/
AnalyzedNode localFlowPred() { result = getAPredecessor() }
/**
* INTERNAL. Do not use.
*
* Gets another data flow node whose value flows into this node in a global step
* (this is, involving global variables).
*/
AnalyzedNode globalFlowPred() { none() }
/**
* Gets an abstract value that this node may evaluate to at runtime.
*
@@ -92,9 +84,6 @@ class AnalyzedNode extends DataFlow::Node {
exists(DataFlow::Incompleteness cause |
isIncomplete(cause) and result = TIndefiniteAbstractValue(cause)
)
or
result = globalFlowPred().getALocalValue() and
shouldTrackGlobally(result)
}
/** Gets a type inferred for this node. */
@@ -295,8 +284,3 @@ private class AnalyzedAsyncFunction extends AnalyzedFunction {
override AbstractValue getAReturnValue() { result = TAbstractOtherObject() }
}
/**
* Holds if the given value should be propagated along `globalFlowPred()` edges.
*/
private predicate shouldTrackGlobally(AbstractValue value) { value instanceof AbstractCallable }

View File

@@ -119,6 +119,7 @@ private module CachedSteps {
predicate calls(DataFlow::InvokeNode invk, Function f) {
f = invk.getACallee(0)
or
not f.getTopLevel().isExterns() and
exists(DataFlow::ClassNode cls, string name |
callResolvesToMember(invk, cls, name) and
f = cls.getInstanceMethod(name).getFunction()

View File

@@ -394,13 +394,6 @@ private class AnalyzedClosureGlobalAccessPath extends AnalyzedNode, AnalyzedProp
accessPath = Closure::getClosureNamespaceFromSourceNode(this)
}
override AnalyzedNode globalFlowPred() {
exists(DataFlow::PropWrite write |
Closure::getWrittenClosureNamespace(write) = accessPath and
result = write.getRhs()
)
}
override predicate reads(AbstractValue base, string propName) {
exists(Closure::ClosureModule mod |
mod.getClosureNamespace() = accessPath and