JS: address comments

This commit is contained in:
Asger F
2019-01-24 11:43:38 +00:00
parent 9fd4e81f20
commit 6bcae5e7c2
7 changed files with 37 additions and 18 deletions

View File

@@ -48,7 +48,7 @@ class GoogProvide extends GoogFunctionCallStmt, GoogNamespaceRef {
GoogProvide() { getFunctionName() = "provide" }
/** Gets the identifier of the namespace created by this call. */
override string getNamespaceId() { result = getArgument(0).(ConstantString).getStringValue() }
override string getNamespaceId() { result = getArgument(0).getStringValue() }
}
/**
@@ -58,7 +58,7 @@ class GoogRequire extends GoogFunctionCall, GoogNamespaceRef {
GoogRequire() { getFunctionName() = "require" }
/** Gets the identifier of the namespace imported by this call. */
override string getNamespaceId() { result = getArgument(0).(ConstantString).getStringValue() }
override string getNamespaceId() { result = getArgument(0).getStringValue() }
}
private class GoogRequireImport extends GoogRequire, Import {
@@ -81,7 +81,7 @@ class GoogModuleDeclaration extends GoogFunctionCallStmt, GoogNamespaceRef {
}
/** Gets the identifier of the namespace imported by this call. */
override string getNamespaceId() { result = getArgument(0).(ConstantString).getStringValue() }
override string getNamespaceId() { result = getArgument(0).getStringValue() }
}
/**
@@ -93,7 +93,7 @@ class ClosureModule extends Module {
}
/**
* Gets the call to `goog.module()` or `goog.declareModuleId` in this module.
* Gets the call to `goog.module` or `goog.declareModuleId` in this module.
*/
GoogModuleDeclaration getModuleDeclaration() {
result = getAChildStmt()
@@ -121,8 +121,7 @@ class ClosureModule extends Module {
*/
Variable getExportsVariable() {
getModuleDeclaration().getFunctionName() = "module" and
result.getScope() = this.getScope() and
result.getName() = "exports"
result = getScope().getVariable("exports")
}
override predicate exports(string name, ASTNode export) {

View File

@@ -338,16 +338,17 @@ private class AnalyzedExportAssign extends AnalyzedPropertyWrite, DataFlow::Valu
* Flow analysis for assignments to the `exports` variable in a Closure module.
*/
private class AnalyzedClosureExportAssign extends AnalyzedPropertyWrite, DataFlow::ValueNode {
override AssignExpr astNode;
ClosureModule mod;
AnalyzedClosureExportAssign() {
astNode.(AssignExpr).getLhs() = mod.getExportsVariable().getAReference()
astNode.getLhs() = mod.getExportsVariable().getAReference()
}
override predicate writes(AbstractValue baseVal, string propName, DataFlow::AnalyzedNode source) {
baseVal = TAbstractModuleObject(astNode.getTopLevel()) and
propName = "exports" and
source = astNode.(AssignExpr).getRhs().flow()
source = astNode.getRhs().flow()
}
}