Skip to content

Commit

Permalink
Update allowed globals
Browse files Browse the repository at this point in the history
  • Loading branch information
appurva21 committed Sep 23, 2024
1 parent e8d30d7 commit b0182a1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
unreleased:
new features:
- >-
GH-676 Updated allowed globals list to include:
atob, btoa, Crypto, CryptoKey, crypto, SubtleCrypto,
TextDecoder, TextEncoder, URL, and URLSearchParams
2.2.0:
date: 2024-03-13
new features:
Expand Down
40 changes: 22 additions & 18 deletions lib/allowed-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@
* @type {String[]}
*/
module.exports = [
'Array', 'ArrayBuffer', 'Atomics',
'BigInt', 'BigInt64Array', 'BigUint64Array',
'Boolean', 'DataView', 'Date',
'Error', 'EvalError', 'Float32Array',
'Float64Array', 'Function', 'Infinity',
'Int16Array', 'Int32Array', 'Int8Array',
'JSON', 'Map', 'Math',
'NaN', 'Number', 'Object',
'Promise', 'Proxy', 'RangeError',
'ReferenceError', 'Reflect', 'RegExp',
'Set', 'SharedArrayBuffer', 'String',
'Symbol', 'SyntaxError', 'TypeError',
'URIError', 'Uint16Array', 'Uint32Array',
'Uint8Array', 'Uint8ClampedArray', 'WeakMap',
'WeakSet', 'decodeURI', 'decodeURIComponent',
'encodeURI', 'encodeURIComponent', 'escape',
'isFinite', 'isNaN', 'parseFloat',
'parseInt', 'undefined', 'unescape'
'Array', 'ArrayBuffer', 'Atomics',
'atob', 'BigInt', 'BigInt64Array',
'BigUint64Array', 'Boolean', 'btoa',
'Crypto', 'CryptoKey', 'crypto',
'DataView', 'Date', 'Error',
'EvalError', 'Float32Array', 'Float64Array',
'Function', 'Infinity', 'Int16Array',
'Int32Array', 'Int8Array', 'JSON',
'Map', 'Math', 'NaN',
'Number', 'Object', 'Promise',
'Proxy', 'RangeError', 'ReferenceError',
'Reflect', 'RegExp', 'Set',
'SharedArrayBuffer', 'String', 'SubtleCrypto',
'Symbol', 'SyntaxError', 'TextEncoder',
'TextDecoder', 'TypeError', 'URIError',
'URL', 'URLSearchParams', 'Uint16Array',
'Uint32Array', 'Uint8Array', 'Uint8ClampedArray',
'WeakMap', 'WeakSet', 'decodeURI',
'decodeURIComponent', 'encodeURI', 'encodeURIComponent',
'escape', 'isFinite', 'isNaN',
'parseFloat', 'parseInt', 'undefined',
'unescape'
];
18 changes: 9 additions & 9 deletions test/unit/scope-globals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ describe('scope module globals', function () {
it('should be limited to a known subset in context', function (done) {
scope.exec(`
var availableGlobals = Object.getOwnPropertyNames(this).sort();
expect(availableGlobals).eql(['Array', 'ArrayBuffer', 'Atomics', 'BigInt', 'BigInt64Array',
'BigUint64Array', 'Boolean', 'DataView', 'Date', 'decodeURI', 'decodeURIComponent', 'encodeURI',
'encodeURIComponent', 'Error', 'escape', 'EvalError', 'Float32Array', 'Float64Array', 'Function',
'Infinity', 'Int8Array', 'Int16Array', 'Int32Array', 'isFinite', 'isNaN', 'JSON', 'Map', 'Math', 'NaN',
'Number', 'Object', 'parseFloat', 'parseInt', 'Proxy', 'Promise', 'RangeError', 'ReferenceError',
'Reflect', 'RegExp', 'Set', 'SharedArrayBuffer', 'String', 'Symbol', 'SyntaxError', 'TypeError',
'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'undefined', 'unescape', 'URIError',
'WeakMap', 'WeakSet',
expect(availableGlobals).eql(['Array', 'ArrayBuffer', 'Atomics', 'atob', 'BigInt', 'BigInt64Array',
'BigUint64Array', 'Boolean', 'btoa', 'Crypto', 'CryptoKey', 'crypto', 'DataView', 'Date', 'decodeURI',
'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'Error', 'escape', 'EvalError', 'Float32Array',
'Float64Array', 'Function', 'Infinity', 'Int8Array', 'Int16Array', 'Int32Array', 'isFinite', 'isNaN',
'JSON','Map', 'Math', 'NaN', 'Number', 'Object', 'parseFloat', 'parseInt', 'Proxy', 'Promise',
'RangeError', 'ReferenceError', 'Reflect', 'RegExp', 'Set', 'SharedArrayBuffer', 'String',
'SubtleCrypto', 'Symbol', 'SyntaxError', 'TextDecoder', 'TextEncoder', 'TypeError', 'Uint8Array',
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'undefined', 'unescape', 'URIError', 'URL',
'URLSearchParams', 'WeakMap', 'WeakSet',
'expect' // special for test
].sort())
`, done);
Expand Down

0 comments on commit b0182a1

Please sign in to comment.