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) } /**