-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(endo): Support exec shell environment
- Loading branch information
Showing
7 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/usr/bin/env node | ||
import fs from "fs"; | ||
import { main } from "../src/cli.js"; | ||
|
||
main(process, { fs: fs.promises }); | ||
(async () => { | ||
const fs = await import("fs"); | ||
const { main } = await import("../src/cli.js"); | ||
main(process, { fs: fs.promises }); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* global lockdown */ | ||
|
||
// This is a CommonJS module, to be used like `node -r endo/src/lockdown.cjs`. | ||
// The `endo exec` command stages a man-in-the-middle `node` shell script that | ||
// in turn injects this SES lockdown parameter in all Node.js commands in the | ||
// resulting shell environment. | ||
// The taming behavior may be overridden with environment variables | ||
// like `ERROR_TAMING=unsafe endo exec node ...` | ||
|
||
require("ses"); | ||
lockdown({ | ||
dateTaming: process.env.ENDO_DATE_TAMING || 'safe', | ||
errorTaming: process.env.ENDO_ERROR_TAMING || 'safe', | ||
mathTaming: process.env.ENDO_MATH_TAMING || 'safe', | ||
regExpTaming: process.env.ENDO_REGEXP_TAMING || 'safe', | ||
localeTaming: process.env.ENDO_LOCAlE_TAMING || 'safe', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/* global lockdown */ | ||
import "ses"; | ||
|
||
// This is used by Endo to lockdown its own start compartment. | ||
|
||
lockdown({ | ||
errorTaming: "unsafe" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This postinstall hook creates mitm/node. | ||
// This in turn interposes SES lockdown for all descendent processes, provided | ||
// that the mitm directory is appears before Node.js's bin directory on the | ||
// environment PATH. | ||
|
||
import fs from "fs"; | ||
|
||
const node = process.argv[0]; | ||
const lockdown = new URL("../src/lockdown.cjs", import.meta.url).pathname; | ||
const mitm = new URL("../mitm/node", import.meta.url).pathname; | ||
|
||
const script = `#!/bin/bash | ||
set -ueo pipefail | ||
${node} -r ${lockdown} "$@"`; | ||
|
||
fs.writeFileSync(mitm, script, "utf-8"); | ||
fs.chmodSync(mitm, 0o755); |