JS: rename more predicates for consistency

This commit is contained in:
Asger F
2019-02-11 18:57:50 +00:00
parent 23bd9e62f0
commit 701e662bc4
3 changed files with 12 additions and 12 deletions

View File

@@ -147,7 +147,7 @@ module Closure {
* Holds if `name` is a closure namespace, including proper namespace prefixes.
*/
pragma[noinline]
predicate isLibraryNamespacePath(string name) {
predicate isClosureNamespace(string name) {
exists(string namespace | namespace = any(ClosureNamespaceRef ref).getClosureNamespace() |
name = namespace.substring(0, namespace.indexOf("."))
or
@@ -158,13 +158,13 @@ module Closure {
/**
* Gets the closure namespace path addressed by the given dataflow node, if any.
*/
string getLibraryAccessPath(DataFlow::SourceNode node) {
isLibraryNamespacePath(result) and
string getClosureNamespaceFromSourceNode(DataFlow::SourceNode node) {
isClosureNamespace(result) and
node = DataFlow::globalVarRef(result)
or
exists(DataFlow::SourceNode base, string basePath, string prop |
basePath = getLibraryAccessPath(base) and
isLibraryNamespacePath(basePath) and
basePath = getClosureNamespaceFromSourceNode(base) and
isClosureNamespace(basePath) and
node = base.getAPropertyRead(prop) and
result = basePath + "." + prop
)
@@ -174,7 +174,7 @@ module Closure {
// foo.bar = { baz() {} }
exists(DataFlow::PropWrite write |
node = write.getRhs() and
result = getWrittenLibraryAccessPath(write)
result = getWrittenClosureNamespace(write)
)
or
result = node.(ClosureNamespaceAccess).getClosureNamespace()
@@ -183,12 +183,12 @@ module Closure {
/**
* Gets the closure namespace path written to by the given property write, if any.
*/
string getWrittenLibraryAccessPath(DataFlow::PropWrite node) {
result = getLibraryAccessPath(node.getBase().getALocalSource()) + "." + node.getPropertyName()
string getWrittenClosureNamespace(DataFlow::PropWrite node) {
result = getClosureNamespaceFromSourceNode(node.getBase().getALocalSource()) + "." + node.getPropertyName()
}
/**
* Gets a dataflow node that refers to the given value exported from a Closure module.
*/
DataFlow::SourceNode moduleImport(string moduleName) { getLibraryAccessPath(result) = moduleName }
DataFlow::SourceNode moduleImport(string moduleName) { getClosureNamespaceFromSourceNode(result) = moduleName }
}

View File

@@ -1057,7 +1057,7 @@ module DataFlow {
or
exists(GlobalVarAccess va |
nd = valueNode(va.(VarUse)) and
if Closure::isLibraryNamespacePath(va.getName()) then cause = "heap" else cause = "global"
if Closure::isClosureNamespace(va.getName()) then cause = "heap" else cause = "global"
)
or
exists(Expr e | e = nd.asExpr() and cause = "call" |

View File

@@ -358,11 +358,11 @@ private class AnalyzedClosureExportAssign extends AnalyzedPropertyWrite, DataFlo
private class AnalyzedClosureGlobalAccessPath extends AnalyzedNode, AnalyzedPropertyRead {
string accessPath;
AnalyzedClosureGlobalAccessPath() { accessPath = Closure::getLibraryAccessPath(this) }
AnalyzedClosureGlobalAccessPath() { accessPath = Closure::getClosureNamespaceFromSourceNode(this) }
override AnalyzedNode localFlowPred() {
exists(DataFlow::PropWrite write |
Closure::getWrittenLibraryAccessPath(write) = accessPath and
Closure::getWrittenClosureNamespace(write) = accessPath and
result = write.getRhs()
)
or