Skip to content

Commit 90393f9

Browse files
committed
Add breaking test for prototype pollution
1 parent 20e6244 commit 90393f9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/issues.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ test('issues/44', t => {
238238
t.deepEqual(author, {firstName: 'Chris'}, 'patch reference should not be changed')
239239
})
240240

241+
test('issues/76', t => {
242+
t.true(({} as any).polluted === undefined, 'Object prototype should not be polluted')
243+
const value = {}
244+
applyPatch(value, [
245+
{op: 'add', path: '/__proto__/polluted', value: 'Hello!'}
246+
])
247+
t.true(({} as any).polluted === undefined, 'Object prototype should still not be polluted')
248+
})
249+
241250
test('issues/78', t => {
242251
const user = {firstName: 'Chris'}
243252
const patch_results = applyPatch(user, [

0 commit comments

Comments
 (0)