Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: deny modifying the object prototype #1698

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/shared/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export function deepAssign<T, S>(target: T, source: S): T & S;
export function deepAssign<S>(target: {}, source: S): S;
export function deepAssign(target: any, ...sources: any[]): any {
sources.forEach((source) => {
Object.getOwnPropertyNames(source).forEach((key) => assign(key, target, source));
Object.getOwnPropertyNames(source).forEach(
(key) =>
!['__proto__', 'constructor', 'prototype'].includes(key) && assign(key, target, source)
);
/* istanbul ignore next */
if (Object.getOwnPropertySymbols) {
Object.getOwnPropertySymbols(source).forEach((key) => assign(key, target, source));
Expand Down