Skip to content

Commit 6f15818

Browse files
committed
JS: Add self as global object alias
1 parent 8b60314 commit 6f15818

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-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
@@ -304,6 +304,9 @@ DataFlow::SourceNode globalObjectRef() {
304304
// Node.js
305305
result = globalVarRef("global")
306306
or
307+
// DOM and service workers
308+
result = globalVarRef("self")
309+
or
307310
// `require("global")`
308311
result = moduleImport("global")
309312
or

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
| tst.js:3:1:3:6 | window |
1111
| tst.js:4:1:4:6 | window |
1212
| tst.js:4:1:4:13 | window.window |
13+
| tst.js:5:1:5:4 | self |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
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+
| document | tst.js:5:1:5:13 | self.document |
67
| foo | tst3.js:4:1:4:5 | w.foo |
78
| global | tst2.js:7:1:7:6 | global |
89
| global | tst2.js:8:1:8:6 | global |
910
| goog | tst3.js:1:1:1:4 | goog |
1011
| goog | tst3.js:3:9:3:12 | goog |
12+
| self | tst.js:5:1:5:4 | self |
1113
| setTimeout | tst2.js:5:1:5:12 | g.setTimeout |
1214
| window | tst2.js:3:1:3:24 | require ... indow") |
1315
| window | tst.js:1:1:1:6 | window |

javascript/ql/test/library-tests/Nodes/tst.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ window;
22
this;
33
window.document;
44
window.window.document;
5+
self.document;

0 commit comments

Comments
 (0)