Skip to content
Permalink
Browse files
fix: fix for Prototype Pollution (#304)
  • Loading branch information
ready-research committed Sep 3, 2021
1 parent b69619e commit 34ed147c2c9dd02bc213e74f9d5d7af1fae3b42c
Showing with 7 additions and 0 deletions.
  1. +7 −0 packages/util/src/index.ts
@@ -4,6 +4,7 @@ export * from './types'

const DEV = process.env.NODE_ENV !== 'production'

const specialProperties = ['__proto__', 'constructor', 'prototype'];
/**
* Identity function.
*/
@@ -66,6 +67,9 @@ export const get = (from: unknown, path: Path): unknown => {
export const assign = <T, U>(target: T, source: U): T & U => {
if (!is(source)) return target as T & U
for (const key in source) {
if (specialProperties.indexOf(key) !== -1) {
continue;
}
// @ts-ignore
target[key] = source[key]
}
@@ -78,6 +82,9 @@ export const assign = <T, U>(target: T, source: U): T & U => {
export const merge = <T, U>(target: T, source: U): T & U => {
if (!is(source)) return target as T & U
for (const key in source) {
if (specialProperties.indexOf(key) !== -1) {
continue;
}
// @ts-ignore
if (obj(target[key])) {
// @ts-ignore

0 comments on commit 34ed147

Please sign in to comment.