mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
JS: Extract predicates for ES2015/closure modules
This commit is contained in:
@@ -562,6 +562,9 @@ public class ASTExtractor {
|
||||
scopeManager.enterScope(3, moduleScopeKey, toplevelLabel);
|
||||
if (sourceType == SourceType.CLOSURE_MODULE) {
|
||||
scopeManager.addVariables("exports");
|
||||
trapwriter.addTuple("isClosureModule", toplevelLabel);
|
||||
} else {
|
||||
trapwriter.addTuple("isES2015Module", toplevelLabel);
|
||||
}
|
||||
trapwriter.addTuple("isModule", toplevelLabel);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import javascript
|
||||
*/
|
||||
class ES2015Module extends Module {
|
||||
ES2015Module() {
|
||||
isModule(this) and
|
||||
not isNodejs(this)
|
||||
isES2015Module(this)
|
||||
}
|
||||
|
||||
override ModuleScope getScope() { result.getScopeElement() = this }
|
||||
|
||||
@@ -128,6 +128,8 @@ case @toplevel.kind of
|
||||
|
||||
isModule (int tl: @toplevel ref);
|
||||
isNodejs (int tl: @toplevel ref);
|
||||
isES2015Module (int tl: @toplevel ref);
|
||||
isClosureModule (int tl: @toplevel ref);
|
||||
|
||||
// statements
|
||||
#keyset[parent, idx]
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
| tests/es6Module.js:0:0:0:0 | tests/es6Module.js |
|
||||
| tests/es6ModuleDefault.js:0:0:0:0 | tests/es6ModuleDefault.js |
|
||||
| tests/importFromEs6.js:0:0:0:0 | tests/importFromEs6.js |
|
||||
| tests/requireFromEs6.js:0:0:0:0 | tests/requireFromEs6.js |
|
||||
5
javascript/ql/test/library-tests/Closure/StrictMode.ql
Normal file
5
javascript/ql/test/library-tests/Closure/StrictMode.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import javascript
|
||||
|
||||
from TopLevel tl
|
||||
where tl.isStrict()
|
||||
select tl.getFile()
|
||||
Reference in New Issue
Block a user