@capybara-hq/testing 0.1.0-rc.4 → 0.1.0-rc.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/containers.d.ts +7 -2
- package/dist/containers.js +7 -3
- package/dist/device-service-conformance.d.ts +38 -0
- package/dist/device-service-conformance.js +142 -0
- package/dist/dual-replica.d.ts +23 -1
- package/dist/dual-replica.js +53 -0
- package/dist/fake-channel.d.ts +44 -5
- package/dist/fake-channel.js +63 -2
- package/dist/fake-dial-in-machine.d.ts +173 -0
- package/dist/fake-dial-in-machine.js +429 -0
- package/dist/fake-e2b.d.ts +34 -0
- package/dist/fake-e2b.js +95 -1
- package/dist/fake-git-server.d.ts +32 -4
- package/dist/fake-git-server.js +87 -19
- package/dist/fake-lark.d.ts +12 -1
- package/dist/fake-lark.js +63 -10
- package/dist/fake-oauth-server.d.ts +62 -2
- package/dist/fake-oauth-server.js +86 -5
- package/dist/fake-slack.d.ts +17 -1
- package/dist/fake-slack.js +98 -0
- package/dist/fake-telegram.d.ts +173 -0
- package/dist/fake-telegram.js +632 -0
- package/dist/fixtures.d.ts +24 -8
- package/dist/fixtures.js +31 -8
- package/dist/index.d.ts +15 -9
- package/dist/index.js +10 -4
- package/dist/kernel-helpers.d.ts +16 -4
- package/dist/kernel-helpers.js +39 -4
- package/dist/media-samples.d.ts +2 -0
- package/dist/media-samples.js +2 -0
- package/dist/model-conformance.d.ts +15 -10
- package/dist/model-conformance.js +87 -14
- package/dist/push-conformance.d.ts +31 -0
- package/dist/push-conformance.js +160 -0
- package/dist/replica-runner.js +2 -0
- package/dist/sandbox-native-conformance.d.ts +31 -0
- package/dist/sandbox-native-conformance.js +153 -0
- package/dist/sandbox-permission-conformance.d.ts +310 -0
- package/dist/sandbox-permission-conformance.js +1491 -0
- package/fixtures/extensions/fake-bootstrap-a/src/index.ts +8 -4
- package/fixtures/extensions/fake-bootstrap-b/src/index.ts +8 -4
- package/fixtures/extensions/fake-client/.capybara-plugin/plugin.json +11 -0
- package/fixtures/extensions/fake-client/client/styles/fake.css +11 -0
- package/fixtures/extensions/fake-client/package.json +12 -0
- package/fixtures/extensions/fake-client/src/client.tsx +51 -0
- package/fixtures/extensions/fake-client/src/index.ts +43 -0
- package/fixtures/extensions/fake-client/themes/fake.json +11 -0
- package/fixtures/extensions/fake-client-broken/.capybara-plugin/plugin.json +7 -0
- package/fixtures/extensions/fake-client-broken/package.json +12 -0
- package/fixtures/extensions/fake-client-broken/src/client.tsx +22 -0
- package/fixtures/extensions/fake-client-broken/src/index.ts +27 -0
- package/fixtures/extensions/fake-config-form/src/index.ts +52 -46
- package/fixtures/extensions/fake-connector/src/index.ts +64 -34
- package/fixtures/extensions/fake-context/.capybara-plugin/plugin.json +7 -0
- package/fixtures/extensions/fake-context/package.json +12 -0
- package/fixtures/extensions/fake-context/src/index.ts +78 -0
- package/fixtures/extensions/fake-dep-provider/src/index.ts +1 -1
- package/fixtures/extensions/fake-dep-requirer/src/index.ts +1 -1
- package/fixtures/extensions/fake-embed/src/index.ts +26 -26
- package/fixtures/extensions/fake-im/.capybara-plugin/plugin.json +7 -1
- package/fixtures/extensions/fake-im/guides/fake-im-app.md +32 -0
- package/fixtures/extensions/fake-im/guides/fake-im-app.zh.md +32 -0
- package/fixtures/extensions/fake-im/src/channel.ts +22 -1
- package/fixtures/extensions/fake-im/src/checks.ts +94 -0
- package/fixtures/extensions/fake-im/src/directory.ts +44 -20
- package/fixtures/extensions/fake-im/src/index.ts +59 -11
- package/fixtures/extensions/fake-lifecycle/.capybara-plugin/plugin.json +7 -0
- package/fixtures/extensions/fake-lifecycle/migrations/0001_init.sql +16 -0
- package/fixtures/extensions/fake-lifecycle/package.json +12 -0
- package/fixtures/extensions/fake-lifecycle/src/index.ts +72 -0
- package/fixtures/extensions/fake-object-store/src/index.ts +12 -8
- package/fixtures/extensions/fake-openapi/src/index.ts +46 -34
- package/fixtures/extensions/fake-push/.capybara-plugin/plugin.json +13 -0
- package/fixtures/extensions/fake-push/guides/fake-push-key.md +6 -0
- package/fixtures/extensions/fake-push/guides/fake-push-key.zh.md +6 -0
- package/fixtures/extensions/fake-push/migrations/0001_sends.sql +9 -0
- package/fixtures/extensions/fake-push/package.json +12 -0
- package/fixtures/extensions/fake-push/src/check.ts +40 -0
- package/fixtures/extensions/fake-push/src/index.ts +56 -0
- package/fixtures/extensions/fake-push/src/push.ts +103 -0
- package/fixtures/extensions/fake-tools-ui/src/index.ts +61 -2
- package/fixtures/extensions/fake-web/src/index.ts +5 -4
- package/fixtures/extensions/fake-web/src/web.ts +11 -7
- package/fixtures/extensions/fake-web-2/src/index.ts +2 -2
- package/fixtures/extensions/fake-web-2/src/web.ts +11 -7
- package/fixtures/plugins/fake-theme/.capybara-plugin/plugin.json +7 -0
- package/fixtures/plugins/fake-theme/brand/app-512.png +0 -0
- package/fixtures/plugins/fake-theme/brand/app-mask-512.png +0 -0
- package/fixtures/plugins/fake-theme/brand/avatars/bot.svg +1 -0
- package/fixtures/plugins/fake-theme/brand/avatars/cat.png +0 -0
- package/fixtures/plugins/fake-theme/brand/illustration.svg +1 -0
- package/fixtures/plugins/fake-theme/brand/unnamed.svg +1 -0
- package/fixtures/plugins/fake-theme/fonts/FakeSans.woff2 +1 -0
- package/fixtures/plugins/fake-theme/logo.svg +1 -0
- package/fixtures/plugins/fake-theme/package.json +8 -0
- package/fixtures/plugins/fake-theme/themes/brand-kit.json +24 -0
- package/fixtures/plugins/fake-theme/themes/neon-grid.json +13 -0
- package/fixtures/plugins/fake-theme/themes/paper.json +12 -0
- package/package.json +6 -5
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { checkPushResults, PushError, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
const MESSAGE = {
|
|
4
|
+
title: "Support agent",
|
|
5
|
+
body: "needs your approval",
|
|
6
|
+
path: "/chat/c1?org=o1",
|
|
7
|
+
threadId: "c1",
|
|
8
|
+
collapseId: "conv-c1-7",
|
|
9
|
+
origin: "https://capybara.example.com",
|
|
10
|
+
};
|
|
11
|
+
const APP_ID = "com.example.app";
|
|
12
|
+
const secretToken = (n) => `SECRET-TOKEN-${n}-do-not-leak`;
|
|
13
|
+
const target1 = (id, token) => ({
|
|
14
|
+
id,
|
|
15
|
+
platform: "ios",
|
|
16
|
+
appId: APP_ID,
|
|
17
|
+
token,
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Runs the `push-provider@1` conformance suite against one provider and its fake vendor. The suite
|
|
21
|
+
* never sleeps: `hang` settles on the signal's abort event.
|
|
22
|
+
*/
|
|
23
|
+
export function describePushProviderConformance(t) {
|
|
24
|
+
describe(`push provider conformance: ${t.plugin}`, () => {
|
|
25
|
+
async function run(outcome, fn) {
|
|
26
|
+
const h = await t.make();
|
|
27
|
+
try {
|
|
28
|
+
const token = secretToken(outcome);
|
|
29
|
+
h.arrange(token, outcome);
|
|
30
|
+
let settled;
|
|
31
|
+
const ac = new AbortController();
|
|
32
|
+
if (outcome === "hang")
|
|
33
|
+
queueMicrotask(() => ac.abort());
|
|
34
|
+
try {
|
|
35
|
+
settled = {
|
|
36
|
+
kind: "results",
|
|
37
|
+
results: await h.provider.send({
|
|
38
|
+
registrations: [target1("r1", token)],
|
|
39
|
+
message: MESSAGE,
|
|
40
|
+
signal: ac.signal,
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
settled = { kind: "threw", error };
|
|
46
|
+
}
|
|
47
|
+
await fn({ settled, token, requests: h.requests() });
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
await h.close();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** The one outcome of a call: a result for r1, or the kind of a thrown PushError. */
|
|
54
|
+
const outcomeOf = (s) => {
|
|
55
|
+
if (s.kind === "threw") {
|
|
56
|
+
if (s.error instanceof PushError)
|
|
57
|
+
return { status: "failed", kind: s.error.kind };
|
|
58
|
+
throw s.error;
|
|
59
|
+
}
|
|
60
|
+
expect(checkPushResults([target1("r1", "x")], s.results)).toBeNull();
|
|
61
|
+
const r = s.results[0];
|
|
62
|
+
return r.status === "failed" ? { status: "failed", kind: r.kind } : { status: r.status };
|
|
63
|
+
};
|
|
64
|
+
it("delivered answers delivered and the vendor request carries exactly the message", async () => {
|
|
65
|
+
await run("delivered", ({ settled, token, requests }) => {
|
|
66
|
+
expect(settled).toEqual({
|
|
67
|
+
kind: "results",
|
|
68
|
+
results: [{ registrationId: "r1", status: "delivered" }],
|
|
69
|
+
});
|
|
70
|
+
expect(requests).toEqual([{ token, ...MESSAGE }]);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
it("unregistered answers unregistered", async () => {
|
|
74
|
+
await run("unregistered", ({ settled }) => {
|
|
75
|
+
expect(outcomeOf(settled)).toEqual({ status: "unregistered" });
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it.each(["auth", "rate_limited", "transient"])("%s answers failed with that kind", async (outcome) => {
|
|
79
|
+
await run(outcome, ({ settled }) => {
|
|
80
|
+
expect(outcomeOf(settled)).toEqual({ status: "failed", kind: outcome });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
it("a network error yields transient", async () => {
|
|
84
|
+
await run("network_error", ({ settled }) => {
|
|
85
|
+
if (settled.kind === "threw") {
|
|
86
|
+
expect(settled.error).toBeInstanceOf(PushError);
|
|
87
|
+
expect(settled.error.kind).toBe("transient");
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
expect(outcomeOf(settled)).toEqual({ status: "failed", kind: "transient" });
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
it.each([
|
|
95
|
+
"delivered",
|
|
96
|
+
"unregistered",
|
|
97
|
+
"auth",
|
|
98
|
+
"rate_limited",
|
|
99
|
+
"transient",
|
|
100
|
+
"network_error",
|
|
101
|
+
])("%s is requested exactly once (no retries inside)", async (outcome) => {
|
|
102
|
+
await run(outcome, ({ requests, token }) => {
|
|
103
|
+
expect(requests.filter((r) => r.token === token)).toHaveLength(1);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
it("two registrations in one call get two results", async () => {
|
|
107
|
+
const h = await t.make();
|
|
108
|
+
try {
|
|
109
|
+
const regs = [target1("r1", secretToken("a")), target1("r2", secretToken("b"))];
|
|
110
|
+
for (const r of regs)
|
|
111
|
+
h.arrange(r.token, "delivered");
|
|
112
|
+
const results = await h.provider.send({
|
|
113
|
+
registrations: regs,
|
|
114
|
+
message: MESSAGE,
|
|
115
|
+
signal: new AbortController().signal,
|
|
116
|
+
});
|
|
117
|
+
expect(checkPushResults(regs, results)).toBeNull();
|
|
118
|
+
expect(results).toHaveLength(2);
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
await h.close();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
it("hang with an aborted signal settles without a timer", async () => {
|
|
125
|
+
await run("hang", ({ settled }) => {
|
|
126
|
+
if (settled.kind === "threw")
|
|
127
|
+
return;
|
|
128
|
+
expect(outcomeOf(settled)).toEqual({ status: "failed", kind: "transient" });
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
it.each([
|
|
132
|
+
"unregistered",
|
|
133
|
+
"auth",
|
|
134
|
+
"rate_limited",
|
|
135
|
+
"transient",
|
|
136
|
+
"network_error",
|
|
137
|
+
"hang",
|
|
138
|
+
])("%s leaks no token in a message", async (outcome) => {
|
|
139
|
+
await run(outcome, ({ settled, token }) => {
|
|
140
|
+
const messages = settled.kind === "threw"
|
|
141
|
+
? [settled.error instanceof Error ? settled.error.message : String(settled.error)]
|
|
142
|
+
: settled.results.flatMap((r) => (r.status === "failed" ? [r.message] : []));
|
|
143
|
+
for (const m of messages)
|
|
144
|
+
expect(m).not.toContain(token);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
it("apps() returns the same array twice and does not touch the vendor", async () => {
|
|
148
|
+
const h = await t.make();
|
|
149
|
+
try {
|
|
150
|
+
const first = h.provider.apps();
|
|
151
|
+
expect(h.provider.apps()).toBe(first);
|
|
152
|
+
expect(Array.isArray(first)).toBe(true);
|
|
153
|
+
expect(h.requests()).toEqual([]);
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
await h.close();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
package/dist/replica-runner.js
CHANGED
|
@@ -29,6 +29,8 @@ async function startKernel(c) {
|
|
|
29
29
|
extensionPermissions: { autoApprove: true },
|
|
30
30
|
// The official marketplace is on by default and on the internet: tests turn it on explicitly.
|
|
31
31
|
marketplaces: { official: { enabled: false } },
|
|
32
|
+
// Fake servers run on loopback: ctx.net may reach them
|
|
33
|
+
net: { allowInsecureLoopback: true },
|
|
32
34
|
log: { level: "error" },
|
|
33
35
|
};
|
|
34
36
|
const config = KernelConfigSchema.parse(deepMerge(base, c.overrides));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SandboxOperation } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/** Fixture setup only. All paths and symlink targets are absolute and inside the owned root. */
|
|
3
|
+
export type NativeFixtureEntry = {
|
|
4
|
+
path: string;
|
|
5
|
+
kind: "directory";
|
|
6
|
+
} | {
|
|
7
|
+
path: string;
|
|
8
|
+
kind: "file";
|
|
9
|
+
data: Uint8Array;
|
|
10
|
+
} | {
|
|
11
|
+
path: string;
|
|
12
|
+
kind: "symlink";
|
|
13
|
+
target: string;
|
|
14
|
+
};
|
|
15
|
+
/** Supplies isolated ordinary files and fresh native operations; never a permission grant. */
|
|
16
|
+
export interface SandboxNativeFixture {
|
|
17
|
+
/** An empty owned temporary directory, expressed as an absolute POSIX device path. */
|
|
18
|
+
root: string;
|
|
19
|
+
/** A new operation ID for each factory call, consumed by one native method invocation. */
|
|
20
|
+
operation(): Promise<Pick<SandboxOperation, "readFile" | "writeFile" | "stat" | "list" | "scan">>;
|
|
21
|
+
/** Creates entries and their parents inside root; preserves entries from earlier seed calls. */
|
|
22
|
+
seed(entries: readonly NativeFixtureEntry[]): Promise<void>;
|
|
23
|
+
/** Removes fixture-owned resources, including after an assertion failure. */
|
|
24
|
+
dispose(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Checks ordinary native API compatibility in a fixture-owned temporary root. Each invocation
|
|
28
|
+
* gets a fresh operation. Passing does not establish OS enforcement or permission capabilities.
|
|
29
|
+
* The fixture owns setup and cleanup; no official plugin, database or network service is used.
|
|
30
|
+
*/
|
|
31
|
+
export declare function runSandboxNativeConformance(fixture: SandboxNativeFixture): Promise<void>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { posix } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Checks ordinary native API compatibility in a fixture-owned temporary root. Each invocation
|
|
5
|
+
* gets a fresh operation. Passing does not establish OS enforcement or permission capabilities.
|
|
6
|
+
* The fixture owns setup and cleanup; no official plugin, database or network service is used.
|
|
7
|
+
*/
|
|
8
|
+
export async function runSandboxNativeConformance(fixture) {
|
|
9
|
+
const path = (name) => posix.join(fixture.root, name);
|
|
10
|
+
const signal = new AbortController().signal;
|
|
11
|
+
const fresh = async () => {
|
|
12
|
+
const operation = await fixture.operation();
|
|
13
|
+
assert(operation.list && operation.scan, "Native conformance requires list and scan");
|
|
14
|
+
return operation;
|
|
15
|
+
};
|
|
16
|
+
const read = async (name, maxBytes) => (await fresh()).readFile(path(name), { maxBytes, signal });
|
|
17
|
+
const stat = async (name) => (await fresh()).stat(path(name), signal);
|
|
18
|
+
const write = async (name, data) => (await fresh()).writeFile(path(name), data, signal);
|
|
19
|
+
const list = async (name, limit) => (await fresh()).list(path(name), { limit, signal });
|
|
20
|
+
const scan = async (name) => (await fresh()).scan(path(name), { signal });
|
|
21
|
+
const directory = (name) => ({ path: path(name), kind: "directory" });
|
|
22
|
+
const file = (name) => ({
|
|
23
|
+
path: path(name),
|
|
24
|
+
kind: "file",
|
|
25
|
+
data: new Uint8Array(),
|
|
26
|
+
});
|
|
27
|
+
const link = (name, target) => ({
|
|
28
|
+
path: path(name),
|
|
29
|
+
kind: "symlink",
|
|
30
|
+
target: path(target),
|
|
31
|
+
});
|
|
32
|
+
const candidates = (names) => names.map((name) => ({
|
|
33
|
+
path: path(name),
|
|
34
|
+
suggestedName: posix.basename(name),
|
|
35
|
+
}));
|
|
36
|
+
try {
|
|
37
|
+
assert.equal(await stat("missing"), null, "missing stat must return null");
|
|
38
|
+
assert.equal(await read("missing", 10), null, "missing read must return null");
|
|
39
|
+
assert.equal(await list("missing", 10), null, "missing list must return null");
|
|
40
|
+
assert.deepEqual(await scan("missing"), [], "missing scan must be empty");
|
|
41
|
+
await fixture.seed([directory("empty")]);
|
|
42
|
+
assert.equal((await stat("empty"))?.isDir, true);
|
|
43
|
+
assert.equal(await read("empty", 10), null, "directory read must return null");
|
|
44
|
+
assert.deepEqual(await list("empty", 0), { entries: [], truncated: false });
|
|
45
|
+
const bytes = new Uint8Array([0, 255, 128, 10, 65, 0]);
|
|
46
|
+
await write("parents/nested/binary", bytes);
|
|
47
|
+
assert.deepEqual(await stat("parents/nested/binary"), { size: 6, isDir: false });
|
|
48
|
+
assert.deepEqual(await read("parents/nested/binary", 6), { data: bytes, truncated: false });
|
|
49
|
+
assert.deepEqual(await read("parents/nested/binary", 100), { data: bytes, truncated: false });
|
|
50
|
+
assert.deepEqual(await read("parents/nested/binary", 3), {
|
|
51
|
+
data: new Uint8Array([0, 255, 128]),
|
|
52
|
+
truncated: true,
|
|
53
|
+
});
|
|
54
|
+
assert.deepEqual(await read("parents/nested/binary", 0), {
|
|
55
|
+
data: new Uint8Array(),
|
|
56
|
+
truncated: true,
|
|
57
|
+
});
|
|
58
|
+
await write("parents/nested/binary", new Uint8Array());
|
|
59
|
+
assert.deepEqual(await read("parents/nested/binary", 0), {
|
|
60
|
+
data: new Uint8Array(),
|
|
61
|
+
truncated: false,
|
|
62
|
+
});
|
|
63
|
+
assert.deepEqual(await stat("parents/nested/binary"), { size: 0, isDir: false });
|
|
64
|
+
assert.equal(await stat("parents/nested/binary/missing"), null);
|
|
65
|
+
assert.equal(await read("parents/nested/binary/missing", 10), null);
|
|
66
|
+
assert.equal(await list("parents/nested/binary/missing", 10), null);
|
|
67
|
+
assert.deepEqual(await scan("parents/nested/binary/missing"), []);
|
|
68
|
+
await assert.rejects(() => list("parents/nested/binary", 5));
|
|
69
|
+
await assert.rejects(() => scan("parents/nested/binary"));
|
|
70
|
+
await fixture.seed([
|
|
71
|
+
directory("listing/B"),
|
|
72
|
+
file("listing/a"),
|
|
73
|
+
file("listing/\u{1f600}"),
|
|
74
|
+
file("listing/\ue000"),
|
|
75
|
+
link("listing/alias", "listing/B"),
|
|
76
|
+
link("listing/dangling", "listing/missing"),
|
|
77
|
+
link("file-link", "listing/a"),
|
|
78
|
+
]);
|
|
79
|
+
assert.deepEqual(await list("listing", 0), { entries: [], truncated: true });
|
|
80
|
+
assert.deepEqual(await list("listing", 2), {
|
|
81
|
+
entries: [
|
|
82
|
+
{ name: "B", isDir: true },
|
|
83
|
+
{ name: "a", isDir: false },
|
|
84
|
+
],
|
|
85
|
+
truncated: true,
|
|
86
|
+
});
|
|
87
|
+
assert.deepEqual(await list("listing", 6), {
|
|
88
|
+
entries: [
|
|
89
|
+
{ name: "B", isDir: true },
|
|
90
|
+
{ name: "a", isDir: false },
|
|
91
|
+
{ name: "alias", isDir: true },
|
|
92
|
+
{ name: "dangling", isDir: false },
|
|
93
|
+
{ name: "\u{1f600}", isDir: false },
|
|
94
|
+
{ name: "\ue000", isDir: false },
|
|
95
|
+
],
|
|
96
|
+
truncated: false,
|
|
97
|
+
});
|
|
98
|
+
await write("file-link", bytes);
|
|
99
|
+
assert.deepEqual(await read("listing/a", 6), { data: bytes, truncated: false });
|
|
100
|
+
assert.deepEqual(await stat("file-link"), { size: 6, isDir: false });
|
|
101
|
+
assert.deepEqual(await list("listing/alias", 1), { entries: [], truncated: false });
|
|
102
|
+
assert.equal(await read("listing/dangling", 10), null);
|
|
103
|
+
await assert.rejects(() => write("listing/dangling", bytes));
|
|
104
|
+
assert.equal(await stat("listing/missing"), null, "dangling writes must not create a target");
|
|
105
|
+
await fixture.seed([file("percent/a%2f%ZZ/AGENTS.md"), file("percent/a%5c%/AGENTS.md")]);
|
|
106
|
+
assert.deepEqual(await scan("percent"), candidates(["percent/a%2f%ZZ", "percent/a%5c%"]));
|
|
107
|
+
const longName = "x".repeat(65);
|
|
108
|
+
await fixture.seed([
|
|
109
|
+
file("scan/AGENTS.md"),
|
|
110
|
+
file("scan/a/.git"),
|
|
111
|
+
file("scan/a/deep/AGENTS.md"),
|
|
112
|
+
file("scan/a/deep/too-deep/.git"),
|
|
113
|
+
directory("scan/false-hit/AGENTS.md"),
|
|
114
|
+
file("scan/.hidden/.git"),
|
|
115
|
+
file("scan/node_modules/.git"),
|
|
116
|
+
file("scan/Library/.git"),
|
|
117
|
+
file("scan/a/node_modules/.git"),
|
|
118
|
+
file("scan/a/Library/.git"),
|
|
119
|
+
file(`scan/${longName}/.git`),
|
|
120
|
+
file(`scan/${longName}/valid/.git`),
|
|
121
|
+
file("scan/ leading/.git"),
|
|
122
|
+
file("scan/ trailing /.git"),
|
|
123
|
+
file("scan/ leading/valid/.git"),
|
|
124
|
+
link("scan/link", "scan/a"),
|
|
125
|
+
]);
|
|
126
|
+
assert.deepEqual(await scan("scan"), candidates([
|
|
127
|
+
"scan",
|
|
128
|
+
"scan/ leading/valid",
|
|
129
|
+
"scan/a",
|
|
130
|
+
"scan/a/Library",
|
|
131
|
+
"scan/a/deep",
|
|
132
|
+
`scan/${longName}/valid`,
|
|
133
|
+
]), "scan must descend past hits and invalid names, and apply depth/skips exactly");
|
|
134
|
+
await fixture.seed([
|
|
135
|
+
...Array.from({ length: 51 }, (_, i) => file(`results/b${String(i).padStart(3, "0")}/.git`)),
|
|
136
|
+
file("results/a/deep/.git"),
|
|
137
|
+
]);
|
|
138
|
+
assert.deepEqual(await scan("results"), candidates([
|
|
139
|
+
"results/a/deep",
|
|
140
|
+
...Array.from({ length: 49 }, (_, i) => `results/b${String(i).padStart(3, "0")}`),
|
|
141
|
+
]), "scan truncates to 50 only after sorting all visited candidates");
|
|
142
|
+
await fixture.seed([
|
|
143
|
+
...Array.from({ length: 500 }, (_, i) => directory(`visits/d${String(i).padStart(3, "0")}`)),
|
|
144
|
+
file("visits/d498/.git"),
|
|
145
|
+
file("visits/d499/.git"),
|
|
146
|
+
file("visits/d000/deep/.git"),
|
|
147
|
+
]);
|
|
148
|
+
assert.deepEqual(await scan("visits"), candidates(["visits/d498"]), "base counts as visit one; breadth-first visit 500 includes d498, excludes d499 and depth two");
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
await fixture.dispose();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { type PermissionProfile, type SandboxFileScope, type SandboxNetworkScope, type SandboxOperation, type SandboxPermissionSupport } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { NativeFixtureEntry } from "./sandbox-native-conformance.js";
|
|
3
|
+
/** A controlled endpoint whose receipts the fixture counts out of band (never via the device). */
|
|
4
|
+
export interface SandboxPermissionEndpoint {
|
|
5
|
+
/**
|
|
6
|
+
* The host name a scope allowlists for this endpoint (it must pass `validateAllowHost`, which
|
|
7
|
+
* refuses IP literals). The provider or fixture maps it to the endpoint; an ungranted endpoint's
|
|
8
|
+
* name is never allowlisted, so a proxy asked for it by name must refuse.
|
|
9
|
+
*/
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
* The endpoint's numeric address (an IP literal) for raw socket clients: the pointer race and
|
|
13
|
+
* the ungranted, network-none and escalated controls connect here. The granted endpoint's address and
|
|
14
|
+
* at least one ungranted address are IPv4 (the race program builds IPv4 socket addresses).
|
|
15
|
+
*/
|
|
16
|
+
readonly address: string;
|
|
17
|
+
readonly port: number;
|
|
18
|
+
/** Accepted connections so far, observed by the endpoint itself. */
|
|
19
|
+
receipts(): Promise<number>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A destination a sandboxed client asks for by URL (`http://<host>:<port>/`) through the proxy the
|
|
23
|
+
* operation's environment names, when it has one.
|
|
24
|
+
*/
|
|
25
|
+
export interface SandboxPermissionTarget {
|
|
26
|
+
/** A short label for messages (letters, digits, `-`). */
|
|
27
|
+
readonly label: string;
|
|
28
|
+
/** A host name or an IP literal (an IPv6 literal without brackets). */
|
|
29
|
+
readonly host: string;
|
|
30
|
+
readonly port: number;
|
|
31
|
+
/**
|
|
32
|
+
* The numeric address the target is served at, for a raw connect that bypasses the proxy (a
|
|
33
|
+
* proxied provider must refuse it). Omit where it is not known (a public name on the internet).
|
|
34
|
+
*/
|
|
35
|
+
readonly address?: string;
|
|
36
|
+
/** Accepted connections so far, observed by the target itself; omit where none can be counted. */
|
|
37
|
+
receipts?(): Promise<number>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The open public network (approval-only profiles design, "Open network"). Every target here is
|
|
41
|
+
* asked for under the `open-public` network, once per profile.
|
|
42
|
+
*/
|
|
43
|
+
export interface SandboxPermissionOpenNetwork {
|
|
44
|
+
/**
|
|
45
|
+
* Set only where no public target can be reached here at all (offline): without it the harness
|
|
46
|
+
* fails when every reachable list (`reachable`, `fakeIp.reachable`) is empty or unavailable.
|
|
47
|
+
*/
|
|
48
|
+
readonly allowNoPositive?: true;
|
|
49
|
+
/**
|
|
50
|
+
* Public targets the open network reaches, by name and by literal. `{ unavailable }` where no
|
|
51
|
+
* public target can be reached from here (no internet and no stand-in), with the reason; every
|
|
52
|
+
* refusal still runs.
|
|
53
|
+
*/
|
|
54
|
+
readonly reachable: readonly SandboxPermissionTarget[] | {
|
|
55
|
+
readonly unavailable: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Destinations in the closed classes (private, CGNAT, ULA, link-local and metadata, loopback and
|
|
59
|
+
* the host's own addresses, NAT64, benchmark), as IP literals in several spellings and as names
|
|
60
|
+
* resolving there (a DNS rebinding name). Each must be refused; those with receipts see nothing.
|
|
61
|
+
*/
|
|
62
|
+
readonly closed: readonly SandboxPermissionTarget[];
|
|
63
|
+
/**
|
|
64
|
+
* Names the device's resolver answers with a fake-IP address (198.18.0.0/15) while encrypted DNS
|
|
65
|
+
* knows the real one: `reachable` resolve to public addresses, `closed` to closed classes or not
|
|
66
|
+
* at all. `{ unavailable }` with the reason where no fake-IP resolver stands in front of the
|
|
67
|
+
* device here.
|
|
68
|
+
*/
|
|
69
|
+
readonly fakeIp?: {
|
|
70
|
+
readonly reachable: readonly SandboxPermissionTarget[];
|
|
71
|
+
readonly closed: readonly SandboxPermissionTarget[];
|
|
72
|
+
} | {
|
|
73
|
+
readonly unavailable: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** The scope one fresh operation receives; the fixture adds the IDs and revisions. */
|
|
77
|
+
export interface SandboxPermissionGrant {
|
|
78
|
+
readonly profile: PermissionProfile;
|
|
79
|
+
readonly filesystem: SandboxFileScope;
|
|
80
|
+
readonly network: SandboxNetworkScope;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The actual provider under test, on one shared device. All paths are absolute device paths on one
|
|
84
|
+
* shared filesystem; `root` and `sibling` are empty directories owned by the device user. The
|
|
85
|
+
* device must provide `/bin/sh`, `python3`, `node` and `curl`. Inspection is trusted, out of band
|
|
86
|
+
* and read-only; it never runs through a restricted operation and never grants anything.
|
|
87
|
+
*/
|
|
88
|
+
export interface SandboxPermissionFixture {
|
|
89
|
+
/**
|
|
90
|
+
* The project root granted (writable) to restricted operations. On an instance-boundary provider
|
|
91
|
+
* both `root` and `sibling` lie in the instance, whose whole filesystem is the scope.
|
|
92
|
+
*/
|
|
93
|
+
readonly root: string;
|
|
94
|
+
/** A directory outside every restricted grant, on the same filesystem. */
|
|
95
|
+
readonly sibling: string;
|
|
96
|
+
/** Existing files the device user may write ordinarily but no restricted grant covers. */
|
|
97
|
+
readonly protectedPaths: readonly string[];
|
|
98
|
+
/** `granted` is reachable by allowlisting its name; `ungranted` never is. */
|
|
99
|
+
readonly endpoints: {
|
|
100
|
+
readonly granted: SandboxPermissionEndpoint;
|
|
101
|
+
readonly ungranted: readonly SandboxPermissionEndpoint[];
|
|
102
|
+
/**
|
|
103
|
+
* How a restricted allowlist operation reaches `granted`:
|
|
104
|
+
* - `direct`: by connecting to its address (the provider admits the address it maps the
|
|
105
|
+
* allowlisted name to); Python, curl and Node connect straight to it.
|
|
106
|
+
* - `proxy`: only through the HTTP proxy the provider names in the operation's environment
|
|
107
|
+
* (`http_proxy`, the variable curl and Python read for http URLs), which resolves `name`.
|
|
108
|
+
* Positives use curl and Python through that proxy; raw connects to the address are not
|
|
109
|
+
* expected to work, and the pointer race targets the proxy instead.
|
|
110
|
+
* Either way the device needs no name resolution of its own for endpoint names.
|
|
111
|
+
*/
|
|
112
|
+
readonly access: "direct" | "proxy";
|
|
113
|
+
/**
|
|
114
|
+
* `{ unavailable }` with the reason where the fixture cannot make the allowlisted name lead to
|
|
115
|
+
* `granted` without changing the host (macOS: no hosts-file entry, and the runtime's proxy
|
|
116
|
+
* refuses a name that resolves to loopback, by design). The by-name positives are then skipped
|
|
117
|
+
* (and reported unavailable) and `granted` must see no connection at all; every negative still
|
|
118
|
+
* runs. The positive allowlist reach is then the provider's own test's evidence (state it next
|
|
119
|
+
* to the fixture). Default "available".
|
|
120
|
+
*/
|
|
121
|
+
readonly namedReach?: "available" | {
|
|
122
|
+
readonly unavailable: string;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Names on every allowlist the device applies (the scope's, the owner's and the org's) that
|
|
126
|
+
* resolve into a closed address class: an allowlist grant never reaches a closed class, so
|
|
127
|
+
* each must be refused and see no connection. Required for a provider with restricted support
|
|
128
|
+
* and for an instance boundary (there at least one target whose `address` is a cloud metadata
|
|
129
|
+
* address); `{ unavailable }` with the reason only where no name can resolve into a closed
|
|
130
|
+
* class through the provider's own allowlist path (a stand-in proxy), reported unavailable.
|
|
131
|
+
*/
|
|
132
|
+
readonly closedGranted?: readonly SandboxPermissionTarget[] | {
|
|
133
|
+
readonly unavailable: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* The open public network's targets. Required when the provider reports
|
|
138
|
+
* `network.openPublic`: the harness then proves the open network under every profile.
|
|
139
|
+
*/
|
|
140
|
+
readonly openNetwork?: SandboxPermissionOpenNetwork;
|
|
141
|
+
/**
|
|
142
|
+
* Variables present in the environment of the device program (or the provider process) that runs
|
|
143
|
+
* the operations: at least one secret-looking (`AWS_SECRET_ACCESS_KEY`) and at least one
|
|
144
|
+
* innocent-looking name (no `SECRET`, `TOKEN`, `KEY`, `PASS`, `CREDENTIAL` or `CAPYBARA_` in it),
|
|
145
|
+
* so a denylist cannot pass for a minimal environment. No sandboxed command under any profile may
|
|
146
|
+
* see one of their values, and on an operation boundary its variable names must all be in the
|
|
147
|
+
* minimal set (approval-only profiles design, "Fixed denies and the minimal environment"):
|
|
148
|
+
* `PATH`, `LANG`, `HOME`, `TMPDIR` / `TMP` / `TEMP`, the proxy variables (any name containing
|
|
149
|
+
* `PROXY`), what the shell itself sets (`PWD`, `OLDPWD`, `SHLVL`, `_`), and `allowed`: the tool
|
|
150
|
+
* homes and runtime variables this provider adds (state each). With `escalatedControl` (and
|
|
151
|
+
* outside-sandbox support), an escalated call must see every planted variable whose name does
|
|
152
|
+
* not start with `CAPYBARA_` and none that does: the planted values are real, and the device's
|
|
153
|
+
* own variables stay out even there. Required for a provider with restricted support.
|
|
154
|
+
*/
|
|
155
|
+
readonly deviceEnvironment?: {
|
|
156
|
+
readonly variables: Readonly<Record<string, string>>;
|
|
157
|
+
readonly escalatedControl: boolean;
|
|
158
|
+
readonly allowed?: readonly string[];
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Turns the owner's outside-sandbox setting off and returns a function that restores it. The
|
|
162
|
+
* harness proves that the escalated pair runs only while the setting allows it. Required when
|
|
163
|
+
* the provider reports `outsideSandbox`.
|
|
164
|
+
*/
|
|
165
|
+
withoutOutsideSandbox?(): Promise<() => Promise<void>>;
|
|
166
|
+
/**
|
|
167
|
+
* The device user's home, where the protected home locations (shell startup files and the rest of
|
|
168
|
+
* `SANDBOX_MANDATORY_WRITE_DENIES`) resolve for operations started from now on. When present,
|
|
169
|
+
* the harness links `.zprofile` there through a chain of symbolic links into the granted root
|
|
170
|
+
* (seeded with `seed`, which may write under this path) and proves that no hop of the chain and
|
|
171
|
+
* not the target can be written, retargeted or moved away; `remove` deletes the entry it
|
|
172
|
+
* seeded under the home afterwards. `{ unavailable }` with the reason where the provider has no
|
|
173
|
+
* owner home to protect (reported unavailable); required for a provider with restricted support.
|
|
174
|
+
*/
|
|
175
|
+
readonly home?: {
|
|
176
|
+
readonly path: string;
|
|
177
|
+
remove(path: string): Promise<void>;
|
|
178
|
+
} | {
|
|
179
|
+
readonly unavailable: string;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* For an instance-boundary provider (`boundary: "instance"`: the container or microVM is the
|
|
183
|
+
* sandbox): its outer network, which the harness proves instead of per-operation networks.
|
|
184
|
+
* "open" needs {@link openNetwork}; "allowlist" allows exactly the granted endpoint's name.
|
|
185
|
+
*/
|
|
186
|
+
readonly instanceNetwork?: "open" | "allowlist";
|
|
187
|
+
/**
|
|
188
|
+
* How restricted commands meet the mandatory write denies in other spellings of a protected
|
|
189
|
+
* name. "nfkc" (default): every spelling whose NFKC case fold is protected is refused, as the
|
|
190
|
+
* shared SDK policy compares names. "filesystem": the runtime enforces paths as the filesystem
|
|
191
|
+
* resolves them (macOS Seatbelt on case-insensitive APFS: ASCII case and the Unicode case folds
|
|
192
|
+
* APFS applies, such as the Kelvin sign for `k`, reach the protected file and are refused, while
|
|
193
|
+
* compatibility forms such as fullwidth letters are distinct files there); the harness then
|
|
194
|
+
* proves that a fullwidth spelling created a distinct file and never the protected one.
|
|
195
|
+
*/
|
|
196
|
+
readonly foldedNames?: "nfkc" | "filesystem";
|
|
197
|
+
/**
|
|
198
|
+
* Whether restricted none/allowlist operations may listen on loopback. "allowed" (default, Linux):
|
|
199
|
+
* loopback only, every wildcard address refused, a UNIX socket inside the root works,
|
|
200
|
+
* `SO_REUSEPORT` is refused, no sandboxed client connects to a loopback listener (the command's
|
|
201
|
+
* own included), and a client outside the sandbox (an escalated call) reaches the command's
|
|
202
|
+
* listener. "refused" (macOS): the runtime refuses every listener, loopback and UNIX sockets
|
|
203
|
+
* inside the root included (the macOS worker runs its runtime with local binding off).
|
|
204
|
+
*/
|
|
205
|
+
readonly restrictedLoopbackListen?: "allowed" | "refused";
|
|
206
|
+
/**
|
|
207
|
+
* Whether cancellation must also end a descendant that left the command's process group
|
|
208
|
+
* (fork + setpgid). "ended" (default): it must, as Linux PID namespaces and cgroups provide.
|
|
209
|
+
* "not-promised": the runtime ends the owned process group and what stays in it, and does not
|
|
210
|
+
* promise to rediscover a regrouped descendant (macOS, permission operation contract "Explicit
|
|
211
|
+
* background supervision"); the harness then leaves that case out.
|
|
212
|
+
*/
|
|
213
|
+
readonly regroupedDescendants?: "ended" | "not-promised";
|
|
214
|
+
/** The provider's own runtime report; the harness never infers support from a fixture. */
|
|
215
|
+
support(): Promise<SandboxPermissionSupport>;
|
|
216
|
+
/** A fresh operation (new operation ID) for the grant, through the provider's factory. */
|
|
217
|
+
operation(grant: SandboxPermissionGrant): Promise<SandboxOperation>;
|
|
218
|
+
/** Trusted setup under root or sibling; preserves entries from earlier calls. */
|
|
219
|
+
seed(entries: readonly NativeFixtureEntry[]): Promise<void>;
|
|
220
|
+
inspect: {
|
|
221
|
+
readFile(path: string): Promise<Uint8Array | null>;
|
|
222
|
+
/** Permission bits (`st_mode & 0o7777`), or null when missing. */
|
|
223
|
+
mode(path: string): Promise<number | null>;
|
|
224
|
+
/**
|
|
225
|
+
* The subset of `pids` still running on the device (a zombie waiting for its reaper may count
|
|
226
|
+
* either way: the harness polls until the killed ones are gone).
|
|
227
|
+
*/
|
|
228
|
+
alive(pids: readonly number[]): Promise<number[]>;
|
|
229
|
+
/**
|
|
230
|
+
* Runs a Python 3 program (`python3 - ...args`, program on stdin) as the device user in a
|
|
231
|
+
* fresh process outside every operation and every restricted domain, standing in for another
|
|
232
|
+
* session's Full-access work, and returns its stdout. When present, the harness proves that
|
|
233
|
+
* such a process can neither ptrace nor read the memory or environment of the process that
|
|
234
|
+
* supervises a restricted command (its parent). Omit it only where no process outside an
|
|
235
|
+
* operation can run as the device user.
|
|
236
|
+
*/
|
|
237
|
+
outside?(program: string, args: readonly string[]): Promise<string>;
|
|
238
|
+
};
|
|
239
|
+
/** Removes fixture-owned resources, including after an assertion failure. */
|
|
240
|
+
dispose(): Promise<void>;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* A part of the operation-boundary conformance, for runs that split it (each part needs a fresh
|
|
244
|
+
* fixture; the setup, positive controls and the scope contract run in every part):
|
|
245
|
+
* - `filesystem`: mandatory denies, reserved names, protected link chains, git work, sibling and
|
|
246
|
+
* protected-path denials, every profile sandboxed with the minimal environment;
|
|
247
|
+
* - `network`: allowlist, closed classes, loopback listeners, the open network, UNIX sockets;
|
|
248
|
+
* - `processes`: escalated-pair controls, overlaps, swaps and pointer races, the supervisor,
|
|
249
|
+
* cancellation and narrowed scopes.
|
|
250
|
+
*/
|
|
251
|
+
export type SandboxPermissionConformancePart = "filesystem" | "network" | "processes";
|
|
252
|
+
/**
|
|
253
|
+
* The approval-only checks of the operation-boundary conformance, for a focused rerun or a harness
|
|
254
|
+
* self-test (`checks`: only these, after the setup, positive controls and the scope contract):
|
|
255
|
+
* `outside-switch` (processes), `environment`, `reserved-names` and `link-chain` (filesystem),
|
|
256
|
+
* `closed-granted`, `loopback`, `open-network` and `foreign-unix` (network).
|
|
257
|
+
*/
|
|
258
|
+
export type SandboxPermissionConformanceCheck = "outside-switch" | "environment" | "reserved-names" | "link-chain" | "closed-granted" | "loopback" | "open-network" | "foreign-unix";
|
|
259
|
+
export interface SandboxPermissionConformanceOptions {
|
|
260
|
+
/** Only these parts (each needs a fresh fixture); never empty. Default: every part. */
|
|
261
|
+
readonly parts?: readonly SandboxPermissionConformancePart[];
|
|
262
|
+
/** Only these approval-only checks (see {@link SandboxPermissionConformanceCheck}); never empty. */
|
|
263
|
+
readonly checks?: readonly SandboxPermissionConformanceCheck[];
|
|
264
|
+
}
|
|
265
|
+
/** What a run could not prove here, each with the fixture's reason (annotate or log them). */
|
|
266
|
+
export interface SandboxPermissionConformanceReport {
|
|
267
|
+
readonly unavailable: readonly {
|
|
268
|
+
readonly item: string;
|
|
269
|
+
readonly reason: string;
|
|
270
|
+
}[];
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Proves an actual provider's permission boundary on one shared device (approval-only profiles
|
|
274
|
+
* design). The sandbox is the device's and the same under every profile: a profile only chooses
|
|
275
|
+
* who approves a crossing, so every profile's ordinary call is sandboxed, and only the escalated
|
|
276
|
+
* pair (the device filesystem with the environment network, legal only together) runs outside it,
|
|
277
|
+
* and only with outside-sandbox support while the owner allows it.
|
|
278
|
+
*
|
|
279
|
+
* An operation-boundary provider (a local device) is proved with positive controls; sibling,
|
|
280
|
+
* symlink, protected-path, mandatory-deny, reserved-name, protected-link-chain and network
|
|
281
|
+
* denials; every profile sandboxed with the minimal environment; the open network (closed classes
|
|
282
|
+
* refused by resolved address, rebinding and fake-IP names included) and the allowlist (closed
|
|
283
|
+
* classes refused even for granted names); loopback listeners (Linux: loopback only, no sandboxed
|
|
284
|
+
* connect to any, its own included, no `SO_REUSEPORT`; macOS: none at all); escalated-pair
|
|
285
|
+
* controls outside the sandbox; both overlap orders; component/root swaps and mutable syscall
|
|
286
|
+
* pointers during access; exact cancellation; a supervisor closed to same-uid outsiders (when the
|
|
287
|
+
* fixture can run one) and fresh narrowed scopes. Pathname UNIX services outside the roots stay
|
|
288
|
+
* unreachable under every sandbox network, and so does one another process made inside a write
|
|
289
|
+
* root (only the operation's own sockets are reachable). A provider that reports restricted unsupported must
|
|
290
|
+
* refuse restricted operations (fail closed); nothing here substitutes a fixture flag for support.
|
|
291
|
+
*
|
|
292
|
+
* An instance-boundary provider (a cloud device: the container or microVM is the sandbox) is
|
|
293
|
+
* proved with every profile running alike in the instance (its whole filesystem the scope),
|
|
294
|
+
* nothing outside it, the outer network (open or allowlist) for every operation, and exact
|
|
295
|
+
* cancellation.
|
|
296
|
+
*
|
|
297
|
+
* Not covered, by design (known limitations, not passes): metadata reads outside the roots (stat,
|
|
298
|
+
* readlink, xattrs, statfs), and the world-readable `/proc/<pid>` entries of other processes of the
|
|
299
|
+
* same uid, such as `cmdline`, `stat` and `status`. A restricted operation can therefore read the
|
|
300
|
+
* command line of a concurrent escalated command on the device: Landlock cannot scope `/proc` to the
|
|
301
|
+
* operation's own process tree (see the Linux launcher's known limitations). Providers keep secrets
|
|
302
|
+
* out of command lines; ptrace-guarded entries (`environ`, `mem`, `maps`, `fd`) stay closed.
|
|
303
|
+
*/
|
|
304
|
+
export declare function runSandboxPermissionConformance(fixture: SandboxPermissionFixture, options?: SandboxPermissionConformanceOptions): Promise<SandboxPermissionConformanceReport>;
|
|
305
|
+
/**
|
|
306
|
+
* Polls a trusted read until `path` exists, racing the operation that should create it: if that
|
|
307
|
+
* operation settles first (refused, failed or exited without the file), this throws at once with
|
|
308
|
+
* the operation's error or exit, after one last read. The operation's rejection is always handled.
|
|
309
|
+
*/
|
|
310
|
+
export declare function waitForFile(read: (path: string) => Promise<Uint8Array | null>, path: string, pending: Promise<unknown>): Promise<void>;
|