JS: Extend getABulkExportedNode and use it in PackageExports

This commit is contained in:
Asger Feldthaus
2021-09-01 13:04:57 +02:00
parent cce3c0256e
commit 4b1f918feb
3 changed files with 19 additions and 0 deletions

View File

@@ -313,6 +313,19 @@ class AmdModule extends Module {
name = pwn.getPropertyName()
)
}
override DataFlow::Node getABulkExportedNode() {
// Assigned to `module.exports` via the factory's `module` parameter
exists(AbstractModuleObject m, DataFlow::PropWrite write |
m.getModule() = this and
write.getPropertyName() = "exports" and
write.getBase().analyze().getAValue() = m and
result = write.getRhs()
)
or
// Returned from factory function
result = getDefine().getModuleExpr().flow()
}
}
/**

View File

@@ -177,6 +177,10 @@ module Closure {
)
)
}
override DataFlow::Node getABulkExportedNode() {
result = getExportsVariable().getAnAssignedExpr().flow()
}
}
/**

View File

@@ -171,4 +171,6 @@ private DataFlow::Node getAnExportFromModule(Module mod) {
result.analyze().getAValue() = mod.(AmdModule).getDefine().getAModuleExportsValue()
or
result = mod.getAnExportedValue(_)
or
result = mod.getABulkExportedNode()
}