Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fixup: reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Feb 20, 2024
1 parent 927d137 commit 9bae988
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import * as bson from 'bson';

// Returns the same object but frozen and with a null prototype.
function lookupMap<T extends {}>(input: T): Readonly<T> {
return Object.freeze(Object.create(null, Object.getOwnPropertyDescriptors(input)));
return Object.freeze(
Object.create(null, Object.getOwnPropertyDescriptors(input))
);
}

function NumberLong(v: any) {
Expand Down
12 changes: 8 additions & 4 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,14 @@ it('should not allow calling functions that do not exist', function() {

for (const mode of [ParseMode.Extended, ParseMode.Strict, ParseMode.Loose]) {
it('should not allow calling functions that only exist as Object.prototype properties', function() {
expect(parse('{ date: Date.constructor("") }', {mode})).toEqual('');
expect(parse('{ date: Date.hasOwnProperty("") }', {mode})).toEqual('');
expect(parse('{ date: Date.__proto__("") }', {mode})).toEqual('');
expect(parse('{ date: Code({ toString: Date.constructor("throw null;") }) }', {mode})).toEqual('');
expect(parse('{ date: Date.constructor("") }', { mode })).toEqual('');
expect(parse('{ date: Date.hasOwnProperty("") }', { mode })).toEqual('');
expect(parse('{ date: Date.__proto__("") }', { mode })).toEqual('');
expect(
parse('{ date: Code({ toString: Date.constructor("throw null;") }) }', {
mode,
})
).toEqual('');
});
}

Expand Down

0 comments on commit 9bae988

Please sign in to comment.