Skip to content

Commit

Permalink
fixup! partial review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Nov 13, 2024
1 parent 6b9c271 commit 81482e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/ses/src/compartment-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
9 changes: 5 additions & 4 deletions packages/ses/src/intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, any>} */
const intrinsics = create(null);
let pseudoNatives;
Expand Down Expand Up @@ -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));

Expand Down
7 changes: 2 additions & 5 deletions packages/ses/src/permits-intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 81482e7

Please sign in to comment.