Skip to content

Commit

Permalink
Add Blob to allowed list of globals (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
appurva21 authored Sep 25, 2024
1 parent 10cb59c commit af65aea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ unreleased:
- >-
GH-676 Updated allowed globals list to include:
URL, Encoding, Cryptographic, and Stream APIs
- GH-683 Updated allowed globals list to include `Blob`
chores:
- GH-677 Updated ESLint rules
- GH-677 Updated dependencies
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ These are the list of globals available to scripts in the scope
]
```

### File:
```json
[
"Blob"
]
```

### Cryptography:
```json
[
Expand Down
4 changes: 4 additions & 0 deletions lib/allowed-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module.exports = [
'TextDecoder', 'TextDecoderStream',
'TextEncoder', 'TextEncoderStream',

// File
// TODO: Add `File` class once support for node < v20 is dropped
'Blob',

// Cryptography
'Crypto', 'CryptoKey',
'crypto', 'SubtleCrypto',
Expand Down
25 changes: 13 additions & 12 deletions test/unit/scope-globals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ describe('scope module globals', function () {
scope.exec(`
var availableGlobals = Object.getOwnPropertyNames(this).sort();
expect(availableGlobals).eql(['Array', 'ArrayBuffer', 'Atomics', 'atob', 'BigInt', 'BigInt64Array',
'BigUint64Array', 'Boolean', 'ByteLengthQueuingStrategy', 'CompressionStream', 'CountQueuingStrategy',
'btoa', 'Crypto', 'CryptoKey', 'crypto', 'DataView', 'Date', 'DecompressionStream', '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', 'ReadableByteStreamController', 'ReadableStream', 'ReadableStreamBYOBReader',
'ReadableStreamBYOBRequest', 'ReadableStreamDefaultController', 'ReadableStreamDefaultReader',
'ReferenceError', 'Reflect', 'RegExp', 'Set', 'SharedArrayBuffer', 'String', 'SubtleCrypto', 'Symbol',
'SyntaxError', 'TextDecoder', 'TextDecoderStream', 'TextEncoder', 'TextEncoderStream',
'TransformStream', 'TransformStreamDefaultController', 'TypeError', 'Uint8Array', 'Uint8ClampedArray',
'Uint16Array', 'Uint32Array', 'undefined', 'unescape', 'URIError', 'URL', 'URLSearchParams', 'WeakMap',
'WeakSet', 'WritableStream', 'WritableStreamDefaultController', 'WritableStreamDefaultWriter',
'BigUint64Array', 'Blob', 'Boolean', 'ByteLengthQueuingStrategy', 'CompressionStream',
'CountQueuingStrategy', 'btoa', 'Crypto', 'CryptoKey', 'crypto', 'DataView', 'Date',
'DecompressionStream', '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', 'ReadableByteStreamController',
'ReadableStream', 'ReadableStreamBYOBReader', 'ReadableStreamBYOBRequest',
'ReadableStreamDefaultController', 'ReadableStreamDefaultReader', 'ReferenceError', 'Reflect', 'RegExp',
'Set', 'SharedArrayBuffer', 'String', 'SubtleCrypto', 'Symbol', 'SyntaxError', 'TextDecoder',
'TextDecoderStream', 'TextEncoder', 'TextEncoderStream', 'TransformStream',
'TransformStreamDefaultController', 'TypeError', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array',
'Uint32Array', 'undefined', 'unescape', 'URIError', 'URL', 'URLSearchParams', 'WeakMap', 'WeakSet',
'WritableStream', 'WritableStreamDefaultController', 'WritableStreamDefaultWriter',
'expect' // special for test
].sort())
`, done);
Expand Down

0 comments on commit af65aea

Please sign in to comment.