Skip to content

Commit 13c01a5

Browse files
author
substack
committed
more failing proto pollution tests
1 parent f34df07 commit 13c01a5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/proto.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,33 @@ test('proto pollution', function (t) {
55
var argv = parse(['--__proto__.x','123']);
66
t.equal({}.x, undefined);
77
t.equal(argv.__proto__.x, 123);
8+
t.equal(argv.x, undefined);
9+
t.end();
10+
});
11+
12+
test('proto pollution (array)', function (t) {
13+
var argv = parse(['--x','4','--x','5','--x.__proto__.z','789']);
14+
t.equal({}.z, undefined);
15+
t.deepEqual(argv.x, [4,5]);
16+
t.equal(argv.x.z, undefined);
17+
t.equal(argv.x.__proto__.z, 789);
18+
t.end();
19+
});
20+
21+
test('proto pollution (number)', function (t) {
22+
var argv = parse(['--x','5','--x.__proto__.z','100']);
23+
t.equal({}.z, undefined);
24+
t.equal((4).z, undefined);
25+
t.equal(argv.x, 5);
26+
t.equal(argv.x.z, undefined);
27+
t.end();
28+
});
29+
30+
test('proto pollution (string)', function (t) {
31+
var argv = parse(['--x','abc','--x.__proto__.z','def']);
32+
t.equal({}.z, undefined);
33+
t.equal('...'.z, undefined);
34+
t.equal(argv.x, 'abc');
35+
t.equal(argv.x.z, undefined);
836
t.end();
937
});

0 commit comments

Comments
 (0)