mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
fix(zipObjectDeep): prototype pollution (#4759)
This commit is contained in:
33
test/test.js
33
test/test.js
@@ -25799,6 +25799,39 @@
|
||||
});
|
||||
});
|
||||
|
||||
// zipObjectDeep prototype pollution
|
||||
['__proto__', 'constructor', 'prototype'].forEach(function (keyToTest) {
|
||||
QUnit.test('zipObjectDeep is not setting ' + keyToTest + ' on global', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
_.zipObjectDeep([keyToTest + '.a'], ['newValue']);
|
||||
// Can't access plain `a` as it's not defined and test fails
|
||||
assert.notEqual(root['a'], 'newValue');
|
||||
});
|
||||
|
||||
QUnit.test('zipObjectDeep is not overwriting ' + keyToTest + ' on vars', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
const b = 'oldValue'
|
||||
_.zipObjectDeep([keyToTest + '.b'], ['newValue']);
|
||||
assert.equal(b, 'oldValue');
|
||||
assert.notEqual(root['b'], 'newValue');
|
||||
|
||||
// ensure nothing was created
|
||||
assert.notOk(root['b']);
|
||||
});
|
||||
|
||||
QUnit.test('zipObjectDeep is not overwriting global.' + keyToTest, function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
_.zipObjectDeep([root + '.' + keyToTest + '.c'], ['newValue']);
|
||||
assert.notEqual(root['c'], 'newValue');
|
||||
|
||||
// ensure nothing was created
|
||||
assert.notOk(root['c']);
|
||||
});
|
||||
});
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.zipWith');
|
||||
|
||||
Reference in New Issue
Block a user