From 3dbebff0f4436cf946cb6c1e6db606f4b9bded4f Mon Sep 17 00:00:00 2001 From: John Gee Date: Sat, 18 Feb 2023 19:40:02 +1300 Subject: [PATCH] [Tests] check side-effects of pollution protection --- test/proto.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/proto.js b/test/proto.js index 589efd7..668da5f 100644 --- a/test/proto.js +++ b/test/proto.js @@ -5,6 +5,20 @@ var test = require('tape'); /* eslint no-proto: 0 */ +// Not pollution as such, but verify protections working as intended. +test('trailing __proto__ key in dotted option ignored', function (t) { + var argv = parse(['--a.__proto__', 'IGNORED']); + t.deepEqual(argv.a, {}); + t.end(); +}); + +// Not pollution as such, but verify protections working as intended. +test('trailing constructor key in dotted option ignored', function (t) { + var argv = parse(['--a.constructor', 'IGNORED']); + t.deepEqual(argv.a, {}); + t.end(); +}); + test('proto pollution', function (t) { var argv = parse(['--__proto__.x', '123']); t.equal({}.x, undefined);