@agentswf/sandbox 0.1.0-beta.0 → 0.1.0-beta.1
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/package.json +1 -1
- package/src/docker/index.ts +5 -0
- package/src/resolve.ts +8 -2
- package/src/srt/index.ts +2 -0
- package/src/srt/profile.ts +10 -2
package/package.json
CHANGED
package/src/docker/index.ts
CHANGED
|
@@ -133,6 +133,11 @@ async function openBox(
|
|
|
133
133
|
}
|
|
134
134
|
return result.stdout.trim();
|
|
135
135
|
};
|
|
136
|
+
if (spec.sockets.length > 0) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`docker: a box cannot reach host sockets (${spec.sockets.join(", ")}); use srt`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
136
141
|
const socket = daemonSocket(client.environment);
|
|
137
142
|
for (const path of [spec.cwd, ...spec.read, ...spec.write]) {
|
|
138
143
|
// A box that can reach the daemon can start a container with the host mounted.
|
package/src/resolve.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { isRecord } from "@agentswf/contract";
|
|
|
5
5
|
import { SANDBOX_ENVIRONMENTS, type SandboxEnvironmentKey } from "@agentswf/contract/workflow";
|
|
6
6
|
import type { Gitdir, ResolvedSandbox, SandboxProviders } from "./seam";
|
|
7
7
|
|
|
8
|
-
const REACH_KEYS = ["read", "write", "network"] as const;
|
|
8
|
+
const REACH_KEYS = ["read", "write", "network", "sockets", "webSearch"] as const;
|
|
9
9
|
|
|
10
10
|
export type SandboxResolution = {
|
|
11
11
|
/** The environment key the sandbox runs under: the one the spec named, else the default. */
|
|
@@ -110,7 +110,7 @@ export async function resolveSandbox(
|
|
|
110
110
|
await resolvePath(spec.cwd === undefined ? "." : spec.cwd, options.cwd, home, "cwd"),
|
|
111
111
|
"cwd",
|
|
112
112
|
);
|
|
113
|
-
const paths = (field: "read" | "write") =>
|
|
113
|
+
const paths = (field: "read" | "write" | "sockets") =>
|
|
114
114
|
Promise.all(
|
|
115
115
|
list(spec[field], field).map(async (path) =>
|
|
116
116
|
forbidden(await resolvePath(path, cwd, home, field), field),
|
|
@@ -118,6 +118,10 @@ export async function resolveSandbox(
|
|
|
118
118
|
);
|
|
119
119
|
const write = unique(await paths("write"));
|
|
120
120
|
const read = unique(await paths("read")).filter((path) => !write.includes(path));
|
|
121
|
+
const sockets = unique(await paths("sockets"));
|
|
122
|
+
if (spec.webSearch !== undefined && typeof spec.webSearch !== "boolean") {
|
|
123
|
+
throw new Error("sandbox webSearch must be true or false");
|
|
124
|
+
}
|
|
121
125
|
const network = unique(
|
|
122
126
|
list(spec.network, "network").map((domain) => {
|
|
123
127
|
if (!isDomain(domain)) throw new Error(`not a sandbox domain: ${JSON.stringify(domain)}`);
|
|
@@ -174,6 +178,8 @@ export async function resolveSandbox(
|
|
|
174
178
|
read,
|
|
175
179
|
write,
|
|
176
180
|
network,
|
|
181
|
+
sockets,
|
|
182
|
+
webSearch: spec.webSearch === true,
|
|
177
183
|
hidden: holdsRunRoot ? [runRoot] : [],
|
|
178
184
|
gitdirs: [...gitdirs].map(([path, { own, linked }]): Gitdir => {
|
|
179
185
|
// A submodule's gitdir is in its superproject's `modules`, which is guarded whole: it is
|
package/src/srt/index.ts
CHANGED
package/src/srt/profile.ts
CHANGED
|
@@ -63,7 +63,11 @@ export function baseProfile(
|
|
|
63
63
|
const gitdirs = spec.gitdirs.map((gitdir) => gitdir.path);
|
|
64
64
|
return {
|
|
65
65
|
enableWeakerNetworkIsolation: true,
|
|
66
|
-
network: {
|
|
66
|
+
network: {
|
|
67
|
+
allowedDomains: [...spec.network],
|
|
68
|
+
deniedDomains: [],
|
|
69
|
+
allowUnixSockets: [...spec.sockets],
|
|
70
|
+
},
|
|
67
71
|
filesystem: {
|
|
68
72
|
denyRead: unique([host.home, ...DENIED, context.runRoot, ...spec.hidden]),
|
|
69
73
|
allowRead: unique([
|
|
@@ -117,7 +121,11 @@ export function agentProfile(
|
|
|
117
121
|
network: {
|
|
118
122
|
...base.network,
|
|
119
123
|
allowedDomains: unique([...base.network.allowedDomains, ...agent.harness.domains]),
|
|
120
|
-
allowUnixSockets:
|
|
124
|
+
allowUnixSockets: unique([
|
|
125
|
+
...base.network.allowUnixSockets,
|
|
126
|
+
agent.door.endpoint,
|
|
127
|
+
...(short ? [short] : []),
|
|
128
|
+
]),
|
|
121
129
|
},
|
|
122
130
|
filesystem: {
|
|
123
131
|
...base.filesystem,
|