microsandbox-rb 0.17.4 → 0.18.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +378 -1
- data/Cargo.lock +747 -1134
- data/DESIGN.md +52 -36
- data/README.md +27 -20
- data/SECURITY.md +22 -6
- data/docs/configuration.md +153 -17
- data/docs/errors.md +8 -2
- data/docs/execution.md +17 -0
- data/docs/filesystem.md +2 -1
- data/docs/images.md +74 -2
- data/docs/lifecycle.md +130 -6
- data/docs/observability.md +9 -7
- data/docs/releasing.md +1 -1
- data/docs/runtime.md +126 -43
- data/docs/surface.md +55 -14
- data/ext/microsandbox/Cargo.toml +22 -20
- data/ext/microsandbox/extconf.rb +9 -8
- data/ext/microsandbox/src/backend.rs +21 -15
- data/ext/microsandbox/src/error.rs +59 -1
- data/ext/microsandbox/src/host_path.rs +37 -28
- data/ext/microsandbox/src/lib.rs +314 -42
- data/ext/microsandbox/src/runtime.rs +5 -5
- data/ext/microsandbox/src/sandbox.rs +508 -241
- data/ext/microsandbox/src/snapshot.rs +63 -20
- data/ext/microsandbox/src/storage.rs +44 -0
- data/lib/microsandbox/errors.rb +63 -0
- data/lib/microsandbox/exec_handle.rb +2 -1
- data/lib/microsandbox/runtime_info.rb +65 -0
- data/lib/microsandbox/sandbox.rb +544 -158
- data/lib/microsandbox/snapshot.rb +101 -28
- data/lib/microsandbox/storage.rb +205 -0
- data/lib/microsandbox/version.rb +5 -4
- data/lib/microsandbox.rb +259 -60
- data/rust-toolchain.toml +1 -1
- data/sig/microsandbox.rbs +113 -7
- metadata +5 -2
data/DESIGN.md
CHANGED
|
@@ -337,22 +337,22 @@ and the Rust→class mapping in `sdk/python/src/error.rs`.
|
|
|
337
337
|
## Runtime binary (`msb` + `libkrunfw`)
|
|
338
338
|
|
|
339
339
|
The gem is **SDK-only**: nothing is provisioned while it is built or installed.
|
|
340
|
-
The core crate's
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
340
|
+
The core SDK crate's binary features — `download-binaries` (its `build.rs`
|
|
341
|
+
downloads the `msb` runtime and `libkrunfw` into `~/.microsandbox` at build
|
|
342
|
+
time) and `embed-binaries` (`include_bytes!` of the whole runtime tarball) —
|
|
343
|
+
are deliberately **off** (`default-features = false`, features
|
|
344
|
+
`cloud`/`keyring`/`local`/`net`/`ssh`, the set the official SDKs ship).
|
|
345
|
+
Build-time provisioning only ever helped the source gem: for a precompiled gem
|
|
346
|
+
the download lands on the CI host, and even for a source install it couples
|
|
347
|
+
"compile a Ruby extension" to "fetch 50 MB of host binaries", which is not the
|
|
348
|
+
compiler's business.
|
|
349
|
+
|
|
350
|
+
Since runtime `v0.7` the extension embeds nothing at all: the *guest* agent
|
|
351
|
+
(`agentd`, PID 1 inside every microVM) ships inside the `msb` release build,
|
|
352
|
+
so the host runtime pair is the only binary dependency. (Through runtime
|
|
353
|
+
`v0.6.18` the extension `include_bytes!`-d `agentd` itself via a direct
|
|
354
|
+
`microsandbox-runtime` dependency with its `prebuilt` feature; that dependency
|
|
355
|
+
is gone.)
|
|
356
356
|
|
|
357
357
|
### The companion gem
|
|
358
358
|
|
|
@@ -404,20 +404,30 @@ pushes its platform package's `msb` into the same set-once slot at module load).
|
|
|
404
404
|
A lazy hook inside `ensure_runtime!` would only cover `Sandbox.create`/`start`
|
|
405
405
|
and silently miss every other entry point that resolves or spawns `msb`.
|
|
406
406
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
`
|
|
411
|
-
|
|
412
|
-
`
|
|
413
|
-
`
|
|
414
|
-
`
|
|
407
|
+
Since runtime `v0.7` the core resolves `msb` and `libkrunfw` as one **pair**,
|
|
408
|
+
in this order: `$MSB_PATH` (with `MSB_LIBKRUNFW_PATH` or the library next to
|
|
409
|
+
it) → the SDK path slots (claimed by the companion gem at load;
|
|
410
|
+
`Microsandbox.runtime_path=`/`libkrunfw_path=` target the same set-once
|
|
411
|
+
slots, so with the gem installed the setters are **no-ops** — override via
|
|
412
|
+
`MSB_PATH`) → config file → the runtime home (`<home>/bin/msb` +
|
|
413
|
+
`<home>/lib/<libkrunfw>`). `msb` on `PATH` is no longer a source.
|
|
414
|
+
`Microsandbox.runtime_info` reports the winning pair, its origin and the
|
|
415
|
+
version embedded in the `msb`; `Microsandbox.install` / `.installed?` cover
|
|
416
|
+
explicit, idempotent provisioning (`installed?` = any complete pair resolves,
|
|
417
|
+
whatever its version).
|
|
418
|
+
|
|
419
|
+
Runtime `v0.7` launches only an `msb` whose embedded version equals the SDK's
|
|
420
|
+
exactly (the launch contract refuses everything else, `#!` wrapper scripts
|
|
421
|
+
included), so the bootstrap is version-aware: `ensure_runtime!` replaces a
|
|
422
|
+
stale runtime in the home, but never touches one from `MSB_PATH`, the slots or
|
|
423
|
+
the config file — it warns that local starts will be refused.
|
|
415
424
|
|
|
416
425
|
Auto-provisioning stays as the **lowest tier**, deliberately (npx-style
|
|
417
426
|
first-use download; see upstream discussion
|
|
418
427
|
[superradcompany/microsandbox#1305](https://github.com/superradcompany/microsandbox/issues/1305)):
|
|
419
|
-
`Sandbox.create`/`start`
|
|
420
|
-
missing or version-stale
|
|
428
|
+
`Sandbox.create`/`start`/`restore` (and `recover_storage`) call
|
|
429
|
+
`Microsandbox.ensure_runtime!`, which fetches a missing or version-stale
|
|
430
|
+
runtime into the runtime home on first use — by the
|
|
421
431
|
*running* host's arch, which is always correct — at most once per process.
|
|
422
432
|
`MICROSANDBOX_NO_AUTO_INSTALL` opts out (air-gapped hosts that provision out of
|
|
423
433
|
band). When the companion gem won the resolver (`bundled_runtime_active?`),
|
|
@@ -434,8 +444,9 @@ extension.
|
|
|
434
444
|
## Core-crate dependency (self-contained)
|
|
435
445
|
|
|
436
446
|
`ext/microsandbox/Cargo.toml` depends on the core crate via a **pinned git tag**
|
|
437
|
-
(`microsandbox
|
|
438
|
-
`
|
|
447
|
+
(every upstream git dependency — `microsandbox`, `microsandbox-network`,
|
|
448
|
+
`microsandbox-utils` — on
|
|
449
|
+
the one tag recorded in `Microsandbox::RUNTIME_VERSION`), so the gem builds anywhere
|
|
439
450
|
— CI and end-user source installs —
|
|
440
451
|
without an adjacent checkout. For fast local development against a sibling
|
|
441
452
|
microsandbox checkout, copy `.cargo/config.toml.example` to `.cargo/config.toml`
|
|
@@ -464,9 +475,9 @@ git. The override must never be committed — it would break container builds.
|
|
|
464
475
|
|
|
465
476
|
## Build requirements
|
|
466
477
|
|
|
467
|
-
* Ruby >= 3.
|
|
468
|
-
* Rust (stable) >= 1.
|
|
469
|
-
which
|
|
478
|
+
* Ruby >= 3.3, RubyGems >= 3.3.11
|
|
479
|
+
* Rust (stable) >= 1.94 — the core crate is edition 2024 and pulls sea-orm 2 /
|
|
480
|
+
sqlx 0.9, which set MSRV 1.94. `rust-toolchain.toml` pins `stable`.
|
|
470
481
|
* Linux with KVM, or macOS on Apple Silicon (same as the other SDKs).
|
|
471
482
|
|
|
472
483
|
## Implemented surface (v1) vs roadmap
|
|
@@ -503,15 +514,20 @@ implemented, and so is the bulk of the v0.5.8 configuration surface that a
|
|
|
503
514
|
later parity pass added: streaming image-pull progress, host-side `VolumeFs`,
|
|
504
515
|
streaming guest fs (`read_stream`/`write_stream`), the full secrets surface,
|
|
505
516
|
network configuration (DNS, TLS-interception tuning, IPv4/IPv6 pools,
|
|
506
|
-
`
|
|
507
|
-
create options, full mount
|
|
508
|
-
host-permissions),
|
|
517
|
+
`max_tcp_connections`/`max_udp_connections`, `trust_host_cas`, the HTTP deny
|
|
518
|
+
response), `init`/`ephemeral`/disk-image `fstype` create options, full mount
|
|
519
|
+
options (tmpfs/disk + stat-virtualization/host-permissions), snapshot
|
|
520
|
+
inspection (`open`/`list_dir`/`reindex`), `Sandbox.restore`, and the runtime
|
|
521
|
+
`v0.7` storage diagnosis/recovery.
|
|
509
522
|
|
|
510
523
|
A few **secondary** upstream knobs remain unexposed (a genuine binding gap, not
|
|
511
524
|
upstream-gated — they exist at the pinned runtime,
|
|
512
525
|
`Microsandbox::RUNTIME_VERSION`): per-published-port host
|
|
513
526
|
**bind address** (ports always bind loopback), network **interface overrides**,
|
|
514
|
-
|
|
515
|
-
mount with `{ named: }`)
|
|
527
|
+
inline **named-volume create-mode** (pre-create with `Volume.create`, then
|
|
528
|
+
mount with `{ named: }`), HTTP CONNECT proxies, the inbound published-port
|
|
529
|
+
caps, and the runtime `v0.7` additions planned for 0.19.0 (detached jobs,
|
|
530
|
+
snapshot groups and live forks, restore's network/security options,
|
|
531
|
+
`nested_virt`); `docs/surface.md` keeps the list. These slot in module-by-module exactly as the existing
|
|
516
532
|
bindings do. Beyond those, surfacing genuinely newer core features is gated on
|
|
517
533
|
advancing the pinned core-crate tag.
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://rubygems.org/gems/microsandbox-rb)
|
|
4
4
|
[](https://github.com/ya-luotao/microsandbox-rb/actions/workflows/ci.yml)
|
|
5
|
-
[](https://www.ruby-lang.org/)
|
|
6
6
|
[](https://rubydoc.info/gems/microsandbox-rb)
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
|
|
@@ -14,8 +14,8 @@ Lightweight microVM sandboxes for Ruby. Run AI agents and untrusted code with ha
|
|
|
14
14
|
|
|
15
15
|
- **Real VMs, not containers.** Every sandbox has its own Linux kernel under KVM (Linux) or the Hypervisor framework (Apple Silicon). Sub-100 ms boot; the runtime lives in your process.
|
|
16
16
|
- **Synchronous, idiomatic Ruby.** Keyword arguments, block-scoped lifecycle, a flat typed error hierarchy with stable `#code`s, and hand-maintained RBS signatures. The GVL is released during native calls, so other threads keep running.
|
|
17
|
-
- **The whole core surface.** Collected *and* streaming exec, logs, metrics, and filesystem handles; live `modify` with dry-run plans; snapshots
|
|
18
|
-
- **Network policy as data.** Composable profiles plus per-rule CIDR/domain allow-deny policies, TLS interception, outbound SOCKS4/SOCKS5 proxies, fail-closed strict hostname mode, and
|
|
17
|
+
- **The whole core surface.** Collected *and* streaming exec, logs, metrics, and filesystem handles; live `modify` with dry-run plans; snapshots and `Sandbox.restore`; named volumes with host-side access; image cache management; interactive `attach`; in-process SSH/SFTP; a raw `agentd` client.
|
|
18
|
+
- **Network policy as data.** Composable profiles plus per-rule CIDR/domain allow-deny policies, TLS interception, outbound SOCKS4/SOCKS5 proxies, fail-closed strict hostname mode, and secret substitution with per-host allow-lists.
|
|
19
19
|
- **Convergent lifecycle.** `connect_or_create`, `restart`, `destroy`, and `wait_for_status` take a name to the state you want and refuse to touch a sandbox someone recreated under the same name.
|
|
20
20
|
- **Hermetic runtime.** The optional `microsandbox-rb-binaries` companion gem vendors a checksum-verified `msb` + `libkrunfw` in lockstep with the SDK, so production never downloads on first use. Without it, the runtime is provisioned into `~/.microsandbox` on demand.
|
|
21
21
|
- **Local or cloud.** The same API runs against the local libkrun backend or the microsandbox cloud, selected per process or per block.
|
|
@@ -36,25 +36,28 @@ gem compiles the Rust extension, so the first install takes a few minutes.
|
|
|
36
36
|
|
|
37
37
|
**Prerequisites**
|
|
38
38
|
|
|
39
|
-
- Ruby 3.
|
|
39
|
+
- Ruby 3.3 or newer.
|
|
40
40
|
- Linux with KVM enabled, or macOS on Apple Silicon. Cloud-only users
|
|
41
41
|
(`MSB_BACKEND=cloud`) need neither.
|
|
42
|
-
- A stable Rust toolchain (1.
|
|
42
|
+
- A stable Rust toolchain (1.94 or newer) on `PATH` to compile the source gem.
|
|
43
43
|
Precompiled extension gems are not published; see
|
|
44
44
|
[docs/releasing.md](docs/releasing.md).
|
|
45
45
|
- The `msb` runtime and `libkrunfw` firmware, from the companion gem above or
|
|
46
|
-
downloaded on first use.
|
|
47
|
-
|
|
46
|
+
downloaded on first use. The runtime must be exactly the version the SDK
|
|
47
|
+
embeds (`Microsandbox::RUNTIME_VERSION`); an older one left in
|
|
48
|
+
`~/.microsandbox` is replaced on first use. Provision ahead of time (a Docker
|
|
49
|
+
layer, an air-gapped host) with:
|
|
48
50
|
|
|
49
51
|
```ruby
|
|
50
|
-
Microsandbox.install
|
|
52
|
+
Microsandbox.install # no-op when the home already holds this runtime
|
|
53
|
+
Microsandbox.runtime_info # => which msb + libkrunfw, from where, which version
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
The companion gem ships one platform gem each for `arm64-darwin`,
|
|
54
57
|
`x86_64-linux-gnu`, and `aarch64-linux-gnu`, must match the SDK version, and is
|
|
55
58
|
found automatically at `require "microsandbox"`. See
|
|
56
|
-
[docs/runtime.md](docs/runtime.md) for the resolution order,
|
|
57
|
-
disabling the first-use download.
|
|
59
|
+
[docs/runtime.md](docs/runtime.md) for the resolution order, the exact-version
|
|
60
|
+
rule, `MSB_PATH`, and disabling the first-use download.
|
|
58
61
|
|
|
59
62
|
## Quick start
|
|
60
63
|
|
|
@@ -135,16 +138,17 @@ Microsandbox::Sandbox.create("agent", image: "public.ecr.aws/docker/library/pyth
|
|
|
135
138
|
network: Microsandbox::NetworkPolicy.custom(default_egress: :deny,
|
|
136
139
|
rules: [{ action: :allow, direction: :egress, protocol: :tcp, port: 443,
|
|
137
140
|
destination: Microsandbox::Destination.domain("api.example.com") }]),
|
|
138
|
-
strict: true,
|
|
139
141
|
proxy: Microsandbox::OutboundProxy.socks5("127.0.0.1:1080"),
|
|
140
|
-
secrets: [{ env: "API_KEY", value: ENV.fetch("HOST_API_KEY"),
|
|
142
|
+
secrets: [{ env: "API_KEY", value: ENV.fetch("HOST_API_KEY"), allow: ["api.example.com"] }]
|
|
141
143
|
) do |sb|
|
|
142
144
|
# ...
|
|
143
145
|
end
|
|
144
146
|
```
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
Strict hostname enforcement is on by default since 0.18.0, and a denied HTTP
|
|
149
|
+
request gets a JSON `403`. See [docs/configuration.md](docs/configuration.md)
|
|
150
|
+
for every create option, including resources, ports, volumes, root-disk
|
|
151
|
+
layout, the secrets keys, and the HTTP deny response.
|
|
148
152
|
|
|
149
153
|
### Observability and live modification
|
|
150
154
|
|
|
@@ -184,17 +188,18 @@ Since upstream `v0.6.9` the microsandbox repository ships an official
|
|
|
184
188
|
[`sdk/ruby`](https://github.com/superradcompany/microsandbox/tree/main/sdk/ruby),
|
|
185
189
|
a compact veneer over the same Rust SDK. Both gems define the `Microsandbox`
|
|
186
190
|
module, so use one or the other in a process, not both. Differences below are
|
|
187
|
-
taken from the official gem's own README as of upstream `v0.
|
|
191
|
+
taken from the official gem's own README as of upstream `v0.7.14`.
|
|
188
192
|
|
|
189
193
|
| Capability | `microsandbox-rb` (this gem) | official `microsandbox` gem |
|
|
190
194
|
|---|:---:|:---:|
|
|
191
195
|
| Lifecycle, convergent `connect_or_create`, local/cloud backends | ✅ | ✅ |
|
|
192
196
|
| Collected `exec`/`shell`, logs, metrics, guest filesystem | ✅ | ✅ |
|
|
193
197
|
| Image, volume, and snapshot management | ✅ | ✅ |
|
|
198
|
+
| Booting a sandbox from a snapshot (`Sandbox.restore`) | ✅ | not exposed |
|
|
194
199
|
| Streaming exec, logs, metrics, filesystem handles | ✅ | not exposed |
|
|
195
200
|
| Interactive SSH/SFTP client and server | ✅ | `ssh_exec` only |
|
|
196
201
|
| Live modification plans (`modify`, dry-run) | ✅ | not exposed |
|
|
197
|
-
| Outbound
|
|
202
|
+
| Outbound proxy (`proxy:`) | SOCKS4/SOCKS5 | HTTP CONNECT |
|
|
198
203
|
| Full network policy and mount builders, strict hostname mode | ✅ | not exposed |
|
|
199
204
|
| Rootfs patches, structured root disk, raw `agentd` client | ✅ | — |
|
|
200
205
|
| RBS type signatures | ✅ | — |
|
|
@@ -209,8 +214,8 @@ share the upstream tag, but the numbers have diverged since and the gem version
|
|
|
209
214
|
is **not** an indicator of the embedded runtime. Ask the build instead:
|
|
210
215
|
|
|
211
216
|
```ruby
|
|
212
|
-
Microsandbox::VERSION # => "0.
|
|
213
|
-
Microsandbox.runtime_version # => "v0.
|
|
217
|
+
Microsandbox::VERSION # => "0.18.0" (the gem's own version)
|
|
218
|
+
Microsandbox.runtime_version # => "v0.7.14" (the embedded upstream runtime tag)
|
|
214
219
|
```
|
|
215
220
|
|
|
216
221
|
While the gem is `0.x`, a breaking API change bumps the minor and a fix bumps
|
|
@@ -245,10 +250,12 @@ constants against this gem's. Every release records its runtime in
|
|
|
245
250
|
| `0.15.0` | `v0.6.14` | adopts upstream `v0.6.10`–`v0.6.14` step by step: bind-mount correctness, guest bootstrap off the kernel command line, DNS pins for deferred domain allows, Linux glibc 2.28 baseline for the prebuilt runtime, legacy ext4 upper-disk resize, `msb_krun` 0.1.32. Parity: `ssh.open_client`/`prepare_server` accept `inactivity_timeout:` (seconds; `0` disables, `nil` inherits the 600s global default) |
|
|
246
251
|
| `0.16.0` | `v0.6.16` | adopts upstream `v0.6.15`+`v0.6.16` step by step: mount fallback ownership, readonly-mount write-probe fix, log retrieval rerouted through the SDK backends, config overlaid by field presence, network-slot recycling. Parity: per-mount `uid:`/`gid:`, and the convergent lifecycle — `Sandbox.connect_or_create`, `#id`, `#wait_for_status`, `#restart`, `#destroy`, `SandboxHandle#connect_or_start`, `SandboxReplacedError` |
|
|
247
252
|
| `0.17.0` | `v0.6.18` | adopts upstream `v0.6.17`+`v0.6.18` step by step: outbound SOCKS4/SOCKS5 proxies (SOCKS5 UDP + credentials), migration-order fix for databases last opened by a `v0.6.15` `msb`, security hardening — plain-HTTP `Host`/`:authority` now checked against domain-rule policies even in non-strict mode, plus fail-closed strict hostname mode. Parity: `proxy:` (`Microsandbox::OutboundProxy` / `SecretSource`), `strict:` |
|
|
248
|
-
| `0.17.1` | `v0.6.18` | gem-only security and hardening release: relative host paths pinned at create time (GHSA-mcw9-9rf6-p4rm), `Volume.fs` path validation, `Cargo.lock` advisory updates, argument-guard and cleanup fixes, `SECURITY.md` |
|
|
253
|
+
| `0.17.1` | `v0.6.18` | gem-only security and hardening release: relative host paths pinned at create time (GHSA-mcw9-9rf6-p4rm), `Volume.fs` path validation (mitigates GHSA-rh2c-vm8j-5gg6), `Cargo.lock` advisory updates, argument-guard and cleanup fixes, `SECURITY.md` |
|
|
249
254
|
| `0.17.2` | `v0.6.18` | gem-only fix and release-pipeline hardening release: an interrupted native call no longer loses its result (a sandbox the call owns is stopped on `Timeout`/`Thread#kill`), release preflight, SHA-pinned workflow actions and `cargo deny` advisory checks, RBS and docs contract specs |
|
|
250
255
|
| `0.17.3` | `v0.6.18` | gem-only fix release, fork safety: a forked child (Puma, Resque, Solid Queue) rebuilds its backend and runtime on its first SDK call instead of hanging or crashing, a handle created before the fork raises `ForkedHandleError` in the child, and nothing inherited from the parent is dropped there |
|
|
251
256
|
| `0.17.4` | `v0.6.18` | gem-only fix release: fork safety identifies a process by pid and fork generation (survives pid reuse), `install`/`setup` leave the backend alone in a forked child, a `Sandbox` subclass's `initialize` runs outside the interrupt mask, and the macOS limit that a forked child must not build network clients is documented; rustls 0.23.46 fixes four TLS advisories (RUSTSEC-2026-0346 to -0349) |
|
|
257
|
+
| `0.17.5` | `v0.6.18` | gem-only security release: dependency updates clear RUSTSEC-2026-0381 to -0410, including the zstd used for image-layer decompression (three zstd advisories remain only on an external-kernel path the runtime never takes, see `CHANGELOG.md`); `SECURITY.md` maps more upstream advisories to gem versions |
|
|
258
|
+
| `0.18.0` | `v0.7.14` | adopts upstream `v0.7.14` (**breaking**): the `msb` runtime must be exactly the SDK's version (a stale home runtime is replaced automatically, other sources are refused); secrets vocabulary (`allow:`/`allow_placeholder_for:`/`substitution:`/`violation_action:`), `secret_violation_action:`; `Sandbox.restore` replaces `create(from_snapshot:)`, `full:` replaces `resumable:`; HTTP denials default to a JSON 403 (`http:` option); one-way catalog migrations and macOS storage recovery for existing sandboxes; Ruby >= 3.3 |
|
|
252
259
|
|
|
253
260
|
## Development
|
|
254
261
|
|
|
@@ -262,7 +269,7 @@ cargo fmt --check --manifest-path ext/microsandbox/Cargo.toml
|
|
|
262
269
|
cargo clippy --manifest-path ext/microsandbox/Cargo.toml -- -D warnings
|
|
263
270
|
```
|
|
264
271
|
|
|
265
|
-
CI compiles and runs the unit suite on Ruby 3.
|
|
272
|
+
CI compiles and runs the unit suite on Ruby 3.3 and 3.4 on Linux and macOS,
|
|
266
273
|
lints Rust and Ruby, packages and installs the built gems, builds every
|
|
267
274
|
`microsandbox-rb-binaries` platform gem, and boots real microVMs in a KVM
|
|
268
275
|
integration job against both the provisioned and the bundled runtime.
|
data/SECURITY.md
CHANGED
|
@@ -32,17 +32,33 @@ entry in some of them refers to the upstream project's own Ruby gem, not to
|
|
|
32
32
|
|
|
33
33
|
| Advisory | Severity | Affected `microsandbox-rb` | Status |
|
|
34
34
|
|---|---|---|---|
|
|
35
|
-
| [GHSA-
|
|
36
|
-
| [GHSA-
|
|
37
|
-
| [GHSA-
|
|
35
|
+
| [GHSA-rh2c-vm8j-5gg6](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-rh2c-vm8j-5gg6) — `Volume.fs` paths that pass through a missing directory escape the volume root | Critical | `0.7.0`–`0.17.0` | Mitigated in `0.17.1`: every `Volume.fs` / `VolumeInfo#fs` method refuses a path with a `..` segment, in both the Ruby and the native layer, which closes the published bypass (`write`, `mkdir`, `copy` and `rename` through a directory that does not exist). **Fully fixed in `0.18.0`**, which embeds runtime `v0.7.14`: upstream rewrote host-side volume access in runtime `v0.7.6`, which also closes the window between checking a path and using it. The upstream advisory lists only `microsandbox <= 0.6.16` with no patched version, but the affected resolver is unchanged in every runtime up to `v0.7.5`, so gem `0.17.0` (runtime `v0.6.18`) is affected too. `Volume.fs` first appeared in `0.7.0`. Tracked for this gem as [GHSA-7hgp-qrrh-xc2m](https://github.com/ya-luotao/microsandbox-rb/security/advisories/GHSA-7hgp-qrrh-xc2m). |
|
|
36
|
+
| [GHSA-mcw9-9rf6-p4rm](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-mcw9-9rf6-p4rm) — relative bind-mount paths re-resolved against the working directory on restart | High | `<= 0.17.0` | Fixed in `0.17.1` for sandboxes created through this gem (paths are pinned at create time in the binding). Sandboxes created earlier with a relative path keep it: recreate them. Upstream fixed it in runtime `v0.7.6`, so from `0.18.0` (runtime `v0.7.14`) the `msb` CLI this gem installs pins relative paths too; with `0.17.x` its `msb` is runtime `v0.6.18`, so a sandbox created with `msb` directly is not covered there: use absolute paths. Tracked for this gem as [GHSA-qrhv-m6hf-9cmg](https://github.com/ya-luotao/microsandbox-rb/security/advisories/GHSA-qrhv-m6hf-9cmg). |
|
|
37
|
+
| [GHSA-cg9x-2vfm-3j58](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-cg9x-2vfm-3j58) — NAT64 addresses can bypass destination-group network policy | High | `<= 0.17.5` (runtime `< v0.7.5`) | **Fixed in `0.18.0`** (runtime `v0.7.14`; upstream fixed it in `v0.7.5`). Only exploitable where the host network routes a NAT64 prefix. On older gem versions, mitigate by denying the prefix explicitly (see below) or blocking it at the host. |
|
|
38
|
+
| [GHSA-cvr8-2329-j4xw](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-cvr8-2329-j4xw) — sandbox catalog database is created world-readable, exposing persisted secret and environment values to other local users | Medium | `<= 0.17.5` | **Fixed in `0.18.0`** (runtime `v0.7.14`; upstream fixed it in `v0.7.12`): the catalog directory and its SQLite files are owner-only, and an existing catalog is tightened when the runtime opens it. The runtime home must now be private to one OS account (see `docs/runtime.md`). Tracked for this gem as [GHSA-pwg7-fm3g-v2xj](https://github.com/ya-luotao/microsandbox-rb/security/advisories/GHSA-pwg7-fm3g-v2xj). |
|
|
39
|
+
| [GHSA-3mpp-52gc-935r](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-3mpp-52gc-935r) — hostname allowlist bypass via mismatched HTTP `Host` / `:authority` | High | `<= 0.16.0` | Runtime fix included from `0.17.0`. If you rely on a hostname allowlist for HTTPS without TLS interception, also keep strict mode on: it is the default from `0.18.0`, and `0.17.x` needs `strict: true`. |
|
|
38
40
|
| [GHSA-gj24-29j2-3x78](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-gj24-29j2-3x78) — egress allowlist bypass on malformed HTTP/1 request lines | Medium | `<= 0.12.0` | Runtime fix included from `0.13.0`. |
|
|
39
41
|
| [GHSA-4vq3-cjpp-v7fg](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-4vq3-cjpp-v7fg) — guest-controlled symlinks in `msb copy` | High | `<= 0.10.0` (the bundled `msb` CLI) | Runtime fix included from `0.11.0`. |
|
|
42
|
+
| [GHSA-v693-3rfr-6q3q](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-v693-3rfr-6q3q) — IPv4-mapped IPv6 addresses bypass DNS rebind protection | Critical | `<= 0.9.1` | Runtime fix included from `0.9.2` (runtime `v0.6.3`). Affects network-enabled sandboxes. |
|
|
40
43
|
| [GHSA-m8f5-rh7h-vgg3](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-m8f5-rh7h-vgg3) — secret values in world-readable process arguments | Medium | `<= 0.7.0` | Runtime fix included from `0.8.0`. |
|
|
44
|
+
| [GHSA-89j4-256r-3pcq](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-89j4-256r-3pcq) — symlink traversal when importing a snapshot archive | High | `0.5.7`–`0.5.9` (`Snapshot.import` and the bundled `msb snapshot import`) | Runtime fix included from `0.5.10` (runtime `v0.5.8`). |
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
[GHSA-xgg5-hjwq-2gw8](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-xgg5-hjwq-2gw8)
|
|
47
|
+
(domain deny rules bypassed by direct-IP TLS) does not affect any release of
|
|
48
|
+
this gem: it was fixed in runtime `v0.5.0`, and the first release, `0.5.7`,
|
|
49
|
+
embeds runtime `v0.5.7`.
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
[GHSA-3f94-vm6x-3jv3](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-3f94-vm6x-3jv3)
|
|
52
|
+
(cross-sandbox filesystem access via a guest-controlled root-disk journal,
|
|
53
|
+
runtime `0.7.8` on Windows) does not affect any release of this gem either:
|
|
54
|
+
the gem does not support Windows, no release embedded a runtime between
|
|
55
|
+
`v0.6.18` and `v0.7.14`, and runtime `v0.6.18` has no root-disk journal
|
|
56
|
+
(`crates/runtime/lib/checkpoint` does not exist there).
|
|
57
|
+
|
|
58
|
+
### Mitigating GHSA-cg9x-2vfm-3j58 on `0.17.5` and earlier
|
|
59
|
+
|
|
60
|
+
Upgrade to `0.18.0`. Until you can, on a host whose network provides NAT64
|
|
61
|
+
(typically IPv6-only networks), deny the well-known prefix explicitly. Rules you pass are evaluated before the rules a
|
|
46
62
|
profile expands to, so this keeps the default public-internet profile and puts
|
|
47
63
|
the deny ahead of it:
|
|
48
64
|
|
data/docs/configuration.md
CHANGED
|
@@ -28,7 +28,7 @@ To leave headroom for a live CPU/memory resize later, reserve a ceiling with
|
|
|
28
28
|
The full option list — `init`/`ephemeral`, disk-image `fstype`, `log_level`,
|
|
29
29
|
`security`, `rlimits`, `pull_policy`, `secrets`, `patches`
|
|
30
30
|
(`Microsandbox::Patch`), the structured `root_disk:` (`Microsandbox::RootDisk`),
|
|
31
|
-
`
|
|
31
|
+
`secret_violation_action:`, `cmd:`, `detached:`, `idle_timeout`/`max_duration`, and more —
|
|
32
32
|
is documented in [surface.md](surface.md) and typed in
|
|
33
33
|
[`sig/microsandbox.rbs`](../sig/microsandbox.rbs).
|
|
34
34
|
|
|
@@ -37,7 +37,10 @@ is documented in [surface.md](surface.md) and typed in
|
|
|
37
37
|
`network:` takes composable profiles (`:public`, `:private`, `:host`, `:none`)
|
|
38
38
|
or a custom `Microsandbox::NetworkPolicy` with per-rule CIDR/IP/domain/suffix/
|
|
39
39
|
group allow-deny rules, per-direction defaults, DNS and TLS-interception
|
|
40
|
-
settings, IPv4/IPv6 pools,
|
|
40
|
+
settings, IPv4/IPv6 pools, connection caps (`max_tcp_connections:` for
|
|
41
|
+
proxied TCP connections, `max_udp_connections:` for UDP relay sessions; `0`
|
|
42
|
+
means unlimited, omit to keep the runtime default; `max_connections:` is a
|
|
43
|
+
deprecated alias of the TCP cap), and `trust_host_cas`.
|
|
41
44
|
|
|
42
45
|
```ruby
|
|
43
46
|
Microsandbox::Sandbox.create("worker", image: "python",
|
|
@@ -48,21 +51,61 @@ Microsandbox::Sandbox.create("worker", image: "python",
|
|
|
48
51
|
|
|
49
52
|
### Strict hostname policy
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
Strict mode (runtime `v0.6.18`) makes a hostname-rule allow fail closed
|
|
52
55
|
unless the runtime can actually see the request authority (plain-HTTP `Host`,
|
|
53
56
|
or SNI/`:authority` under TLS interception); a bypassed or non-intercepted
|
|
54
57
|
HTTPS flow allowed only by a hostname rule is then denied before the upstream
|
|
55
|
-
dial.
|
|
56
|
-
|
|
58
|
+
dial. It is **on by default since 0.18.0** (runtime `v0.7`; it was opt-in
|
|
59
|
+
before): pass `strict: false` to opt out. Create-only. Independently of
|
|
60
|
+
`strict:`, any policy with domain rules checks plain-HTTP `Host` headers
|
|
61
|
+
against it.
|
|
57
62
|
|
|
58
63
|
```ruby
|
|
59
64
|
Microsandbox::Sandbox.create("worker", image: "python",
|
|
60
65
|
network: Microsandbox::NetworkPolicy.custom(default_egress: :deny,
|
|
61
66
|
rules: [{ action: :allow, direction: :egress, protocol: :tcp, port: 443,
|
|
62
|
-
destination: Microsandbox::Destination.domain("api.example.com") }])
|
|
63
|
-
|
|
67
|
+
destination: Microsandbox::Destination.domain("api.example.com") }]))
|
|
68
|
+
# strict hostname enforcement applies by default; `strict: false` opts out.
|
|
64
69
|
```
|
|
65
70
|
|
|
71
|
+
### HTTP deny response
|
|
72
|
+
|
|
73
|
+
Since 0.18.0 (runtime `v0.7`) a request the network policy denies is answered
|
|
74
|
+
instead of reset: a denied plain-HTTP request — or an HTTPS one under TLS
|
|
75
|
+
interception — gets `403 Forbidden` with a JSON body such as
|
|
76
|
+
`{"code": "network_policy_denied", "domain": "example.com", "message":
|
|
77
|
+
"Request blocked by network policy."}`, and a request that a secret policy
|
|
78
|
+
blocks gets one too. Other denied traffic is still dropped. This is the
|
|
79
|
+
default for every sandbox the runtime starts, including ones created under
|
|
80
|
+
0.17.x or earlier: their stored config has no `http` setting, so they pick up
|
|
81
|
+
the default on their next start.
|
|
82
|
+
|
|
83
|
+
Tune it with the create-only `http:` Hash:
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
Microsandbox::Sandbox.create("worker", image: "python",
|
|
87
|
+
http: { network_message: "Egress is limited to the build mirror.",
|
|
88
|
+
secret_message: "Secrets only go to api.example.com." })
|
|
89
|
+
|
|
90
|
+
# a plain-text 403 body instead of JSON (no custom messages in this format)
|
|
91
|
+
Microsandbox::Sandbox.create("worker", image: "python", http: { format: :text })
|
|
92
|
+
|
|
93
|
+
# the 0.17 behaviour: close the connection, no HTTP answer
|
|
94
|
+
Microsandbox::Sandbox.create("worker", image: "python", http: { deny_response: false })
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| Key | Values | Default |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| `deny_response:` | `true` / `false` | `true` |
|
|
100
|
+
| `format:` | `:json` / `:text` (Symbol or String) | `:json` |
|
|
101
|
+
| `network_message:` | String, used as is as the JSON `message` of a network-policy denial | the runtime's message |
|
|
102
|
+
| `secret_message:` | String, the JSON `message` of a secret-policy denial | the runtime's message |
|
|
103
|
+
|
|
104
|
+
The two messages need the JSON format and an enabled response; an unknown key
|
|
105
|
+
or a wrong type raises `ArgumentError`. The setting is local-only: a cloud
|
|
106
|
+
create accepts the defaults and `deny_response: false`, and raises
|
|
107
|
+
`UnsupportedError` for a custom format or message.
|
|
108
|
+
|
|
66
109
|
## Outbound proxy
|
|
67
110
|
|
|
68
111
|
Route the sandbox's egress through a SOCKS4 (TCP) or SOCKS5 (TCP + non-DNS UDP)
|
|
@@ -93,19 +136,107 @@ Microsandbox::Sandbox.create("worker", image: "python",
|
|
|
93
136
|
## Secrets
|
|
94
137
|
|
|
95
138
|
`secrets:` gives the guest a placeholder and substitutes the real value only in
|
|
96
|
-
requests to the hosts you allow
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
`
|
|
139
|
+
requests to the hosts you allow. At create time it is an **Array of specs** (one
|
|
140
|
+
bare spec Hash also works): `env:` is the variable the guest sees (holding the
|
|
141
|
+
placeholder), `value:` is the real secret, and `allow:` — required, non-empty —
|
|
142
|
+
lists the hosts that may receive the real value: exact names, `"*.example.com"`
|
|
143
|
+
wildcards, or `"*"` for ANY host (upstream's `allow_any_host_dangerous`; use it
|
|
144
|
+
only when you mean it).
|
|
101
145
|
|
|
102
146
|
```ruby
|
|
103
147
|
Microsandbox::Sandbox.create("worker", image: "python",
|
|
104
|
-
secrets: [{ env: "API_KEY", value: ENV.fetch("HOST_API_KEY"),
|
|
148
|
+
secrets: [{ env: "API_KEY", value: ENV.fetch("HOST_API_KEY"), allow: ["api.example.com"] }])
|
|
105
149
|
# inside the guest: $API_KEY is "$MSB_API_KEY"; the proxy swaps in the real
|
|
106
150
|
# value for requests to api.example.com only
|
|
107
151
|
```
|
|
108
152
|
|
|
153
|
+
The other per-secret keys:
|
|
154
|
+
|
|
155
|
+
- `allow_placeholder_for:` — hosts that may receive the **unchanged
|
|
156
|
+
placeholder** without it counting as a violation (e.g. an internal service
|
|
157
|
+
that only forwards it).
|
|
158
|
+
- `placeholder:` — the guest-visible stand-in (default `$MSB_<env>`).
|
|
159
|
+
- `require_tls_identity:` — substitute only over TLS whose server identity was
|
|
160
|
+
verified (default `true`).
|
|
161
|
+
- `substitution:` — where the value may be substituted:
|
|
162
|
+
`{ headers:, header_fields:, query:, body: }`. Defaults: headers on, query
|
|
163
|
+
and body off. `header_fields: [...]` limits header substitution to the named
|
|
164
|
+
headers (it needs headers on). At least one location must stay enabled.
|
|
165
|
+
Inside an allowed header the runtime substitutes a Basic credential in
|
|
166
|
+
decoded form, otherwise the literal placeholder in any scheme (`Bearer`,
|
|
167
|
+
`token`, …); there is no Basic-only setting.
|
|
168
|
+
- `violation_action:` — what happens when the placeholder heads for a host not
|
|
169
|
+
in `allow:`/`allow_placeholder_for:`: `:block`, `:block_and_log`, or
|
|
170
|
+
`:block_and_terminate` (kebab-case spellings are accepted too). The
|
|
171
|
+
sandbox-wide default is the create keyword `secret_violation_action:`
|
|
172
|
+
(upstream default `block_and_log`).
|
|
173
|
+
|
|
174
|
+
### Migrating secrets from 0.17.x
|
|
175
|
+
|
|
176
|
+
Runtime `v0.7` replaced the secrets vocabulary. The old keys raise
|
|
177
|
+
`ArgumentError` naming their replacement instead of being silently dropped:
|
|
178
|
+
|
|
179
|
+
| 0.17.x | 0.18.0 |
|
|
180
|
+
| --- | --- |
|
|
181
|
+
| `host:` / `hosts:` / `host_patterns:` | one `allow: [...]` list (wildcards included) |
|
|
182
|
+
| `inject_headers:` / `inject_query:` / `inject_body:` | `substitution: { headers:, query:, body: }` |
|
|
183
|
+
| `inject_basic_auth:` | removed, with no Basic-only equivalent: see [Basic-only secrets](#basic-only-secrets-inject_basic_auth) |
|
|
184
|
+
| `require_tls:` | `require_tls_identity:` |
|
|
185
|
+
| `on_violation:` (per secret) | `violation_action:` |
|
|
186
|
+
| `on_secret_violation:` (create) | `secret_violation_action:` |
|
|
187
|
+
| passthrough violation policy (`passthrough_hosts:` / `"passthrough"`) | per-secret `allow_placeholder_for: [...]` |
|
|
188
|
+
|
|
189
|
+
`passthrough:` is still accepted on a secret spec as a deprecated alias of
|
|
190
|
+
`allow_placeholder_for:` (it warns, and the two lists are merged).
|
|
191
|
+
|
|
192
|
+
#### Basic-only secrets (`inject_basic_auth:`)
|
|
193
|
+
|
|
194
|
+
0.17.x could substitute a secret only inside a Basic `Authorization` header
|
|
195
|
+
(`inject_basic_auth: true` with `inject_headers: false`). Runtime `v0.7` has no
|
|
196
|
+
such setting. The narrowest replacement is:
|
|
197
|
+
|
|
198
|
+
```ruby
|
|
199
|
+
Microsandbox::Sandbox.create("worker", image: "public.ecr.aws/docker/library/alpine:latest",
|
|
200
|
+
secrets: [{env: "API_KEY", value: ENV.fetch("API_KEY"), allow: ["api.example.com"],
|
|
201
|
+
substitution: {headers: true, header_fields: ["Authorization"], query: false, body: false}}])
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
It still widens the old policy within that one header: the runtime
|
|
205
|
+
substitutes a Basic credential in decoded form and otherwise replaces the
|
|
206
|
+
literal placeholder in any scheme, such as `Bearer` or `token`. Never use a
|
|
207
|
+
bare `substitution: { headers: true }` for such a secret: it substitutes the
|
|
208
|
+
value into **every** header sent to an allowed host, including ones a server
|
|
209
|
+
may reflect or log.
|
|
210
|
+
|
|
211
|
+
**Saved sandboxes are widened automatically.** The first `v0.7` runtime to
|
|
212
|
+
open a 0.17.x runtime home converts every saved Basic-only secret to
|
|
213
|
+
substitution in every header, with no `header_fields` allowlist (upstream
|
|
214
|
+
catalog migration `migrate_secret_config`). No removed keyword is involved,
|
|
215
|
+
and `modify` cannot narrow the converted policy. After the conversion such a
|
|
216
|
+
secret looks the same as one that asked for header-wide substitution, so find
|
|
217
|
+
the affected sandboxes **before upgrading**, with 0.17.x:
|
|
218
|
+
|
|
219
|
+
```ruby
|
|
220
|
+
# Run with microsandbox-rb 0.17.x, before upgrading.
|
|
221
|
+
page = Microsandbox::Sandbox.list_with(limit: 100)
|
|
222
|
+
loop do
|
|
223
|
+
page.each do |h|
|
|
224
|
+
secrets = h.config.dig("network", "secrets", "secrets") || []
|
|
225
|
+
basic_only = secrets.any? { |s| s.dig("injection", "basic_auth") && !s.dig("injection", "headers") }
|
|
226
|
+
puts h.name if basic_only
|
|
227
|
+
end
|
|
228
|
+
break unless page.next_cursor
|
|
229
|
+
page = Microsandbox::Sandbox.list_with(limit: 100, cursor: page.next_cursor)
|
|
230
|
+
end
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Then, after upgrading and before any of them is started again, remove each
|
|
234
|
+
one (`Sandbox.remove`) and create it again with the recipe above. The new
|
|
235
|
+
sandbox starts from a fresh root disk. If you already
|
|
236
|
+
upgraded without the list, treat every saved secret whose `substitution` has
|
|
237
|
+
`headers: true` and no `header_fields` (in `SandboxHandle#config`) as a
|
|
238
|
+
candidate.
|
|
239
|
+
|
|
109
240
|
An inline `value:` is part of the sandbox's saved configuration: it is stored
|
|
110
241
|
in cleartext in the local catalog under the runtime home (`~/.microsandbox` by
|
|
111
242
|
default) until the sandbox is removed, and `SandboxHandle#config` returns it.
|
|
@@ -142,13 +273,18 @@ written from the host without booting a sandbox via `Volume.fs` /
|
|
|
142
273
|
`VolumeInfo#fs`.
|
|
143
274
|
|
|
144
275
|
A relative host path (`volumes: { "/data" => "./data" }`, `image: "./rootfs"`,
|
|
145
|
-
a `root_disk:` image, a `Patch.copy_file` source, a `tls:` certificate,
|
|
146
|
-
path-form `from_snapshot:`) is resolved **once, when the sandbox is created**,
|
|
276
|
+
a `root_disk:` image, a `Patch.copy_file` source, a `tls:` certificate) is resolved **once, when the sandbox is created**,
|
|
147
277
|
against the creating process's working directory, and stored as an absolute
|
|
148
278
|
path. Starting the sandbox later from another directory mounts the same host
|
|
149
|
-
directory. Resolution does not follow symlinks
|
|
279
|
+
directory. Resolution does not follow symlinks, and since runtime `v0.7` a bind
|
|
280
|
+
path that goes through a symlink (macOS's `/tmp` → `/private/tmp`, say) is
|
|
281
|
+
refused unless the mount sets `follow_root_symlinks: true`; pass the resolved
|
|
282
|
+
path instead. Sandboxes created by gem
|
|
150
283
|
versions before `0.17.1` kept the relative path and resolved it again on every
|
|
151
284
|
start ([GHSA-mcw9-9rf6-p4rm](https://github.com/superradcompany/microsandbox/security/advisories/GHSA-mcw9-9rf6-p4rm));
|
|
152
285
|
recreate those. On a cloud backend, host paths are sent as written.
|
|
153
286
|
|
|
154
|
-
|
|
287
|
+
`Sandbox.restore` anchors a relative snapshot path (and `snapshot_base:`) the
|
|
288
|
+
same way, when it is called. It replaced `Sandbox.create(name, from_snapshot:
|
|
289
|
+
...)`, which raises with directions since 0.18.0; see
|
|
290
|
+
[images.md](images.md#restoring-a-snapshot).
|
data/docs/errors.md
CHANGED
|
@@ -25,11 +25,15 @@ options) raises a plain `ArgumentError` before the native layer is reached.
|
|
|
25
25
|
| Class | `#code` | Raised when |
|
|
26
26
|
|-------|---------|-------------|
|
|
27
27
|
| `Error` | `microsandbox-error` | Base class; unmapped core errors |
|
|
28
|
-
| `InvalidConfigError` | `invalid-config` | Bad create options, invalid backend/cloud configuration |
|
|
28
|
+
| `InvalidConfigError` | `invalid-config` | Bad create options, invalid backend/cloud configuration, a restore whose captured mounts lack a destination binding |
|
|
29
|
+
| `RuntimeNotInstalledError` | `runtime-not-installed` | No `msb` + `libkrunfw` runtime pair was found anywhere |
|
|
30
|
+
| `RuntimeIncompleteError` | `runtime-incomplete` | The selected runtime pair is partial, or `MSB_PATH` / `runtime_path` names an `msb` with no matching `libkrunfw` |
|
|
29
31
|
| `SandboxNotFoundError` | `sandbox-not-found` | No sandbox with that name |
|
|
30
32
|
| `SandboxNotRunningError` | `sandbox-not-running` | Operation needs a running guest (`ping`/`touch`/`exec` on a stopped sandbox) |
|
|
31
33
|
| `SandboxAlreadyExistsError` | `sandbox-already-exists` | Name clash on `create` without `replace:` |
|
|
32
34
|
| `SandboxStillRunningError` | `sandbox-still-running` | `remove` on a running sandbox |
|
|
35
|
+
| `StopTimeoutError` | `stop-timeout` | A graceful stop (`stop_with_timeout`, or `restart`/`destroy`'s `timeout:`) did not complete within its budget; the stop may still complete and no kill was requested. The block forms catch it and kill |
|
|
36
|
+
| `SandboxStopTimedOutError` | `sandbox-stop-timed-out` | Reserved for parity; not raised at the pinned runtime |
|
|
33
37
|
| `SandboxReplacedError` | `sandbox-replaced` | The identity a handle was bound to no longer owns the name (see [lifecycle.md](lifecycle.md#convergent-lifecycle)) |
|
|
34
38
|
| `ExecTimeoutError` | `exec-timeout` | `exec(timeout:)` / `shell(timeout:)` deadline hit |
|
|
35
39
|
| `ExecFailedError` | `exec-failed` | Spawn-time failure (e.g. command not found) — a non-zero exit is **not** an error |
|
|
@@ -47,14 +51,16 @@ options) raises a plain `ArgumentError` before the native layer is reached.
|
|
|
47
51
|
| `SnapshotImageMissingError` | `snapshot-image-missing` | Restore needs an image that is not cached |
|
|
48
52
|
| `SnapshotIntegrityError` | `snapshot-integrity` | Snapshot payload failed verification |
|
|
49
53
|
| `SnapshotMigrationError` | `snapshot-migration` | Automatic snapshot-descriptor migration was blocked and needs repair |
|
|
54
|
+
| `SnapshotSourceRecoveryError` | `snapshot-source-recovery` | A `full:` capture completed but the source sandbox failed to recover; carries `#source_sandbox`, `#checkpoint_id`, `#checkpoint_root`, `#checkpoint_path`, `#artifact` (nil unless published), `#detail`, `#publication_error` |
|
|
50
55
|
| `NetworkPolicyError` | `network-policy-error` | Invalid network policy or `NetworkBuilder` validation failure (an invalid `proxy:` is `InvalidConfigError`) |
|
|
51
56
|
| `SecretViolationError` | `secret-violation` | Reserved for parity; not raised by the current native mapping |
|
|
52
57
|
| `TlsError` | `tls-error` | Reserved for parity; not raised by the current native mapping |
|
|
53
58
|
| `IoError` | `io-error` | Host-side I/O failure |
|
|
54
59
|
| `MetricsDisabledError` | `metrics-disabled` | Metrics turned off for this sandbox |
|
|
55
|
-
| `MetricsUnavailableError` | `metrics-unavailable` | Reserved for parity; not raised at the pinned runtime. The transient "no live metrics slot" window right after boot raises the base `Microsandbox::Error` — match on the message |
|
|
60
|
+
| `MetricsUnavailableError` | `metrics-unavailable` | Reserved for parity; not raised at the pinned runtime. The transient "no verified live metrics slot" window right after boot raises the base `Microsandbox::Error` — match on the message |
|
|
56
61
|
| `UnsupportedOperationError` | `unsupported-operation` | The runtime version does not support the operation |
|
|
57
62
|
| `CloudHttpError` | `cloud-http` | Cloud backend HTTP failure |
|
|
63
|
+
| `ModificationNotConfirmedError` | `modification-not-confirmed` | Cloud only: a `modify` was saved but is not in effect, or its outcome is unknown (the message says which) |
|
|
58
64
|
| `UnsupportedError` | `unsupported` | The selected backend does not implement the operation; carries `#operation` (e.g. `"sandbox.kill"`) and `#hint` |
|
|
59
65
|
| `ForkedHandleError` | `forked-handle` | A handle was used in a process forked from the one that created it; open a new one in the child (see [runtime.md](runtime.md#forking-puma-resque-solid-queue)) |
|
|
60
66
|
|
data/docs/execution.md
CHANGED
|
@@ -59,6 +59,23 @@ Microsandbox::Sandbox.create("stream", image: "public.ecr.aws/docker/library/pyt
|
|
|
59
59
|
end
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
Writing an empty string to `stdin` is a no-op since 0.18.0 (runtime `v0.7`);
|
|
63
|
+
before, `write("")` sent EOF. Call `close` to send EOF.
|
|
64
|
+
|
|
65
|
+
### Execution limits
|
|
66
|
+
|
|
67
|
+
Runtime `v0.7` applies fixed flow-control limits to every sandbox (upstream's
|
|
68
|
+
`ExecLimits` defaults; they cannot be changed per call):
|
|
69
|
+
|
|
70
|
+
- at most **128** executions per sandbox, counting exited streams whose output
|
|
71
|
+
has not been read yet — the next one is refused ("active execution limit
|
|
72
|
+
reached"), so drain or drop handles you no longer need;
|
|
73
|
+
- **64 KiB** of stdin may be waiting to enter a command's pipe, sent in chunks
|
|
74
|
+
of at most **16 KiB**;
|
|
75
|
+
- **1 MiB** of stdout/stderr may be waiting unread, delivered in chunks of at
|
|
76
|
+
most **16 KiB**: a command that writes faster than you read is paced, not
|
|
77
|
+
buffered without bound.
|
|
78
|
+
|
|
62
79
|
`shell_stream` is the shell-script counterpart. For a host-TTY-coupled
|
|
63
80
|
interactive session (raw mode + SIGWINCH), use `attach`/`attach_shell`.
|
|
64
81
|
|