Skip to content

Commit c8823fa

Browse files
committed
JS: change charpred of ClosureModule to be AST-based
1 parent d1607f7 commit c8823fa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

javascript/ql/src/semmle/javascript/Closure.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ module Closure {
6868
* A module using the Closure module system, declared using `goog.module()` or `goog.declareModuleId()`.
6969
*/
7070
class ClosureModule extends Module {
71-
ClosureModule() { any(ClosureModuleDeclaration decl).getTopLevel() = this }
71+
ClosureModule() {
72+
// Use AST-based predicate to cut recursive dependencies.
73+
exists(MethodCallExpr call |
74+
getAStmt().(ExprStmt).getExpr() = call and
75+
call.getReceiver().(GlobalVarAccess).getName() = "goog" and
76+
(call.getMethodName() = "module" or call.getMethodName() = "declareModuleId")
77+
)
78+
}
7279

7380
/**
7481
* Gets the call to `goog.module` or `goog.declareModuleId` in this module.

0 commit comments

Comments
 (0)