From 9a54ce5df1b46fb731758a8c91a9420fb848638e Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Mon, 12 Aug 2024 14:21:02 -0700 Subject: [PATCH 1/2] fix(compartment-mapper): fix #2407 include symbol-named properties --- packages/compartment-mapper/src/policy.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/compartment-mapper/src/policy.js b/packages/compartment-mapper/src/policy.js index ee2a8fb52d..98af69a31e 100644 --- a/packages/compartment-mapper/src/policy.js +++ b/packages/compartment-mapper/src/policy.js @@ -10,7 +10,9 @@ import { policyLookupHelper, } from './policy-format.js'; -const { create, entries, values, assign, keys, freeze } = Object; +const { create, entries, values, assign, freeze, getOwnPropertyDescriptors } = + Object; +const { ownKeys } = Reflect; const q = JSON.stringify; /** @@ -28,7 +30,12 @@ export const ATTENUATORS_COMPARTMENT = ''; */ const selectiveCopy = (from, to, list) => { if (!list) { - list = keys(from); + const descs = getOwnPropertyDescriptors(from); + list = ownKeys(from).filter( + key => + // @ts-expect-error TypeScript still confused about a symbol as index + descs[key].enumerable, + ); } for (let index = 0; index < list.length; index += 1) { const key = list[index]; From 8360bbdd73ff8e2316c6e97cc15b30e37d0e68b7 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Wed, 21 Aug 2024 17:54:16 -0700 Subject: [PATCH 2/2] fixup! review comment --- packages/compartment-mapper/src/policy.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/compartment-mapper/src/policy.js b/packages/compartment-mapper/src/policy.js index 98af69a31e..7306ae7496 100644 --- a/packages/compartment-mapper/src/policy.js +++ b/packages/compartment-mapper/src/policy.js @@ -21,7 +21,9 @@ const q = JSON.stringify; export const ATTENUATORS_COMPARTMENT = ''; /** - * Copies properties (optionally limited to a specific list) from one object to another. + * Copies properties (optionally limited to a specific list) from one object + * to another. By default, copies all enumerable, own, string- and + * symbol-named properties. * * @param {object} from * @param {object} to