From 3efb14fa53f5914d80acee5dc9861345668433a6 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Mon, 12 Aug 2024 14:21:02 -0700 Subject: [PATCH] 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];