Skip to content

Commit

Permalink
Add breaking test for prototype pollution
Browse files Browse the repository at this point in the history
  • Loading branch information
chbrown committed Dec 16, 2021
1 parent 20e6244 commit 90393f9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ test('issues/44', t => {
t.deepEqual(author, {firstName: 'Chris'}, 'patch reference should not be changed')
})

test('issues/76', t => {
t.true(({} as any).polluted === undefined, 'Object prototype should not be polluted')
const value = {}
applyPatch(value, [
{op: 'add', path: '/__proto__/polluted', value: 'Hello!'}
])
t.true(({} as any).polluted === undefined, 'Object prototype should still not be polluted')
})

test('issues/78', t => {
const user = {firstName: 'Chris'}
const patch_results = applyPatch(user, [
Expand Down

0 comments on commit 90393f9

Please sign in to comment.