Skip to content

Commit 80cfab4

Browse files
committed
Backport tests
1 parent 2c95ba9 commit 80cfab4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/yargs-parser.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,4 +2375,31 @@ describe('yargs-parser', function () {
23752375
})
23762376
argv.a.should.deep.equal(['a.txt', 'b.txt'])
23772377
})
2378+
2379+
// Patching for https://snyk.io/vuln/SNYK-JS-YARGSPARSER-560381
2380+
it('should not pollute the prototype', function () {
2381+
const argv = parser(['--foo', 'bar'], {
2382+
alias: {
2383+
z: 'zoom'
2384+
},
2385+
default: {
2386+
settings: jsonPath
2387+
},
2388+
config: 'settings'
2389+
})
2390+
2391+
argv.should.have.property('herp', 'derp')
2392+
argv.should.have.property('zoom', 55)
2393+
argv.should.have.property('foo').and.deep.equal('bar')
2394+
2395+
expect({}.bbb).to.equal(undefined)
2396+
expect({}.aaa).to.equal(undefined)
2397+
})
2398+
2399+
it('should not pollute the prototype', function () {
2400+
parser(['-f.__proto__.foo', '99', '-x.y.__proto__.bar', '100', '--__proto__', '200'])
2401+
Object.keys({}.__proto__).length.should.equal(0) // eslint-disable-line
2402+
expect({}.foo).to.equal(undefined)
2403+
expect({}.bar).to.equal(undefined)
2404+
})
23782405
})

0 commit comments

Comments
 (0)