Skip to content

Commit

Permalink
feat: non-security mode for create-react-scripts compat. (KLUDGE)
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc authored and erights committed Mar 26, 2021
1 parent 01fabaf commit 48f1a03
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/ses/src/lockdown-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,15 @@ export function repairIntrinsics(
* 3. HARDEN to share the intrinsics.
*/

function hardenIntrinsics() {
function hardenIntrinsics(kludge) {
// Circumvent the override mistake.
enablePropertyOverrides(intrinsics, overrideTaming);

// Finally register and optionally freeze all the intrinsics. This
// must be the operation that modifies the intrinsics.
lockdownHarden(intrinsics);
if (!kludge) {
// Finally register and optionally freeze all the intrinsics. This
// must be the operation that modifies the intrinsics.
lockdownHarden(intrinsics);
}

// Having completed lockdown without failing, the user may now
// call `harden` and expect the object's transitively accessible properties
Expand Down Expand Up @@ -282,13 +284,18 @@ export const makeLockdown = (
* @param {LockdownOptions} [options]
*/
const lockdown = (options = {}) => {
const { skipHardenIntrinsics, ...restOptions } = options;
const maybeHardenIntrinsics = repairIntrinsics(
makeCompartmentConstructor,
compartmentPrototype,
getAnonymousIntrinsics,
options,
restOptions,
);
return maybeHardenIntrinsics();
if (skipHardenIntrinsics) {
maybeHardenIntrinsics(true);
} else {
maybeHardenIntrinsics();
}
};
return lockdown;
};
Expand Down

0 comments on commit 48f1a03

Please sign in to comment.