JS: Resolve simple calls based on qualified name

This commit is contained in:
Asger F
2019-08-01 13:43:31 +01:00
parent ca71d3117e
commit 221d94961a
2 changed files with 8 additions and 14 deletions

View File

@@ -244,18 +244,4 @@ 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

@@ -127,6 +127,14 @@ private module CachedSteps {
invk = cls.getAClassReference().getAMethodCall(name) and
f = cls.getStaticMethod(name).getFunction()
)
or
// Call from `foo.bar.baz()` to `foo.bar.baz = function()`
not f.getTopLevel().isExterns() and
exists(string name |
GlobalAccessPath::isAssignedInUniqueFile(name) and
GlobalAccessPath::fromRhs(f.flow()) = name and
GlobalAccessPath::fromReference(invk.getCalleeNode()) = name
)
}
/**