Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
Fix style and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
XmiliaH committed Jul 5, 2022
1 parent 3a98764 commit c01280c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/setup-sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const {
const {
get: localWeakMapGet,
set: localWeakMapSet
} = LocalWeakMap.prototype;
} = LocalWeakMap.prototype;

function localUnexpected() {
return new VMError('Should not happen');
Expand Down
12 changes: 12 additions & 0 deletions test/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,18 @@ describe('VM', () => {
const sst = vm2.run('Error.prepareStackTrace = (e,sst)=>sst;const sst = new Error().stack;Error.prepareStackTrace = undefined;sst');
assert.strictEqual(vm2.run('sst=>Object.getPrototypeOf(sst)')(sst), vm2.run('Array.prototype'));
assert.throws(()=>vm2.run('sst=>sst[0].getThis().constructor.constructor')(sst), /TypeError: Cannot read propert.*constructor/);
assert.throws(()=>vm2.run(`
const { set } = WeakMap.prototype;
WeakMap.prototype.set = function(v) {
return set.call(this, v, v);
};
Error.prepareStackTrace =
Error.prepareStackTrace =
(_, c) => c.map(c => c.getThis()).find(a => a);
const { stack } = new Error();
Error.prepareStackTrace = undefined;
stack.process
`));
});

it('Node internal prepareStackTrace attack', () => {
Expand Down

0 comments on commit c01280c

Please sign in to comment.