Skip to content

Commit cc98de5

Browse files
committed
JS: Handle require() and the like
1 parent 01b1e8a commit cc98de5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

javascript/ql/lib/semmle/javascript/internal/NameResolution.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ module NameResolution {
102102
node2 = exprt.getImportedPath()
103103
)
104104
or
105+
// For imports like `require()` that are just expressions evaluating to the imported module.
106+
exists(Import imprt |
107+
imprt.getImportedModuleNode() = DataFlow::valueNode(imprt) and
108+
node1 = imprt.getImportedPathExpr() and
109+
node2 = imprt
110+
)
111+
or
105112
exists(ImportNamespaceSpecifier spec |
106113
node1 = spec.getImportDeclaration().getImportedPathExpr() and
107114
node2 = spec.getLocal()

0 commit comments

Comments
 (0)