Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli)!: Rename --UNSAFE to --UNCONFINED #2011

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions packages/cli/src/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,13 @@ export const makeCommand = async ({

const resultP =
importPath !== undefined
? E(party).importUnsafeAndEndow(
? E(party).makeUnconfined(
workerName,
path.resolve(importPath),
powersName,
resultName,
)
: E(party).importBundleAndEndow(
workerName,
bundleName,
powersName,
resultName,
);
: E(party).makeBundle(workerName, bundleName, powersName, resultName);
const result = await resultP;
console.log(result);

Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/src/daemon-node-powers.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export const makeDaemonicPersistencePowers = (

const webPageBundlerFormula = includeWebPageBundler
? {
type: /** @type {'import-unsafe'} */ ('import-unsafe'),
type: /** @type {'make-unconfined'} */ ('make-unconfined'),
worker: `worker-id512:${zero512}`,
powers: 'host',
importPath: fileURLToPath(
Expand Down
20 changes: 7 additions & 13 deletions packages/daemon/src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,7 @@ const makeEndoBootstrap = (
// eslint-disable-next-line no-use-before-define
provideValueForFormulaIdentifier(guestFormulaIdentifier)
);
const external = E(workerDaemonFacet).importUnsafeAndEndow(
importPath,
guestP,
);
const external = E(workerDaemonFacet).makeUnconfined(importPath, guestP);
return { external, internal: undefined };
};

Expand Down Expand Up @@ -285,10 +282,7 @@ const makeEndoBootstrap = (
// eslint-disable-next-line no-use-before-define
provideValueForFormulaIdentifier(guestFormulaIdentifier)
);
const external = E(workerDaemonFacet).importBundleAndEndow(
readableBundleP,
guestP,
);
const external = E(workerDaemonFacet).makeBundle(readableBundleP, guestP);
return { external, internal: undefined };
};

Expand All @@ -312,14 +306,14 @@ const makeEndoBootstrap = (
formula.values,
terminator,
);
} else if (formula.type === 'import-unsafe') {
} else if (formula.type === 'make-unconfined') {
return makeControllerForUnsafePlugin(
formula.worker,
formula.powers,
formula.importPath,
terminator,
);
} else if (formula.type === 'import-bundle') {
} else if (formula.type === 'make-bundle') {
return makeControllerForSafeBundle(
formula.worker,
formula.powers,
Expand Down Expand Up @@ -433,8 +427,8 @@ const makeEndoBootstrap = (
} else if (
[
'eval-id512',
'import-unsafe-id512',
'import-bundle-id512',
'make-unconfined-id512',
'make-bundle-id512',
'guest-id512',
'web-bundle',
].includes(formulaType)
Expand Down Expand Up @@ -614,7 +608,7 @@ const makeEndoBootstrap = (
})
);
const bundle = await E(bundleBlob).json();
await E(webPageP).importBundleAndEndow(bundle, endowedPowers);
await E(webPageP).makeBundle(bundle, endowedPowers);
},
});

Expand Down
20 changes: 10 additions & 10 deletions packages/daemon/src/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const makeHostMaker = ({
* @param {string | 'NONE' | 'HOST' | 'ENDO'} powersName
* @param {string} resultName
*/
const importUnsafeAndEndow = async (
const makeUnconfined = async (
workerName,
importPath,
powersName,
Expand All @@ -259,8 +259,8 @@ export const makeHostMaker = ({
);

const formula = {
/** @type {'import-unsafe'} */
type: 'import-unsafe',
/** @type {'make-unconfined'} */
type: 'make-unconfined',
worker: workerFormulaIdentifier,
powers: powersFormulaIdentifier,
importPath,
Expand All @@ -270,7 +270,7 @@ export const makeHostMaker = ({
// eslint-disable-next-line no-use-before-define
const { formulaIdentifier, value } = await provideValueForFormula(
formula,
'import-unsafe-id512',
'make-unconfined-id512',
);
if (resultName !== undefined) {
await petStore.write(resultName, formulaIdentifier);
Expand All @@ -284,7 +284,7 @@ export const makeHostMaker = ({
* @param {string | 'NONE' | 'HOST' | 'ENDO'} powersName
* @param {string} resultName
*/
const importBundleAndEndow = async (
const makeBundle = async (
workerName,
bundleName,
powersName,
Expand All @@ -305,8 +305,8 @@ export const makeHostMaker = ({
);

const formula = {
/** @type {'import-bundle'} */
type: 'import-bundle',
/** @type {'make-bundle'} */
type: 'make-bundle',
worker: workerFormulaIdentifier,
powers: powersFormulaIdentifier,
bundle: bundleFormulaIdentifier,
Expand All @@ -316,7 +316,7 @@ export const makeHostMaker = ({
// eslint-disable-next-line no-use-before-define
const { value, formulaIdentifier } = await provideValueForFormula(
formula,
'import-bundle-id512',
'make-bundle-id512',
);

if (resultName !== undefined) {
Expand Down Expand Up @@ -451,8 +451,8 @@ export const makeHostMaker = ({
provideWorker,
evaluate,
terminate,
importUnsafeAndEndow,
importBundleAndEndow,
makeUnconfined,
makeBundle,
provideWebPage,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/src/pet-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { quote: q } = assert;

const validIdPattern = /^[0-9a-f]{128}$/;
const validFormulaPattern =
/^(?:host|pet-store|(?:readable-blob-sha512|worker-id512|pet-store-id512|eval-id512|import-unsafe-id512|import-bundle-id512|host-id512|guest-id512):[0-9a-f]{128}|web-bundle:[0-9a-f]{32})$/;
/^(?:host|pet-store|(?:readable-blob-sha512|worker-id512|pet-store-id512|eval-id512|make-unconfined-id512|make-bundle-id512|host-id512|guest-id512):[0-9a-f]{128}|web-bundle:[0-9a-f]{32})$/;

/**
* @param {import('./types.js').FilePowers} filePowers
Expand Down
12 changes: 6 additions & 6 deletions packages/daemon/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ type EvalFormula = {
};

type ImportUnsafeFormula = {
rekmarks marked this conversation as resolved.
Show resolved Hide resolved
type: 'import-unsafe';
type: 'make-unconfined';
worker: string;
powers: string;
importPath: string;
// TODO formula slots
};

type ImportBundleFormula = {
type: 'import-bundle';
type: 'make-bundle';
worker: string;
powers: string;
bundle: string;
Expand Down Expand Up @@ -233,13 +233,13 @@ export interface EndoHost {
petNames: Array<string>,
resultName?: string,
);
importUnsafeAndEndow(
makeUnconfined(
workerPetName: string | undefined,
importPath: string,
powersName: string,
resultName?: string,
): Promise<unknown>;
importBundleAndEndow(
makeBundle(
workerPetName: string | undefined,
bundleName: string,
powersName: string,
Expand Down Expand Up @@ -342,8 +342,8 @@ export interface WorkerDaemonFacet {
values: Array<unknown>,
cancelled: Promise<never>,
): Promise<unknown>;
importBundleAndEndow(bundle: ERef<EndoReadable>, powers: ERef<unknown>);
importUnsafeAndEndow(path: string, powers: ERef<unknown>);
makeBundle(bundle: ERef<EndoReadable>, powers: ERef<unknown>);
makeUnconfined(path: string, powers: ERef<unknown>);
}

export type DaemonicControlPowers = {
Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/src/web-page-bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// This is a built-in unsafe plugin for lazily constructing the web-page.js
// bundle for booting up web caplets.
// The hard-coded 'web-page-js' formula is a hard-coded 'import-unsafe' formula
// The hard-coded 'web-page-js' formula is a hard-coded 'make-unconfined' formula
// that runs this program in worker 0.
// It does not accept its endowed powers.

Expand Down
2 changes: 1 addition & 1 deletion packages/daemon/src/web-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const bootstrap = Far('WebFacet', {
console.log('received ping');
return 'pong';
},
async importBundleAndEndow(bundle, powers) {
async makeBundle(bundle, powers) {
const namespace = await importBundle(bundle, {
endowments,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/daemon/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const makeWorkerFacet = ({ pathToFileURL, cancel }) => {
* @param {string} path
* @param {unknown} powersP
*/
importUnsafeAndEndow: async (path, powersP) => {
makeUnconfined: async (path, powersP) => {
const url = pathToFileURL(path);
const namespace = await import(url);
return namespace.make(powersP);
Expand All @@ -63,7 +63,7 @@ export const makeWorkerFacet = ({ pathToFileURL, cancel }) => {
* @param {import('@endo/eventual-send').ERef<import('./types.js').EndoReadable>} readableP
* @param {unknown} powersP
*/
importBundleAndEndow: async (readableP, powersP) => {
makeBundle: async (readableP, powersP) => {
const bundleText = await E(readableP).text();
const bundle = JSON.parse(bundleText);

Expand Down
10 changes: 5 additions & 5 deletions packages/daemon/test/test-endo.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ test('closure state lost by restart', async t => {
test('persist unsafe services and their requests', async t => {
const { promise: cancelled, reject: cancel } = makePromiseKit();
t.teardown(() => cancel(Error('teardown')));
const locator = makeLocator('tmp', 'import-unsafe');
const locator = makeLocator('tmp', 'make-unconfined');

await stop(locator).catch(() => {});
await reset(locator);
Expand Down Expand Up @@ -358,7 +358,7 @@ test('persist unsafe services and their requests', async t => {
await E(host).makeWorker('w1');
await E(host).provideGuest('o1');
const servicePath = path.join(dirname, 'test', 'service.js');
await E(host).importUnsafeAndEndow('w1', servicePath, 'o1', 's1');
await E(host).makeUnconfined('w1', servicePath, 'o1', 's1');

await E(host).makeWorker('w2');
const answer = await E(host).evaluate(
Expand Down Expand Up @@ -444,7 +444,7 @@ test('direct termination', async t => {
await E(host).provideWorker('worker');

const counterPath = path.join(dirname, 'test', 'counter.js');
await E(host).importUnsafeAndEndow('worker', counterPath, 'NONE', 'counter');
await E(host).makeUnconfined('worker', counterPath, 'NONE', 'counter');
t.is(
1,
await E(host).evaluate(
Expand Down Expand Up @@ -524,7 +524,7 @@ test('indirect termination', async t => {
await E(host).provideWorker('worker');

const counterPath = path.join(dirname, 'test', 'counter.js');
await E(host).importUnsafeAndEndow('worker', counterPath, 'SELF', 'counter');
await E(host).makeUnconfined('worker', counterPath, 'SELF', 'counter');
t.is(
1,
await E(host).evaluate(
Expand Down Expand Up @@ -606,7 +606,7 @@ test('terminate because of requested capability', async t => {
const messages = E(host).followMessages();

const counterPath = path.join(dirname, 'test', 'counter-party.js');
E(host).importUnsafeAndEndow('worker', counterPath, 'guest', 'counter');
E(host).makeUnconfined('worker', counterPath, 'guest', 'counter');

await E(host).evaluate('worker', '0', [], [], 'zero');
await E(messages).next();
Expand Down
Loading