From 81482e710128bde0edb4415ca002bca9d1f40043 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Tue, 12 Nov 2024 17:39:55 -0800 Subject: [PATCH] fixup! partial review suggestion --- packages/ses/src/compartment-shim.js | 2 +- packages/ses/src/intrinsics.js | 9 +++++---- packages/ses/src/permits-intrinsics.js | 7 ++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/ses/src/compartment-shim.js b/packages/ses/src/compartment-shim.js index d8736d7fea..a804a479b1 100644 --- a/packages/ses/src/compartment-shim.js +++ b/packages/ses/src/compartment-shim.js @@ -9,6 +9,6 @@ const markVirtualizedNativeFunction = tameFunctionToString(); globalThis.Compartment = makeCompartmentConstructor( makeCompartmentConstructor, // TODO pass a proper reporter as second arg to `getGlobalIntrinsics`? - getGlobalIntrinsics(globalThis), + getGlobalIntrinsics(globalThis, console), markVirtualizedNativeFunction, ); diff --git a/packages/ses/src/intrinsics.js b/packages/ses/src/intrinsics.js index 6749cd60d8..6dd17b58ee 100644 --- a/packages/ses/src/intrinsics.js +++ b/packages/ses/src/intrinsics.js @@ -77,9 +77,9 @@ function sampleGlobals(globalObject, newPropertyNames) { } /** - * @param {Reporter} [reporter] defaults to `console` + * @param {Reporter} reporter */ -export const makeIntrinsicsCollector = (reporter = console) => { +export const makeIntrinsicsCollector = reporter => { /** @type {Record} */ const intrinsics = create(null); let pseudoNatives; @@ -180,10 +180,11 @@ export const makeIntrinsicsCollector = (reporter = console) => { * *original* unsafe (feral, untamed) bindings of these global variables. * * @param {object} globalObject + * @param {Reporter} reporter */ -export const getGlobalIntrinsics = globalObject => { +export const getGlobalIntrinsics = (globalObject, reporter) => { // TODO pass a proper reporter to `makeIntrinsicsCollector` - const { addIntrinsics, finalIntrinsics } = makeIntrinsicsCollector(); + const { addIntrinsics, finalIntrinsics } = makeIntrinsicsCollector(reporter); addIntrinsics(sampleGlobals(globalObject, sharedGlobalPropertyNames)); diff --git a/packages/ses/src/permits-intrinsics.js b/packages/ses/src/permits-intrinsics.js index bb1743aea4..fb0090476a 100644 --- a/packages/ses/src/permits-intrinsics.js +++ b/packages/ses/src/permits-intrinsics.js @@ -78,7 +78,7 @@ import { cauterizeProperty } from './cauterize-property.js'; export default function removeUnpermittedIntrinsics( intrinsics, markVirtualizedNativeFunction, - { warn, error }, + reporter, ) { // These primitives are allowed for permits. const primitives = ['undefined', 'boolean', 'number', 'string', 'symbol']; @@ -280,10 +280,7 @@ export default function removeUnpermittedIntrinsics( const subPermit = getSubPermit(obj, permit, propString); if (!subPermit || !isAllowedProperty(subPath, obj, prop, subPermit)) { - cauterizeProperty(obj, prop, subPermit === false, subPath, { - warn, - error, - }); + cauterizeProperty(obj, prop, subPermit === false, subPath, reporter); } } }