File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 39903990 var key = toKey(path[index]),
39913991 newValue = value;
39923992
3993+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
3994+ return object;
3995+ }
3996+
39933997 if (index != lastIndex) {
39943998 var objValue = nested[key];
39953999 newValue = customizer ? customizer(objValue, key, nested) : undefined;
Original file line number Diff line number Diff line change 2579925799 });
2580025800 });
2580125801
25802+ // zipObjectDeep prototype pollution
25803+ ['__proto__', 'constructor', 'prototype'].forEach(function (keyToTest) {
25804+ QUnit.test('zipObjectDeep is not setting ' + keyToTest + ' on global', function (assert) {
25805+ assert.expect(1);
25806+
25807+ _.zipObjectDeep([keyToTest + '.a'], ['newValue']);
25808+ // Can't access plain `a` as it's not defined and test fails
25809+ assert.notEqual(root['a'], 'newValue');
25810+ });
25811+
25812+ QUnit.test('zipObjectDeep is not overwriting ' + keyToTest + ' on vars', function (assert) {
25813+ assert.expect(3);
25814+
25815+ const b = 'oldValue'
25816+ _.zipObjectDeep([keyToTest + '.b'], ['newValue']);
25817+ assert.equal(b, 'oldValue');
25818+ assert.notEqual(root['b'], 'newValue');
25819+
25820+ // ensure nothing was created
25821+ assert.notOk(root['b']);
25822+ });
25823+
25824+ QUnit.test('zipObjectDeep is not overwriting global.' + keyToTest, function (assert) {
25825+ assert.expect(2);
25826+
25827+ _.zipObjectDeep([root + '.' + keyToTest + '.c'], ['newValue']);
25828+ assert.notEqual(root['c'], 'newValue');
25829+
25830+ // ensure nothing was created
25831+ assert.notOk(root['c']);
25832+ });
25833+ });
25834+
2580225835 /*--------------------------------------------------------------------------*/
2580325836
2580425837 QUnit.module('lodash.zipWith');
You can’t perform that action at this time.
0 commit comments