Skip to content

Commit

Permalink
don't assign onto __proto__
Browse files Browse the repository at this point in the history
  • Loading branch information
substack committed Mar 10, 2020
1 parent 47acf72 commit 63e7ed0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = function (args, opts) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
if (o[key] === undefined) o[key] = {};
if (o[key] === {}.__proto__) o[key] = {};
o = o[key];
});

Expand Down
1 change: 1 addition & 0 deletions test/proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ var test = require('tape');
test('proto pollution', function (t) {
var argv = parse(['--__proto__.x','123']);
t.equal({}.x, undefined);
t.equal(argv.__proto__.x, 123);
t.end();
});

0 comments on commit 63e7ed0

Please sign in to comment.