Skip to content

Commit 6a78e37

Browse files
author
Max Schaefer
committed
JavaScript: Make AMD dependencies Imports.
1 parent fcf04ab commit 6a78e37

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

javascript/ql/src/semmle/javascript/AMD.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,23 @@ private predicate amdModuleTopLevel(AMDModuleDefinition def, TopLevel tl) {
196196
not def.getParent+() instanceof AMDModuleDefinition
197197
}
198198

199+
/**
200+
* An AMD dependency, viewed as an import.
201+
*/
202+
private class AmdDependencyImport extends Import {
203+
AmdDependencyImport() {
204+
this = any(AMDModuleDefinition def).getADependency()
205+
}
206+
207+
override Module getEnclosingModule() {
208+
this = result.(AMDModule).getDefine().getADependency()
209+
}
210+
211+
override PathExpr getImportedPath() {
212+
result = this
213+
}
214+
}
215+
199216
/**
200217
* An AMD-style module.
201218
*/

javascript/ql/src/semmle/javascript/Modules.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ abstract class Module extends TopLevel {
9292
}
9393

9494
/**
95-
* An import in a module, which may either be an ECMAScript 2015-style
96-
* `import` statement or a CommonJS-style `require` import.
95+
* An import in a module, which may be an ECMAScript 2015-style
96+
* `import` statement, a CommonJS-style `require` import, or an AMD dependency.
9797
*/
9898
abstract class Import extends ASTNode {
9999
/** Gets the module in which this import appears. */

0 commit comments

Comments
 (0)