diff --git a/packages/compartment-mapper/test/snapshots/test-error-handling.js.md b/packages/compartment-mapper/test/snapshots/test-error-handling.js.md index 749c039ea8..21359b73c1 100644 --- a/packages/compartment-mapper/test/snapshots/test-error-handling.js.md +++ b/packages/compartment-mapper/test/snapshots/test-error-handling.js.md @@ -95,14 +95,14 @@ Generated by [AVA](https://avajs.dev). `Error: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/cjs/␊ at Object.execute (file://.../compartment-mapper/src/import-archive.js:…)␊ at execute (file://.../ses/src/module-instance.js:…)␊ - at compartmentImportNow (file://.../ses/src/compartment-shim.js:…)␊ - at Compartment.importNow (file://.../ses/src/compartment-shim.js:…)␊ + at compartmentImportNow (file://.../ses/src/compartment.js:…)␊ + at Compartment.importNow (file://.../ses/src/compartment.js:…)␊ at require (file://.../compartment-mapper/src/parse-cjs-shared-export-wrapper.js:…)␊ at eval (eval at (eval at makeEvaluate (file://.../ses/src/make-evaluate.js:…)), :…)␊ at Object.execute (file://.../compartment-mapper/src/parse-pre-cjs.js:…)␊ at execute (file://.../ses/src/module-instance.js:…)␊ - at compartmentImportNow (file://.../ses/src/compartment-shim.js:…)␊ - at file://.../ses/src/compartment-shim.js:…` + at compartmentImportNow (file://.../ses/src/compartment.js:…)␊ + at file://.../ses/src/compartment.js:…` ## fixtures-error-handling / cjs / makeArchive / parseArchive with a prefix @@ -111,14 +111,14 @@ Generated by [AVA](https://avajs.dev). `Error: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/cjs/␊ at Object.execute (file://.../compartment-mapper/src/import-archive.js:…)␊ at execute (file://.../ses/src/module-instance.js:…)␊ - at compartmentImportNow (file://.../ses/src/compartment-shim.js:…)␊ - at Compartment.importNow (file://.../ses/src/compartment-shim.js:…)␊ + at compartmentImportNow (file://.../ses/src/compartment.js:…)␊ + at Compartment.importNow (file://.../ses/src/compartment.js:…)␊ at require (file://.../compartment-mapper/src/parse-cjs-shared-export-wrapper.js:…)␊ at eval (eval at (eval at makeEvaluate (file://.../ses/src/make-evaluate.js:…)), :…)␊ at Object.execute (file://.../compartment-mapper/src/parse-pre-cjs.js:…)␊ at execute (file://.../ses/src/module-instance.js:…)␊ - at compartmentImportNow (file://.../ses/src/compartment-shim.js:…)␊ - at file://.../ses/src/compartment-shim.js:…` + at compartmentImportNow (file://.../ses/src/compartment.js:…)␊ + at file://.../ses/src/compartment.js:…` ## fixtures-error-handling / cjs / writeArchive / loadArchive @@ -127,14 +127,14 @@ Generated by [AVA](https://avajs.dev). `Error: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/cjs/␊ at Object.execute (file://.../compartment-mapper/src/import-archive.js:…)␊ at execute (file://.../ses/src/module-instance.js:…)␊ - at compartmentImportNow (file://.../ses/src/compartment-shim.js:…)␊ - at Compartment.importNow (file://.../ses/src/compartment-shim.js:…)␊ + at compartmentImportNow (file://.../ses/src/compartment.js:…)␊ + at Compartment.importNow (file://.../ses/src/compartment.js:…)␊ at require (file://.../compartment-mapper/src/parse-cjs-shared-export-wrapper.js:…)␊ at eval (eval at (eval at makeEvaluate (file://.../ses/src/make-evaluate.js:…)), :…)␊ at Object.execute (file://.../compartment-mapper/src/parse-pre-cjs.js:…)␊ at execute (file://.../ses/src/module-instance.js:…)␊ - at compartmentImportNow (file://.../ses/src/compartment-shim.js:…)␊ - at file://.../ses/src/compartment-shim.js:…` + at compartmentImportNow (file://.../ses/src/compartment.js:…)␊ + at file://.../ses/src/compartment.js:…` ## fixtures-error-handling / cjs / writeArchive / importArchive @@ -143,71 +143,11 @@ Generated by [AVA](https://avajs.dev). `Error: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/cjs/␊ at Object.execute (file://.../compartment-mapper/src/import-archive.js:…)␊ at execute (file://.../ses/src/module-instance.js:…)␊ - at compartmentImportNow (file://.../ses/src/compartment-shim.js:…)␊ - at Compartment.importNow (file://.../ses/src/compartment-shim.js:…)␊ + at compartmentImportNow (file://.../ses/src/compartment.js:…)␊ + at Compartment.importNow (file://.../ses/src/compartment.js:…)␊ at require (file://.../compartment-mapper/src/parse-cjs-shared-export-wrapper.js:…)␊ at eval (eval at (eval at makeEvaluate (file://.../ses/src/make-evaluate.js:…)), :…)␊ at Object.execute (file://.../compartment-mapper/src/parse-pre-cjs.js:…)␊ at execute (file://.../ses/src/module-instance.js:…)␊ - at compartmentImportNow (file://.../ses/src/compartment-shim.js:…)␊ - at file://.../ses/src/compartment-shim.js:…` - -## fixtures-error-handling / both / loadLocation - -> Snapshot 1 - - `TypeError: Failed to load module "./main.js" in package "file://.../compartment-mapper/test/fixtures-error-handling/node_modules/both/" (1 underlying failures: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/esm/␊ - at load (file://.../ses/src/module-load.js:…)␊ - at async file://.../compartment-mapper/test/scaffold.js:…␊ - at async file://.../compartment-mapper/test/scaffold.js:…` - - -## fixtures-error-handling / both / makeArchive / parseArchive - -> Snapshot 1 - - `TypeError: Failed to load module "./main.js" in package "file://.../compartment-mapper/test/fixtures-error-handling/node_modules/both/" (1 underlying failures: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/esm/␊ - at load (file://.../ses/src/module-load.js:…)␊ - at async digestLocation (file://.../compartment-mapper/src/archive.js:…)␊ - at async makeAndHashArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async makeArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async file://.../compartment-mapper/test/scaffold.js:…␊ - at async file://.../compartment-mapper/test/scaffold.js:…` - -## fixtures-error-handling / both / makeArchive / parseArchive with a prefix - -> Snapshot 1 - - `TypeError: Failed to load module "./main.js" in package "file://.../compartment-mapper/test/fixtures-error-handling/node_modules/both/" (1 underlying failures: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/esm/␊ - at load (file://.../ses/src/module-load.js:…)␊ - at async digestLocation (file://.../compartment-mapper/src/archive.js:…)␊ - at async makeAndHashArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async makeArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async file://.../compartment-mapper/test/scaffold.js:…␊ - at async file://.../compartment-mapper/test/scaffold.js:…` - -## fixtures-error-handling / both / writeArchive / loadArchive - -> Snapshot 1 - - `TypeError: Failed to load module "./main.js" in package "file://.../compartment-mapper/test/fixtures-error-handling/node_modules/both/" (1 underlying failures: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/esm/␊ - at load (file://.../ses/src/module-load.js:…)␊ - at async digestLocation (file://.../compartment-mapper/src/archive.js:…)␊ - at async makeAndHashArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async makeArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async writeArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async file://.../compartment-mapper/test/scaffold.js:…␊ - at async file://.../compartment-mapper/test/scaffold.js:…` - -## fixtures-error-handling / both / writeArchive / importArchive - -> Snapshot 1 - - `TypeError: Failed to load module "./main.js" in package "file://.../compartment-mapper/test/fixtures-error-handling/node_modules/both/" (1 underlying failures: Cannot find external module "missing" in package file://.../compartment-mapper/test/fixtures-error-handling/node_modules/esm/␊ - at load (file://.../ses/src/module-load.js:…)␊ - at async digestLocation (file://.../compartment-mapper/src/archive.js:…)␊ - at async makeAndHashArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async makeArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async writeArchive (file://.../compartment-mapper/src/archive.js:…)␊ - at async file://.../compartment-mapper/test/scaffold.js:…␊ - at async file://.../compartment-mapper/test/scaffold.js:…` + at compartmentImportNow (file://.../ses/src/compartment.js:…)␊ + at file://.../ses/src/compartment.js:…` diff --git a/packages/compartment-mapper/test/snapshots/test-error-handling.js.snap b/packages/compartment-mapper/test/snapshots/test-error-handling.js.snap index ec130441ab..1ba5b1f98c 100644 Binary files a/packages/compartment-mapper/test/snapshots/test-error-handling.js.snap and b/packages/compartment-mapper/test/snapshots/test-error-handling.js.snap differ diff --git a/packages/ses/NEWS.md b/packages/ses/NEWS.md index 2f67762874..7041eff19e 100644 --- a/packages/ses/NEWS.md +++ b/packages/ses/NEWS.md @@ -2,21 +2,28 @@ User-visible changes in SES: # Next release +- Extracts `repairIntrinsics(options)` and `hardenIntrinsics()` from the + behavior of `lockdown(options)` so vetted shims can run between these + calls. + Any modifications to shared intrinsics survive if applied after + `repairIntrinsics()`. - In the SES-shim implementation of HardenedJS, all constructed compartments -get the same safe `Date` -constructor, that does not provide the ability to measure duration. It used -to do this by having `Date.now()` return `NaN`, and to have calls on the -constructor that would normally have returned an indication of the current date, -instead return the corresponding invalid date indication. Now, all of these -throw a `TypeError` whose message begins with `'secure mode'`. This aligns with -the XS implementation of HardenedJS. -- Similarly, In the SES-shim implementation of HardenedJS, -all constructed compartments get the same safe `Math` namespace -object that does not provide a working `random()` function. It used to do that -by omitting the `random` property from the safe `Math` namespace object. Now, -the safe shared `Math` namespace object has a `Math.random()` function that -throws a `TypeError whose message begins with `'secure mode'`. This again -aligns with the XS implementation of HardenedJS. + get the same safe `Date` constructor, that does not provide the ability to + measure duration. + It used to do this by having `Date.now()` return `NaN`, and to have calls on + the constructor that would normally have returned an indication of the + current date, instead return the corresponding invalid date indication. + Now, all of these throw a `TypeError` whose message begins with `'secure + mode'`. + This aligns with the XS implementation of HardenedJS. +- Similarly, In the SES-shim implementation of HardenedJS, all constructed + compartments get the same safe `Math` namespace object that does not provide + a working `random()` function. + It used to do that by omitting the `random` property from the safe `Math` + namespace object. + Now, the safe shared `Math` namespace object has a `Math.random()` function + that throws a `TypeError whose message begins with `'secure mode'`. + This again aligns with the XS implementation of HardenedJS. # v0.18.6 (2023-08-07) diff --git a/packages/ses/docs/guide.md b/packages/ses/docs/guide.md index c77377c274..4d50f40de8 100644 --- a/packages/ses/docs/guide.md +++ b/packages/ses/docs/guide.md @@ -28,7 +28,7 @@ Hardened JavaScript: - Removes non-determinism by modifying a few built-in objects. - Adds functionality to freeze and make immutable both built-in JavaScript objects and program created objects and make them immutable. -- Is (as SES) is a proposed extension to the JavaScript standard. +- Is (tentatively named SES) a proposed extension to the JavaScript standard. Hardened JavaScript consists of three parts: - Lockdown is a function that irreversibly repairs and hardens an existing @@ -39,6 +39,12 @@ Hardened JavaScript consists of three parts: globals and modules, but shared hardened primordials and limited access to other powerful objects in global scope. +Lockdown consists of separable Repair Intrinsics and Harden Intrinsics phases, +so that shims (other programs that alter JavaScript) may run between them. +These shims are obliged to maintain the object capability safety invariants +provided by Lockdown and must be carefully reviewed. +We call these "vetted shims". + ## What is SES? SES is an old umbrella term for the Hardened JavaScript effort, and while we @@ -143,6 +149,53 @@ To use SES as a script on the web, use the UMD build.