Skip to content

Commit cd9ccd4

Browse files
author
Max Schaefer
authored
Merge pull request #983 from asger-semmle/closure-global-ref
JS: add closure library in globalObjectRef
2 parents db5fbe2 + 50e8f83 commit cd9ccd4

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

javascript/ql/src/semmle/javascript/dataflow/Nodes.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ DataFlow::SourceNode globalObjectRef() {
284284
or
285285
// `require("global")`
286286
result = moduleImport("global")
287+
or
288+
// Closure library - based on AST to avoid recursion with Closure library model
289+
result = globalVarRef("goog").getAPropertyRead("global")
287290
}
288291

289292
/**

javascript/ql/test/library-tests/Nodes/globalObjectRef.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
| tst2.js:3:1:3:24 | require ... indow") |
44
| tst2.js:7:1:7:6 | global |
55
| tst2.js:8:1:8:6 | global |
6+
| tst3.js:1:1:1:0 | this |
7+
| tst3.js:3:9:3:19 | goog.global |
68
| tst.js:1:1:1:0 | this |
79
| tst.js:1:1:1:6 | window |
810
| tst.js:3:1:3:6 | window |

javascript/ql/test/library-tests/Nodes/globalVarRef.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
| document | tst2.js:2:1:2:26 | require ... ument") |
44
| document | tst.js:3:1:3:15 | window.document |
55
| document | tst.js:4:1:4:22 | window. ... ocument |
6+
| foo | tst3.js:4:1:4:5 | w.foo |
67
| global | tst2.js:7:1:7:6 | global |
78
| global | tst2.js:8:1:8:6 | global |
9+
| goog | tst3.js:1:1:1:4 | goog |
10+
| goog | tst3.js:3:9:3:12 | goog |
811
| setTimeout | tst2.js:5:1:5:12 | g.setTimeout |
912
| window | tst2.js:3:1:3:24 | require ... indow") |
1013
| window | tst.js:1:1:1:6 | window |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
goog.module('test');
2+
3+
let w = goog.global;
4+
w.foo;

0 commit comments

Comments
 (0)