JS: use PropWrite in exports() predicate

This commit is contained in:
Asger F
2019-01-25 10:32:57 +00:00
parent c707935841
commit df88534b36

View File

@@ -118,13 +118,14 @@ module Closure {
}
override predicate exports(string name, ASTNode export) {
// exports.foo = bar
export.(AssignExpr).getLhs().(PropAccess).accesses(getExportsVariable().getAnAccess(), name)
or
// exports = { foo: bar }
exists(VarDef def |
def.getTarget() = getExportsVariable().getAReference() and
def.getSource().(ObjectExpr).getPropertyByName(name) = export
exists(DataFlow::PropWrite write, Expr base |
write.getAstNode() = export and
write.writes(base.flow(), name, _) and
(
base = getExportsVariable().getAReference()
or
base = getExportsVariable().getAnAssignedExpr()
)
)
}
}