Skip to content

Commit db32dc2

Browse files
author
Max Schaefer
committed
JavaScript: Generalise code that assumes imports only appear at the toplevel.
1 parent f05e777 commit db32dc2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

javascript/ql/src/semmle/javascript/ES2015Modules.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ES2015Module extends Module {
2727

2828
/** Gets an export declaration in this module. */
2929
ExportDeclaration getAnExport() {
30-
result.getContainer() = this
30+
result.getTopLevel() = this
3131
}
3232

3333
override Module getAnImportedModule() {
@@ -55,7 +55,7 @@ class ES2015Module extends Module {
5555
/** An import declaration. */
5656
class ImportDeclaration extends Stmt, Import, @importdeclaration {
5757
override ES2015Module getEnclosingModule() {
58-
result = getContainer()
58+
result = getTopLevel()
5959
}
6060

6161
override PathExprInModule getImportedPath() {
@@ -254,7 +254,7 @@ class BulkReExportDeclaration extends ReExportDeclaration, @exportalldeclaration
254254
* but we ignore this subtlety.
255255
*/
256256
private predicate isShadowedFromBulkExport(BulkReExportDeclaration reExport, string name) {
257-
exists (ExportNamedDeclaration other | other.getContainer() = reExport.getEnclosingModule() |
257+
exists (ExportNamedDeclaration other | other.getTopLevel() = reExport.getEnclosingModule() |
258258
other.getAnExportedDecl().getName() = name
259259
or
260260
other.getASpecifier().getExportedName() = name)

javascript/ql/src/semmle/javascript/dataflow/internal/InterModuleTypeInference.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ private class AnalyzedExportAssign extends AnalyzedPropertyWrite, DataFlow::Valu
301301
}
302302

303303
override predicate writes(AbstractValue baseVal, string propName, DataFlow::AnalyzedNode source) {
304-
baseVal = TAbstractModuleObject(exportAssign.getContainer()) and
304+
baseVal = TAbstractModuleObject(exportAssign.getTopLevel()) and
305305
propName = "exports" and
306306
source = this
307307
}

0 commit comments

Comments
 (0)