You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Custom tools |**Off**|`--enable-tools`, `--tool NAME=WASM` with `wasm-host-fns`, or `SandboxBuilder::tool()`|
18
+
| Custom tools |**Off**|`--tool NAME=WASM` with `wasm-host-fns`, `SandboxBuilder::tool()`, or legacy/demo `--enable-tools` echo|
19
19
20
20
With **no flags**, the guest cannot reach the host filesystem or network through dispatch. Only internal plumbing (`__hl_exit`, `__hl_sleep`) is wired.
|`--net-block HOST_OR_IP`| Block-list; all other destinations allowed (implies `--net`). Mutually exclusive with `--net-allow`. |
87
87
|`--port PORT`| Allow `net_bind` / listen on `PORT` (implies `--net`). Without `--port`, outbound-only: bind is rejected. |
88
-
|`--enable-tools`| Registers a built-in `echo` tool (used by the `python-tools` example). Library users add their own tools via `SandboxBuilder::tool()`. |
89
-
|`--tool NAME=WASM`| With the Cargo feature `wasm-host-fns`, registers `WASM` as a WASIp1 custom tool named `NAME`. Repeatable. |
90
-
|`--tool-wasi-dir HOST[:GUEST]`| Preopens a read-write host directory for all Wasm tools. Default guest path is `/host`. Repeatable. |
91
-
|`--tool-wasi-dir-ro HOST[:GUEST]`| Preopens a read-only host directory for all Wasm tools. Default guest path is `/host`. Repeatable. |
92
-
|`--tool-wasi-env KEY=VALUE`| Sets an environment variable for all Wasm tools. Repeatable. |
93
-
|`--tool-wasi-env-inherit KEY`| Copies one host environment variable into all Wasm tools. Repeatable. |
94
-
|`--tool-wasi-fuel FUEL`| Sets the instruction-fuel budget for each Wasm tool call. Default `100000000`. |
95
-
|`--tool-wasi-output-limit SIZE`| Caps captured stdout and stderr per Wasm tool call. Default `1Mi`. |
88
+
|`--enable-tools`| Registers only the built-in `echo` demo tool. It does not load user code; prefer `--tool NAME=WASM` for CLI custom tools or `SandboxBuilder::tool()` for library users. |
89
+
|`--tool NAME=WASM`| With the Cargo feature `wasm-host-fns`, registers `WASM` as a host-side WASIp1 custom tool named `NAME`. Repeatable. |
90
+
|`--tool-wasi-dir HOST[:GUEST]`| Preopens a read-write host directory for every CLI Wasm tool. Default guest path is `/host`. Repeatable. |
91
+
|`--tool-wasi-dir-ro HOST[:GUEST]`| Preopens a read-only host directory for every CLI Wasm tool. Default guest path is `/host`. Repeatable. |
92
+
|`--tool-wasi-env KEY=VALUE`| Sets an environment variable for every CLI Wasm tool. Repeatable. |
93
+
|`--tool-wasi-env-inherit KEY`| Copies one host environment variable into every CLI Wasm tool. Repeatable. |
94
+
|`--tool-wasi-fuel FUEL`| Sets the instruction-fuel budget for each call to every CLI Wasm tool. Default `100000000`. |
95
+
|`--tool-wasi-output-limit SIZE`| Caps captured stdout and stderr for each call to every CLI Wasm tool. Default `1Mi`. |
96
+
97
+
`--tool-wasi-*` flags configure the Wasmtime/WASI sandbox for Wasm custom tools only. They do not expose the guest `--mount` filesystem, and they do not change the `fs_*` handlers used by `lib/hostfs`.
98
+
99
+
The CLI currently applies the same Wasm filesystem, environment, fuel, and output settings to every `--tool` registered in one invocation. If tools need different permissions or limits, do not grant the union to all handlers; that requires a narrower per-tool configuration surface or a separate host integration.
96
100
97
101
**Mount rules (host-enforced before boot):**
98
102
@@ -196,7 +200,7 @@ Sockets are host-side (`socket2`); the guest sees opaque numeric **`fd`** handle
196
200
197
201
## Custom tools
198
202
199
-
**CLI built-in:**`--enable-tools` registers a built-in `echo` tool (returns `args` unchanged) used by the [`python-tools` example](../examples/python-tools).
203
+
**CLI demo tool:**`--enable-tools` registers only a built-in `echo` tool that returns `args` unchanged. It is useful as a smoke test and compatibility path, but it is not the CLI extension mechanism for user-provided host functions. CLI examples should prefer a Wasm `echo.wasm` registered with `--tool echo=...`; library examples should register an echo handler with `SandboxBuilder::tool()`.
200
204
201
205
**CLI Wasm tools:** build with the optional feature and pass one or more `--tool` flags:
202
206
@@ -223,7 +227,11 @@ The handler writes JSON to stdout. It may write either a raw JSON result value o
223
227
224
228
A raw value is treated as the tool result. A single-key `result` envelope is unwrapped. A single-key `error` envelope becomes the outer `__dispatch` error response. Empty stdout returns JSON null.
225
229
226
-
WASI capabilities are denied by default except stdio used for the protocol, clocks, and random. Use `--tool-wasi-dir`, `--tool-wasi-dir-ro`, `--tool-wasi-env`, and `--tool-wasi-env-inherit` to grant explicit filesystem and environment access to handlers. Tool names beginning with `__`, `fs_`, or `net_` are reserved.
230
+
Wasm tools are separate from the built-in `fs_*` and `net_*` dispatch handlers. `--mount` controls what the guest can access through `lib/hostfs`; `--tool-wasi-dir*` controls what the host-side Wasm handler can access through its own WASI filesystem view.
231
+
232
+
WASI capabilities are denied by default except stdio used for the protocol, clocks, and random. Use `--tool-wasi-dir`, `--tool-wasi-dir-ro`, `--tool-wasi-env`, and `--tool-wasi-env-inherit` to grant explicit filesystem and environment access to handlers. These grants and the `--tool-wasi-fuel` / `--tool-wasi-output-limit` settings apply to every CLI Wasm tool registered by the process. Tool names beginning with `__`, `fs_`, or `net_` are reserved.
233
+
234
+
**Why WASIp1 command modules today?** The current CLI maps one `--tool NAME=WASM` flag to one tool name and one fresh handler invocation. WASIp1 keeps that ABI small: JSON request on stdin, JSON response on stdout, no long-lived reactor state, and broad language/toolchain support. Component-model or reactor-style handlers could support a future `--tools component.wasm` shape with multiple exported tools and auto-registration, but that would need a separate registration and lifecycle model; it is not the current ABI.
227
235
228
236
**Library:**
229
237
@@ -233,7 +241,7 @@ Sandbox::builder("kernel")
233
241
.build()?;
234
242
```
235
243
236
-
Custom handlers run with the same JSON request/response envelope as built-in tools.
244
+
`SandboxBuilder::tool()` handlers receive the inner `args`JSON value from the dispatch request; the registry has already matched the outer `name`. Handler return values become the `result` field in the outer `__dispatch` response, and handler errors become `{"error": "..."}`.
237
245
238
246
---
239
247
@@ -248,8 +256,8 @@ Custom handlers run with the same JSON request/response envelope as built-in too
248
256
|`fs_list` entries | 100 000 |
249
257
|`net_send` / `net_sendto`| 1 MiB decoded bytes |
250
258
|`__hl_sleep`| 60 s |
251
-
| Wasm tool fuel | 100 000 000 instructions per call by default; configurable with `--tool-wasi-fuel`|
252
-
| Wasm tool stdout / stderr | 1 MiB each per call by default; configurable with `--tool-wasi-output-limit`|
259
+
| Wasm tool fuel | 100 000 000 instructions per call by default; configurable with `--tool-wasi-fuel`; same value applies to every CLI Wasm tool|
260
+
| Wasm tool stdout / stderr | 1 MiB each per call by default; configurable with `--tool-wasi-output-limit`; same value applies to every CLI Wasm tool|
253
261
| Open host sockets | 1024 per sandbox |
254
262
| AllowList learned DNS IPs | 256 |
255
263
@@ -282,6 +290,7 @@ Custom handlers run with the same JSON request/response envelope as built-in too
282
290
283
291
- Handler code runs on the host inside Wasmtime, not inside the Unikraft VM.
284
292
- WASI filesystem and environment access are capability-based and off unless explicitly granted with `--tool-wasi-*` flags.
293
+
- CLI Wasm capability and limit flags apply to every registered Wasm tool; avoid combining handlers with different privilege needs in one invocation.
285
294
- Fuel limits bound Wasm instruction execution, but do not turn filesystem operations into a full wall-clock timeout.
286
295
- Handlers are untrusted code from the host operator's filesystem; only load modules you intend to grant these capabilities to.
0 commit comments