Skip to content

Commit ae28fba

Browse files
committed
wip
1 parent 8a37657 commit ae28fba

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module NameResolution {
7373
*
7474
* May also include some type-specific steps in cases where this is harmless when tracking values.
7575
*/
76-
private predicate commonStep(Node node1, Node node2) {
76+
private predicate commonStep1(Node node1, Node node2) {
7777
// Import paths are part of the graph and has an incoming edge from the imported module, if found.
7878
// This ensures we can also use the PathExpr as a source when working with external (unresolved) modules.
7979
exists(Import imprt |
@@ -184,6 +184,13 @@ module NameResolution {
184184
)
185185
}
186186

187+
pragma[inline]
188+
private predicate commonStep(Node node1, Node node2) {
189+
commonStep1(node1, node2)
190+
or
191+
node2 = ValueFlow::exportsObjectRhs(node1)
192+
}
193+
187194
/**
188195
* Holds if there is a read from `node1` to `node2` that accesses the member `name`.
189196
*/
@@ -404,18 +411,18 @@ module NameResolution {
404411
or
405412
result = globalAccess(mod, "module")
406413
or
407-
commonStep(moduleObjectRef(mod), result)
414+
commonStep1(moduleObjectRef(mod), result)
408415
}
409416

410-
private Node exportsObjectRhs(Module mod) {
417+
Node exportsObjectRhs(Module mod) {
411418
exists(AssignExpr assign |
412419
assign.getLhs().(PropAccess).accesses(moduleObjectRef(mod), "exports") and
413420
result = assign.getRhs()
414421
)
415-
or
416-
commonStep(result, exportsObjectRhs(mod))
417422
}
418423

424+
private Node exportsObjectRhsPred(Module mod) { commonStep1*(result, exportsObjectRhs(mod)) }
425+
419426
private Node exportsObjectAlias(Module mod) {
420427
result = mod.getScope().getVariable("exports").getAnAccess()
421428
or
@@ -426,7 +433,7 @@ module NameResolution {
426433
or
427434
readStep(moduleObjectRef(mod), "exports", result)
428435
or
429-
result = exportsObjectRhs(mod)
436+
result = exportsObjectRhsPred(mod)
430437
or
431438
commonStep(exportsObjectAlias(mod), result)
432439
}

0 commit comments

Comments
 (0)