mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JavaScript: Generalise code that assumes imports only appear at the toplevel.
This commit is contained in:
@@ -27,7 +27,7 @@ class ES2015Module extends Module {
|
||||
|
||||
/** Gets an export declaration in this module. */
|
||||
ExportDeclaration getAnExport() {
|
||||
result.getContainer() = this
|
||||
result.getTopLevel() = this
|
||||
}
|
||||
|
||||
override Module getAnImportedModule() {
|
||||
@@ -55,7 +55,7 @@ class ES2015Module extends Module {
|
||||
/** An import declaration. */
|
||||
class ImportDeclaration extends Stmt, Import, @importdeclaration {
|
||||
override ES2015Module getEnclosingModule() {
|
||||
result = getContainer()
|
||||
result = getTopLevel()
|
||||
}
|
||||
|
||||
override PathExprInModule getImportedPath() {
|
||||
@@ -254,7 +254,7 @@ class BulkReExportDeclaration extends ReExportDeclaration, @exportalldeclaration
|
||||
* but we ignore this subtlety.
|
||||
*/
|
||||
private predicate isShadowedFromBulkExport(BulkReExportDeclaration reExport, string name) {
|
||||
exists (ExportNamedDeclaration other | other.getContainer() = reExport.getEnclosingModule() |
|
||||
exists (ExportNamedDeclaration other | other.getTopLevel() = reExport.getEnclosingModule() |
|
||||
other.getAnExportedDecl().getName() = name
|
||||
or
|
||||
other.getASpecifier().getExportedName() = name)
|
||||
|
||||
@@ -301,7 +301,7 @@ private class AnalyzedExportAssign extends AnalyzedPropertyWrite, DataFlow::Valu
|
||||
}
|
||||
|
||||
override predicate writes(AbstractValue baseVal, string propName, DataFlow::AnalyzedNode source) {
|
||||
baseVal = TAbstractModuleObject(exportAssign.getContainer()) and
|
||||
baseVal = TAbstractModuleObject(exportAssign.getTopLevel()) and
|
||||
propName = "exports" and
|
||||
source = this
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user