Skip to content

Commit a50ae33

Browse files
v1.4.1
1 parent a376c83 commit a50ae33

3 files changed

Lines changed: 68 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.4.1 (Jan 29, 2021)
2+
3+
- Update extend, to prevent __proto__ attack [[a376c83](https://github.com/solidusjs/solidus-client/commit/a376c831087a1745c00977dedc274f65451d21da)]
4+
15
## 1.4.0 (Nov 6, 2018)
26

37
- Required params [[7de41bb](https://github.com/solidusjs/solidus-client/commit/7de41bb21c1c3731c0edf9d25655e589ce370e6d)]

build/solidus-client.js

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,8 @@ module.exports = View;
671671
},{"./util":4,"underscore":125}],6:[function(_dereq_,module,exports){
672672
var hasOwn = Object.prototype.hasOwnProperty;
673673
var toStr = Object.prototype.toString;
674-
var undefined;
674+
var defineProperty = Object.defineProperty;
675+
var gOPD = Object.getOwnPropertyDescriptor;
675676

676677
var isArray = function isArray(arr) {
677678
if (typeof Array.isArray === 'function') {
@@ -683,40 +684,72 @@ var isArray = function isArray(arr) {
683684

684685
var isPlainObject = function isPlainObject(obj) {
685686
'use strict';
687+
686688
if (!obj || toStr.call(obj) !== '[object Object]') {
687689
return false;
688690
}
689691

690-
var has_own_constructor = hasOwn.call(obj, 'constructor');
691-
var has_is_property_of_method = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
692+
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
693+
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
692694
// Not own constructor property must be Object
693-
if (obj.constructor && !has_own_constructor && !has_is_property_of_method) {
695+
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
694696
return false;
695697
}
696698

697699
// Own properties are enumerated firstly, so to speed up,
698700
// if last one is own, then all properties are own.
699701
var key;
700-
for (key in obj) {}
702+
for (key in obj) { /**/ }
703+
704+
return typeof key === 'undefined' || hasOwn.call(obj, key);
705+
};
706+
707+
// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target
708+
var setProperty = function setProperty(target, options) {
709+
if (defineProperty && options.name === '__proto__') {
710+
defineProperty(target, options.name, {
711+
enumerable: true,
712+
configurable: true,
713+
value: options.newValue,
714+
writable: true
715+
});
716+
} else {
717+
target[options.name] = options.newValue;
718+
}
719+
};
701720

702-
return key === undefined || hasOwn.call(obj, key);
721+
// Return undefined instead of __proto__ if '__proto__' is not an own property
722+
var getProperty = function getProperty(obj, name) {
723+
if (name === '__proto__') {
724+
if (!hasOwn.call(obj, name)) {
725+
return void 0;
726+
} else if (gOPD) {
727+
// In early versions of node, obj['__proto__'] is buggy when obj has
728+
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
729+
return gOPD(obj, name).value;
730+
}
731+
}
732+
733+
return obj[name];
703734
};
704735

705736
module.exports = function extend() {
706737
'use strict';
707-
var options, name, src, copy, copyIsArray, clone,
708-
target = arguments[0],
709-
i = 1,
710-
length = arguments.length,
711-
deep = false;
738+
739+
var options, name, src, copy, copyIsArray, clone;
740+
var target = arguments[0];
741+
var i = 1;
742+
var length = arguments.length;
743+
var deep = false;
712744

713745
// Handle a deep copy situation
714746
if (typeof target === 'boolean') {
715747
deep = target;
716748
target = arguments[1] || {};
717749
// skip the boolean and the target
718750
i = 2;
719-
} else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) {
751+
}
752+
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
720753
target = {};
721754
}
722755

@@ -726,29 +759,27 @@ module.exports = function extend() {
726759
if (options != null) {
727760
// Extend the base object
728761
for (name in options) {
729-
src = target[name];
730-
copy = options[name];
762+
src = getProperty(target, name);
763+
copy = getProperty(options, name);
731764

732765
// Prevent never-ending loop
733-
if (target === copy) {
734-
continue;
735-
}
736-
737-
// Recurse if we're merging plain objects or arrays
738-
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
739-
if (copyIsArray) {
740-
copyIsArray = false;
741-
clone = src && isArray(src) ? src : [];
742-
} else {
743-
clone = src && isPlainObject(src) ? src : {};
766+
if (target !== copy) {
767+
// Recurse if we're merging plain objects or arrays
768+
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
769+
if (copyIsArray) {
770+
copyIsArray = false;
771+
clone = src && isArray(src) ? src : [];
772+
} else {
773+
clone = src && isPlainObject(src) ? src : {};
774+
}
775+
776+
// Never move original objects, clone them
777+
setProperty(target, { name: name, newValue: extend(deep, clone, copy) });
778+
779+
// Don't bring in undefined values
780+
} else if (typeof copy !== 'undefined') {
781+
setProperty(target, { name: name, newValue: copy });
744782
}
745-
746-
// Never move original objects, clone them
747-
target[name] = extend(deep, clone, copy);
748-
749-
// Don't bring in undefined values
750-
} else if (copy !== undefined) {
751-
target[name] = copy;
752783
}
753784
}
754785
}
@@ -758,7 +789,6 @@ module.exports = function extend() {
758789
return target;
759790
};
760791

761-
762792
},{}],7:[function(_dereq_,module,exports){
763793
// Copyright Joyent, Inc. and other Node contributors.
764794
//

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solidus-client",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"main": "index.js",
55
"author": {
66
"name": "Joannic Laborde",

0 commit comments

Comments
 (0)