Skip to content

Commit c19ca78

Browse files
committed
JS: Replace Closure's storeToVariable predicate with more exportsObjectRhs tuples
1 parent ddd65d4 commit c19ca78

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ module NameResolution {
315315
assign.getLhs().(PropAccess).accesses(moduleObjectRef(mod), "exports") and
316316
result = assign.getRhs()
317317
)
318+
or
319+
result = mod.(Closure::ClosureModule).getExportsVariable().getAnAssignedExpr()
318320
}
319321

320322
/** Gets a node that is bulk-exported from the given module. */
@@ -458,8 +460,6 @@ module NameResolution {
458460
result = enum.getMemberByName(name).getIdentifier()
459461
)
460462
or
461-
storeToVariable(result, name, mod.(Closure::ClosureModule).getExportsVariable())
462-
or
463463
exists(DynamicImportExpr imprt |
464464
mod = imprt and
465465
name = "$$promise-content" and
@@ -469,21 +469,6 @@ module NameResolution {
469469
storeToExports(result, mod, name)
470470
}
471471

472-
/**
473-
* Holds if `value` is stored in `target.prop`. Only needs to recognise assignments
474-
* that are also recognised by JSDoc tooling such as the Closure compiler.
475-
*/
476-
private predicate storeToVariable(Expr value, string prop, LocalVariableLike target) {
477-
exists(AssignExpr assign |
478-
// target.name = value
479-
assign.getLhs().(PropAccess).accesses(target.getAnAccess(), prop) and
480-
value = assign.getRhs()
481-
)
482-
or
483-
// target = { name: value }
484-
value = target.getAnAssignedExpr().(ObjectExpr).getPropertyByName(prop).getInit()
485-
}
486-
487472
/** Steps that only apply for this configuration. */
488473
private predicate specificStep(Node node1, Node node2) {
489474
exists(LexicalName var | S::isRelevantVariable(var) |

0 commit comments

Comments
 (0)