Skip to content

Commit e81561c

Browse files
committed
🔐 Move the credential into a broker child the provider cannot read
Slices 1 and 2, as one vertical slice: the abstraction and a real Git consumer arrive together. **Three processes, one question.** A provider invocation starts a broker child for one exact repository. The child acquires through the invoking user's Git and holds the result; the provider holds a capability and a private endpoint; the shim Git runs is the only program that writes a credential anywhere. The workflow process never receives a username or a password — there is no longer anything in it for a lease to be read out of. **The capability is not on a command line.** It reaches the shim through the environment of the Git command the lease was attached to; the command line names a program. The shim file itself holds neither the credential nor the capability — it is a launcher for this host's own unadvertised internal mode, which is not a command, appears in no help or public grammar, and can acquire nothing by itself. **What the broker refuses.** A capability that is not this lease's, an operation that is not `get`, and a locator that is not the one it was leased for. The last is the redirect defence: Git asks the shim about wherever it arrived, the shim restates that, and a broker leased for somewhere else answers nothing. Scheme, host with its explicit port, and full path are all compared. `useHttpPath` is forced on the transport as well as on the acquisition, because without it Git asks about the server and the two repositories could not be told apart at all. **Get-only, structurally.** `store`, `erase`, `approve` and `reject` are not operations that are declined — no code path here writes, forgets or reports a credential. **Teardown order.** Invalidate the lease, close the child's stdin, signal and await the process group, then remove the endpoint and the launcher. A shim that connects during teardown is refused rather than racing a broker that is going away, and an endpoint is never left addressable after its owner is gone. Slices remaining: cancellation-ordering and one-active-process evidence, protected interrupted-Push crash adoption, shared Deno/compiled host-assembly evidence, and the Windows named-pipe equivalent. Refs #522
1 parent 43c4dc1 commit e81561c

10 files changed

Lines changed: 1078 additions & 472 deletions

File tree

‎packages/cli/src/compiled.ts‎

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,34 @@ import { compileDataUri } from "@executablemd/core";
1212
import { runXmd } from "./cli.ts";
1313
import { useDenoWorkflowHost } from "./deno-workflow.ts";
1414
import { useCompiledService } from "./compiled-service.ts";
15+
import { runInternalMode } from "@executablemd/workflow/deno";
1516

16-
await main(function* (args) {
17-
// The base providers for this host. `at: "min"` puts them beneath ordinary
18-
// middleware, so middleware installed later can wrap either one.
19-
yield* API.Env.around(
20-
{
21-
*command([xmdArgs = []]) {
22-
return [process.execPath, ...xmdArgs];
23-
},
17+
// The unadvertised internal modes run before anything else is parsed: they are
18+
// not a command, they appear in no help and in no public grammar, and a caller
19+
// who did not select one gets the ordinary command line unchanged.
20+
if (runInternalMode(process.argv.slice(2))) {
21+
// The mode owns this process from here.
22+
} else {
23+
await main(function* (args) {
24+
// The base providers for this host. `at: "min"` puts them beneath ordinary
25+
// middleware, so middleware installed later can wrap either one.
26+
yield* API.Env.around(
27+
{
28+
*command([xmdArgs = []]) {
29+
return [process.execPath, ...xmdArgs];
30+
},
2431

25-
*compile([source, options]) {
26-
return yield* compileDataUri(source, options);
32+
*compile([source, options]) {
33+
return yield* compileDataUri(source, options);
34+
},
2735
},
28-
},
29-
{ at: "min" },
30-
);
31-
// Document filesystem access resolves in the caller's own filesystem here.
32-
// It is installed explicitly, and at the same depth, because `API.Files` has
33-
// no host default: a run with no provider must fail rather than reach the
34-
// host by accident.
35-
yield* useHostFiles();
36-
yield* runXmd(args, useCompiledService, useDenoWorkflowHost);
37-
});
36+
{ at: "min" },
37+
);
38+
// Document filesystem access resolves in the caller's own filesystem here.
39+
// It is installed explicitly, and at the same depth, because `API.Files` has
40+
// no host default: a run with no provider must fail rather than reach the
41+
// host by accident.
42+
yield* useHostFiles();
43+
yield* runXmd(args, useCompiledService, useDenoWorkflowHost);
44+
});
45+
}

‎packages/cli/src/deno.ts‎

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,36 @@ import { compileDataUri } from "@executablemd/core";
1515
import { runXmd } from "./cli.ts";
1616
import { useDenoWorkflowHost } from "./deno-workflow.ts";
1717
import { useDenoService } from "./deno-service.ts";
18+
import { runInternalMode } from "@executablemd/workflow/deno";
1819

1920
const ENTRYPOINT = fileURLToPath(import.meta.url);
2021

21-
await main(function* (args) {
22-
// The base providers for this host. `at: "min"` puts them beneath ordinary
23-
// middleware, so middleware installed later can wrap either one.
24-
yield* API.Env.around(
25-
{
26-
*command([xmdArgs = []]) {
27-
return [process.execPath, "run", "--allow-all", ENTRYPOINT, ...xmdArgs];
28-
},
22+
// The unadvertised internal modes run before anything else is parsed: they are
23+
// not a command, they appear in no help and in no public grammar, and a caller
24+
// who did not select one gets the ordinary command line unchanged.
25+
if (runInternalMode(process.argv.slice(2))) {
26+
// The mode owns this process from here.
27+
} else {
28+
await main(function* (args) {
29+
// The base providers for this host. `at: "min"` puts them beneath ordinary
30+
// middleware, so middleware installed later can wrap either one.
31+
yield* API.Env.around(
32+
{
33+
*command([xmdArgs = []]) {
34+
return [process.execPath, "run", "--allow-all", ENTRYPOINT, ...xmdArgs];
35+
},
2936

30-
*compile([source, options]) {
31-
return yield* compileDataUri(source, options);
37+
*compile([source, options]) {
38+
return yield* compileDataUri(source, options);
39+
},
3240
},
33-
},
34-
{ at: "min" },
35-
);
36-
// Document filesystem access resolves in the caller's own filesystem here.
37-
// It is installed explicitly, and at the same depth, because `API.Files` has
38-
// no host default: a run with no provider must fail rather than reach the
39-
// host by accident.
40-
yield* useHostFiles();
41-
yield* runXmd(args, useDenoService, useDenoWorkflowHost);
42-
});
41+
{ at: "min" },
42+
);
43+
// Document filesystem access resolves in the caller's own filesystem here.
44+
// It is installed explicitly, and at the same depth, because `API.Files` has
45+
// no host default: a run with no provider must fail rather than reach the
46+
// host by accident.
47+
yield* useHostFiles();
48+
yield* runXmd(args, useDenoService, useDenoWorkflowHost);
49+
});
50+
}

‎packages/workflow/deno.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,12 @@ export type {
7575
SuspensionControllerOptions,
7676
SuspensionNotice,
7777
} from "./src/deno/suspension.ts";
78+
79+
/**
80+
* The unadvertised internal modes this host runs for its own credential broker.
81+
*
82+
* Exported so an entrypoint can offer them, not so anyone can call them: neither
83+
* mode appears in help or in the public grammar, and neither can acquire a
84+
* credential by itself.
85+
*/
86+
export { runInternalMode } from "./src/deno/composition/broker/main.ts";

0 commit comments

Comments
 (0)