Skip to content

Commit d39d431

Browse files
committed
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().
1 parent c9c7ccf commit d39d431

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

javascript/ql/lib/semmle/javascript/ES2015Modules.qll

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ class ImportDeclaration extends Stmt, Import, @import_declaration {
9494

9595
override PathExpr getImportedPath() { result = this.getChildExpr(-1) }
9696

97+
/**
98+
* INTERNAL USE ONLY. DO NOT USE.
99+
*/
100+
string getRawImportPath() { result = this.getChildExpr(-1).getStringValue() }
101+
97102
/**
98103
* Gets the object literal passed as part of the `with` (or `assert`) clause in this import declaration.
99104
*

javascript/ql/lib/semmle/javascript/NodeJS.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private class RequireVariable extends Variable {
242242
private predicate moduleInFile(Module m, File f) { m.getFile() = f }
243243

244244
private predicate isModuleModule(EarlyStageNode nd) {
245-
exists(ImportDeclaration imp | imp.getImportedPath().getValue() = "module" |
245+
exists(ImportDeclaration imp | imp.getRawImportPath() = "module" |
246246
nd = TDestructuredModuleImportNode(imp)
247247
or
248248
nd = TValueNode(imp.getASpecifier().(ImportNamespaceSpecifier))
@@ -268,7 +268,7 @@ private predicate isCreateRequire(EarlyStageNode nd) {
268268
)
269269
or
270270
exists(ImportDeclaration decl, NamedImportSpecifier spec |
271-
decl.getImportedPath().getValue() = "module" and
271+
decl.getRawImportPath() = "module" and
272272
spec = decl.getASpecifier() and
273273
spec.getImportedName() = "createRequire" and
274274
nd = TValueNode(spec)

0 commit comments

Comments
 (0)