From 820dfac48c0e7eb6527a6bc45effce35b8a612d6 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Mon, 4 Apr 2022 11:01:30 +0100 Subject: [PATCH] Manually write out a transitive closure. --- javascript/ql/lib/semmle/javascript/AMD.qll | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/javascript/ql/lib/semmle/javascript/AMD.qll b/javascript/ql/lib/semmle/javascript/AMD.qll index 07f54aa3b13..369a3e0b868 100644 --- a/javascript/ql/lib/semmle/javascript/AMD.qll +++ b/javascript/ql/lib/semmle/javascript/AMD.qll @@ -203,13 +203,22 @@ private class ConstantAmdDependencyPathElement extends PathExpr, ConstantString override string getValue() { result = getStringValue() } } +/** + * Holds if `nd` is nested inside an AMD module definition. + */ +private predicate inAmdModuleDefinition(AstNode nd) { + nd.getParent() instanceof AmdModuleDefinition + or + inAmdModuleDefinition(nd.getParent()) +} + /** * Holds if `def` is an AMD module definition in `tl` which is not * nested inside another module definition. */ private predicate amdModuleTopLevel(AmdModuleDefinition def, TopLevel tl) { def.getTopLevel() = tl and - not def.getParent+() instanceof AmdModuleDefinition + not inAmdModuleDefinition(def) } /**