Skip to content

Commit 6018df3

Browse files
committed
JS: Localize MkModuleExport
1 parent 3db63af commit 6018df3

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -740,20 +740,9 @@ module API {
740740
MkRoot() or
741741
MkModuleDef(string m) { exists(MkModuleExport(m)) } or
742742
MkModuleUse(string m) { exists(MkModuleImport(m)) } or
743-
MkModuleExport(string m) {
744-
exists(Module mod | mod = importableModule(m) |
745-
// exclude modules that don't actually export anything
746-
exports(m, _)
747-
or
748-
exports(m, _, _)
749-
or
750-
exists(NodeModule nm | nm = mod |
751-
exists(Ssa::implicitInit([nm.getModuleVariable(), nm.getExportsVariable()]))
752-
)
753-
)
754-
} or
755743
MkModuleImport(string m) {
756744
imports(_, m)
745+
MkModuleExport(string m) { isDeclaredPackageName(m) } or
757746
or
758747
any(TypeAnnotation n).hasUnderlyingType(m, _)
759748
} or
@@ -1949,3 +1938,8 @@ private Module importableModule(string m) {
19491938
m = pkg.getPackageName()
19501939
)
19511940
}
1941+
1942+
overlay[local]
1943+
private predicate isDeclaredPackageName(string m) {
1944+
m = any(PackageJson pkg).getDeclaredPackageName()
1945+
}

0 commit comments

Comments
 (0)