mirror of
https://github.com/github/codeql.git
synced 2026-04-20 06:24:03 +02:00
JS: Remove a dependency on getImportedPath()
To avoid negative recursion in some upcoming changes, we want to make sure the modeling of createRequire does not depend on getImportedPath().
This commit is contained in:
@@ -94,6 +94,11 @@ class ImportDeclaration extends Stmt, Import, @import_declaration {
|
||||
|
||||
override PathExpr getImportedPath() { result = this.getChildExpr(-1) }
|
||||
|
||||
/**
|
||||
* INTERNAL USE ONLY. DO NOT USE.
|
||||
*/
|
||||
string getRawImportPath() { result = this.getChildExpr(-1).getStringValue() }
|
||||
|
||||
/**
|
||||
* Gets the object literal passed as part of the `with` (or `assert`) clause in this import declaration.
|
||||
*
|
||||
|
||||
@@ -242,7 +242,7 @@ private class RequireVariable extends Variable {
|
||||
private predicate moduleInFile(Module m, File f) { m.getFile() = f }
|
||||
|
||||
private predicate isModuleModule(EarlyStageNode nd) {
|
||||
exists(ImportDeclaration imp | imp.getImportedPath().getValue() = "module" |
|
||||
exists(ImportDeclaration imp | imp.getRawImportPath() = "module" |
|
||||
nd = TDestructuredModuleImportNode(imp)
|
||||
or
|
||||
nd = TValueNode(imp.getASpecifier().(ImportNamespaceSpecifier))
|
||||
@@ -268,7 +268,7 @@ private predicate isCreateRequire(EarlyStageNode nd) {
|
||||
)
|
||||
or
|
||||
exists(ImportDeclaration decl, NamedImportSpecifier spec |
|
||||
decl.getImportedPath().getValue() = "module" and
|
||||
decl.getRawImportPath() = "module" and
|
||||
spec = decl.getASpecifier() and
|
||||
spec.getImportedName() = "createRequire" and
|
||||
nd = TValueNode(spec)
|
||||
|
||||
Reference in New Issue
Block a user