Skip to content

Commit 36e2a9a

Browse files
authored
fix(opentelemetry-core): add extra checks on internal merge function for safety (#6587)
1 parent 8ee2a8b commit 36e2a9a

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
1212

1313
* feat(sdk-metrics): adds the cardinalitySelector argument to PeriodicExportingMetricReaders
1414
[#6460](https://github.com/open-telemetry/opentelemetry-js/pull/6460) @starzlocker
15+
* feat(opentelemetry-core): add extra checks on internal merge function for safety [#6587](https://github.com/open-telemetry/opentelemetry-js/pull/6587) @maryliag
1516

1617
### :boom: Breaking Changes
1718

packages/opentelemetry-core/src/utils/merge.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ function mergeTwoObjects(
6969
const keys = Object.keys(two);
7070
for (let i = 0, j = keys.length; i < j; i++) {
7171
const key = keys[i];
72+
if (
73+
key === '__proto__' ||
74+
key === 'constructor' ||
75+
key === 'prototype'
76+
) {
77+
continue;
78+
}
7279
result[key] = takeValue(two[key]);
7380
}
7481
}
@@ -82,6 +89,13 @@ function mergeTwoObjects(
8289

8390
for (let i = 0, j = keys.length; i < j; i++) {
8491
const key = keys[i];
92+
if (
93+
key === '__proto__' ||
94+
key === 'constructor' ||
95+
key === 'prototype'
96+
) {
97+
continue;
98+
}
8599
const twoValue = two[key];
86100

87101
if (isPrimitive(twoValue)) {

0 commit comments

Comments
 (0)