From d400b04df6c94dc590b59f13f464c80f32377489 Mon Sep 17 00:00:00 2001 From: LeoTM <1881059+leotm@users.noreply.github.com> Date: Thu, 5 Dec 2024 20:47:31 +0000 Subject: [PATCH] fix(ses): removeUnpermittedIntrinsics on Hermes --- packages/ses/src/cauterize-property.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/ses/src/cauterize-property.js b/packages/ses/src/cauterize-property.js index b7bd4929a4..0b2eac54ac 100644 --- a/packages/ses/src/cauterize-property.js +++ b/packages/ses/src/cauterize-property.js @@ -23,6 +23,9 @@ import { objectHasOwnProperty } from './commons.js'; * an undeletable `.prototype` property. In these cases, if we can * set the value of that bogus `.prototype` property to `undefined`, * we do so, issuing a warning, rather than failing to initialize ses. + * Finally we also tolerate functions with undeletable `.caller` and + * `.arguments` properties to conclude removing unpermitted intrinsics + * on Hermes. * * @param {object} obj * @param {PropertyKey} prop @@ -60,6 +63,13 @@ export const cauterizeProperty = ( return; } } + if ( + typeof obj === 'function' && + (prop === 'caller' || prop === 'arguments') + ) { + warn(`Tolerating undeletable ${subPath}`); + return; + } error(`failed to delete ${subPath}`, err); } else { error(`deleting ${subPath} threw`, err);