Compare commits
15
Commits
1ac5193b0e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c674e541d | ||
|
|
5f06c955cb | ||
|
|
7ca42b0e9f | ||
|
|
149d3faac1 | ||
|
|
8ab77ec9dc | ||
|
|
b50e846b11 | ||
|
|
56762648e3 | ||
|
|
2231e4efe1 | ||
|
|
37c58cb5b2 | ||
|
|
2f053b8a5b | ||
|
|
fb6efa1558 | ||
|
|
3879b4cc4d | ||
|
|
b816e435df | ||
|
|
ae91de745e | ||
|
|
687cafb392 |
Generated
+78
-79
@@ -78,18 +78,18 @@ checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"hybrid-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.5.1"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f360145194ee8e21db5ee7f3fcd4fe52210864c75c985dae33218202c8bbe040"
|
||||
checksum = "877bf67ac8e52449eb2f9e98a344ea163beb70dd1f9eebe3cc5357dcfeaee4df"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
@@ -148,40 +148,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.17"
|
||||
name = "const-oid"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
||||
checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.2"
|
||||
version = "1.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
|
||||
checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.7"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
||||
checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
"hybrid-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"const-oid",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
@@ -218,9 +224,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.14"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
|
||||
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
@@ -242,16 +248,6 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.17"
|
||||
@@ -276,10 +272,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "icu_collections"
|
||||
version = "2.3.0"
|
||||
name = "hybrid-array"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513"
|
||||
checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_collections"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"potential_utf",
|
||||
@@ -291,9 +296,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icu_locale_core"
|
||||
version = "2.3.0"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb"
|
||||
checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"litemap",
|
||||
@@ -304,9 +309,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer"
|
||||
version = "2.3.0"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f"
|
||||
checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599"
|
||||
dependencies = [
|
||||
"icu_collections",
|
||||
"icu_normalizer_data",
|
||||
@@ -318,15 +323,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer_data"
|
||||
version = "2.3.0"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0"
|
||||
checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc"
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties"
|
||||
version = "2.3.0"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148"
|
||||
checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_collections",
|
||||
@@ -339,15 +344,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties_data"
|
||||
version = "2.3.0"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa"
|
||||
checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf"
|
||||
|
||||
[[package]]
|
||||
name = "icu_provider"
|
||||
version = "2.3.1"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73"
|
||||
checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_locale_core",
|
||||
@@ -393,9 +398,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.189"
|
||||
version = "0.2.191"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
||||
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
@@ -505,9 +510,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.45"
|
||||
version = "0.23.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634"
|
||||
checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
|
||||
dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
@@ -529,9 +534,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.103.15"
|
||||
version = "0.103.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"
|
||||
checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
@@ -569,9 +574,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.151"
|
||||
version = "1.0.154"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
|
||||
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
@@ -582,9 +587,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.9"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
||||
checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
@@ -605,9 +610,9 @@ checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.16.2"
|
||||
version = "1.16.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
|
||||
checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
@@ -629,9 +634,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.6"
|
||||
version = "3.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
||||
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -662,9 +667,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643"
|
||||
checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"zerovec",
|
||||
@@ -678,9 +683,9 @@ checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.26"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
@@ -728,12 +733,6 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
@@ -746,14 +745,14 @@ version = "0.26.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9"
|
||||
dependencies = [
|
||||
"webpki-roots 1.0.9",
|
||||
"webpki-roots 1.0.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "1.0.9"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"
|
||||
checksum = "1c1c8e20c8a38fc7d65abfe74eb7280e4aa667e8eec8bc84996d2874810748d9"
|
||||
dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
@@ -854,7 +853,7 @@ checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"
|
||||
|
||||
[[package]]
|
||||
name = "wsbx"
|
||||
version = "0.1.3"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -879,9 +878,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.8.3"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5"
|
||||
checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3"
|
||||
dependencies = [
|
||||
"stable_deref_trait",
|
||||
"yoke-derive",
|
||||
@@ -923,9 +922,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.9.0"
|
||||
version = "1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"
|
||||
checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879"
|
||||
|
||||
[[package]]
|
||||
name = "zerotrie"
|
||||
@@ -940,9 +939,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerovec"
|
||||
version = "0.11.8"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8"
|
||||
checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40"
|
||||
dependencies = [
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
@@ -951,9 +950,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerovec-derive"
|
||||
version = "0.11.6"
|
||||
version = "0.11.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da"
|
||||
checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wsbx"
|
||||
version = "0.1.3"
|
||||
version = "0.2.2"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
@@ -10,6 +10,6 @@ flate2 = "1"
|
||||
hex = "0.4"
|
||||
libc = "0.2"
|
||||
serde_json = "1"
|
||||
sha2 = "0.10"
|
||||
sha2 = "0.11"
|
||||
tar = "0.4"
|
||||
ureq = "2"
|
||||
|
||||
@@ -1,92 +1,111 @@
|
||||
# wsbx
|
||||
|
||||
Docker-Sandboxes-style microVMs on Apple Silicon macOS. Each sandbox is a real Linux VM
|
||||
(Virtualization.framework via [vfkit]), booted from any OCI image with a Kata Containers kernel.
|
||||
Linux microVMs for coding agents on Apple Silicon macOS. Each sandbox is a real VM
|
||||
(Virtualization.framework via [vfkit]) booted from any OCI image with a Kata Containers kernel.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
brew install vfkit e2fsprogs go # go: builds the static guest tunnel helper
|
||||
cargo install --path . # or grab wsbx-*-darwin-arm64.tar.gz from a release (push a v* tag to build one)
|
||||
|
||||
wsbx claude # Claude Code in a VM, current dir mounted at the same path
|
||||
wsbx codex | wsbx gemini # other agents (Docker's sandbox-templates images)
|
||||
wsbx pi # pi coding agent, same version + config as on the host
|
||||
wsbx run alpine # bare VM, interactive shell
|
||||
wsbx run -w . ubuntu -- make test # one-off command, exit code propagated
|
||||
wsbx run -p 8000 alpine # host's localhost:8000 reachable as localhost:8000 in the VM
|
||||
wsbx exec NAME # shell in a running sandbox (alias: sh), as the image's user
|
||||
wsbx exec -u root NAME -- apk add git # command, exit code propagated
|
||||
wsbx forward NAME 3000 8080:80 # sandbox's localhost:3000 on the Mac's localhost:3000 (until Ctrl-C; alias fwd)
|
||||
wsbx code NAME # VS Code in the browser, running in the sandbox (until Ctrl-C)
|
||||
wsbx code NAME --desktop # desktop VS Code via Remote-SSH; also: ssh NAME.wsbx
|
||||
wsbx ps # sandboxes: status, CPU, memory, net/block I/O, PIDs, disk, image (alias: ls)
|
||||
wsbx ps -f # same, refreshed every second like `docker stats`
|
||||
wsbx rm NAME... # delete stopped sandboxes; --disk deletes only the disk (fresh on next start)
|
||||
wsbx pull IMAGE
|
||||
wsbx gc # delete cached images no sandbox uses
|
||||
wsbx kernel [--update | --version TAG] # latest Kata release by default, sha256-verified
|
||||
brew install vfkit e2fsprogs
|
||||
curl -fsSL https://git.nhaiden.io/niklas/woiken-sandboxes/raw/branch/main/install.sh | sh
|
||||
```
|
||||
|
||||
Defaults for `--cpus`/`--memory` come from the host (half the cores, a quarter of RAM up to 8 GiB). Image tags
|
||||
are re-resolved after 24 h (cached copy used when offline); the superseded image is deleted automatically. `WSBX_KATA_VERSION` pins the kernel release.
|
||||
Installs the latest release to `~/.local/bin` (sha256-checked). `WSBX_VERSION=v0.2.1` pins a release,
|
||||
`WSBX_INSTALL_DIR` changes the target. From source: `brew install go && cargo install --path .`.
|
||||
|
||||
Options: `--name --workspace --cpus --memory --disk --env K[=V] --host-port/-p PORT --fresh --pull --kernel`.
|
||||
## Usage
|
||||
|
||||
**exec**: host → vfkit unix socket (`exec.sock`) → vsock → guest helper. It runs in the workspace dir with the sandbox's env.
|
||||
You get a pty (with resize) when stdin and stdout are terminals, plain pipes otherwise, so `wsbx exec x -- cat f > out` is byte-exact.
|
||||
```sh
|
||||
wsbx claude | codex | gemini | pi # agent in a VM, current dir mounted at the same path
|
||||
wsbx run -w . ubuntu -- make test # any image, one-off command, exit code propagated
|
||||
wsbx run -p 8000 alpine # host localhost:8000 reachable inside the VM
|
||||
wsbx exec NAME [-- cmd] # shell/command in a running sandbox (-u root)
|
||||
wsbx forward NAME 3000 8080:80 # guest localhost ports on the Mac's localhost
|
||||
wsbx code NAME [--desktop] # VS Code in the browser, or desktop via Remote-SSH (ssh NAME.wsbx)
|
||||
wsbx ps [-f] # status, CPU, memory, I/O, disk
|
||||
wsbx rm NAME... [--disk] | wsbx pull IMAGE | wsbx gc | wsbx kernel [--update]
|
||||
```
|
||||
|
||||
**forward**: host `127.0.0.1:HOSTPORT` → `exec.sock` → vsock → guest helper → guest `localhost:PORT`, one exec-style session
|
||||
per connection. Works for services bound only to the guest's loopback, on running sandboxes, no restart. `0:PORT` picks a free host port.
|
||||
Run options: `--name --workspace --cpus --memory --disk --env K[=V] -p PORT --fresh --pull --kernel`.
|
||||
Agents: `--keys` forwards API keys; `pi` mirrors the host's pi version and config (`--pi-auth` adds `auth.json`).
|
||||
|
||||
**code**: browser mode fetches the official VS Code CLI into the sandbox (`~/.wsbx-vscode`, needs internet in the VM) and runs
|
||||
`code serve-web` on the guest's loopback, forwarded like `forward` to a random host port behind a random connection token.
|
||||
The CLI downloads the matching server on first open (glibc or Alpine images). `--desktop` writes `~/.wsbx/ssh_config` (a `NAME.wsbx`
|
||||
host per sandbox) and adds an `Include` for it at the top of `~/.ssh/config` once. ssh reaches an SSH server in the guest helper through `wsbx exec`
|
||||
(`ProxyCommand`): no port, no keys, you're the image user. Remote-SSH then installs its server in the VM as usual.
|
||||
If the VM was killed mid-download and the server won't start, delete `~/.vscode/cli/serve-web` (browser) or `~/.vscode-server` (desktop) in the sandbox.
|
||||
Both need a sandbox started by this wsbx version (the guest helper ships with each start).
|
||||
## Architecture
|
||||
|
||||
**Host tunnel** (`-p PORT`): guest `localhost:PORT` → vsock → vfkit → unix socket → host `localhost:PORT`.
|
||||
Nothing listens on a host network interface, and only the listed ports are reachable.
|
||||
```mermaid
|
||||
flowchart LR
|
||||
reg[("OCI registry")]
|
||||
subgraph host["macOS host"]
|
||||
cli["wsbx"]
|
||||
img[("~/.wsbx/images<br/>flattened rootfs.tar")]
|
||||
sbx[("~/.wsbx/sandboxes/NAME<br/>disk.img · meta.json")]
|
||||
share["share/<br/>init · run.sh · guest helper"]
|
||||
ws["workspace"]
|
||||
socks["exec.sock · pPORT.sock"]
|
||||
end
|
||||
subgraph vm["Linux microVM"]
|
||||
init["busybox init (PID 1)"]
|
||||
run["run.sh (root)"]
|
||||
cmd["agent / command<br/>(image user)"]
|
||||
helper["guest helper"]
|
||||
end
|
||||
reg -->|"verify, flatten"| cli --> img
|
||||
cli -->|"spawns vfkit"| vm
|
||||
img -.->|"virtio-blk ro, first boot only"| init
|
||||
sbx -->|"virtio-blk /"| init
|
||||
share -->|"virtio-fs /.wsbx/host"| init
|
||||
init --> run --> cmd
|
||||
run --> helper
|
||||
ws -->|"virtio-fs, same path"| cmd
|
||||
socks <-->|"vsock"| helper
|
||||
```
|
||||
|
||||
**pi**: installs `@earendil-works/pi-coding-agent` at the host's `pi --version` (reinstalls when it changes).
|
||||
On every start it copies these from `~/.pi/agent` with symlinks resolved: settings, models, keybindings, mcp, AGENTS/CLAUDE/SYSTEM md files,
|
||||
extensions, skills, prompts, themes. They're linked into the guest's own `~/.pi/agent`, so host edits
|
||||
win and in-VM edits are discarded. `npm/`, `bin/` (macOS binaries) and sessions stay in the VM. `auth.json` is only
|
||||
copied with `--pi-auth`. Local `baseUrl`s in `models.json` (127.0.0.1/localhost) are tunneled automatically.
|
||||
Agent API keys (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, …) are only forwarded with `--keys`. Code in the VM can read them.
|
||||
Sandboxes persist per name (disk under `~/.wsbx/sandboxes`); `--fresh` rebuilds. See `PLAN.md` for design.
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant H as wsbx (host)
|
||||
participant V as vfkit
|
||||
participant G as guest
|
||||
H->>H: pull image (cache, tags re-resolved after 24 h)
|
||||
H->>H: first start: write meta.json, mke2fs disk seeded with busybox + stub init
|
||||
H->>H: recreate share/ (init, run.sh, guest helper)
|
||||
H->>V: boot kernel, disk, share, workspace, vsock
|
||||
V->>G: stub init mounts share, execs current init
|
||||
G->>G: first boot: untar image from read-only disk
|
||||
G->>G: run.sh: env, mounts, start helper, drop to image user
|
||||
G-->>H: exit code via share/exit, then poweroff
|
||||
```
|
||||
|
||||
[vfkit]: https://github.com/crc-org/vfkit
|
||||
- **One process per VM.** The VM lives as long as its command; the exit code comes back through the share.
|
||||
- **Persistent disk, fresh plumbing.** `disk.img` (sparse ext4) keeps the guest's state between runs; init, `run.sh`
|
||||
and the guest helper are rewritten into the share on every start, so upgrading wsbx upgrades existing sandboxes.
|
||||
- **Own OCI client.** Anonymous pulls of linux/arm64 images, layers flattened on the host (whiteouts applied),
|
||||
cached by digest. No Docker needed.
|
||||
- **No host network exposure.** `exec`, `forward`, `code` and `-p` tunnels all run over vsock through unix
|
||||
sockets in the sandbox dir; host-side listeners bind loopback only. Guest egress is vfkit NAT.
|
||||
- **Code layout.** Host: `src/*.rs`. Guest helper (exec, port forwarding, SSH for VS Code): `guest/*.go`,
|
||||
cross-compiled by `build.rs` and embedded in the binary. Design notes: `PLAN.md`.
|
||||
|
||||
## Security model
|
||||
|
||||
The VM is the boundary. The guest (including a prompt-injected agent or a malicious image) is assumed hostile.
|
||||
The VM is the boundary. The guest, including a prompt-injected agent or a malicious image, is assumed hostile.
|
||||
|
||||
- **Control share** (`/.wsbx/host`): the guest can write to it, so it's recreated empty on every start while the VM is stopped and
|
||||
deleted after exit. Guest outputs are read only as regular files with a size cap; persistent state lives in the host-only
|
||||
`meta.json`.
|
||||
- **vfkit arguments**: paths containing `,` `"` or control characters are refused (vfkit splits options on commas).
|
||||
Workspaces overlapping `~/.wsbx` are refused.
|
||||
- **Registry**: references are validated before any request, digest pins are enforced, and every blob/manifest is sha256-verified.
|
||||
Auth realms must be https. For public registries, connections to loopback/private/link-local addresses are refused
|
||||
(token realms and redirects included).
|
||||
- **pi config**: allowlisted items only. Symlinks are followed only into `~/.pi/agent` or `~/.agents/skills`, with no cycles
|
||||
and no special files, capped at 256 MB.
|
||||
- **exec**: sessions run as root before dropping to the user, so the guest helper accepts them only from the host's vsock CID,
|
||||
not from guest processes via vsock loopback.
|
||||
- **forward**: listens on the host's loopback only. Browsers don't isolate `localhost` cookies by port, so a forwarded guest
|
||||
page can read non-HttpOnly cookies your other localhost apps set. Forward only what you need.
|
||||
- **code**: the SSH server is only reachable through `wsbx exec` (your user's `~/.wsbx`), so it skips auth, with an ephemeral host key.
|
||||
It allows sessions and host → guest forwarding only; guest → host forwarding (`-R`) and agent forwarding are refused. Desktop VS Code
|
||||
auto-forwards ports the guest opens to your localhost (turn off `remote.autoForwardPorts` if unwanted), and its client
|
||||
trusts the remote server more than a browser tab does. The browser mode has the same localhost-cookie caveat as `forward`.
|
||||
- **Host tunnel**: only the ports you pass with `-p` (or the local `baseUrl`s in pi's `models.json`), over vsock.
|
||||
- **Control share**: guest-writable, so it's recreated empty on every start and deleted after exit. Guest outputs are
|
||||
read only as small regular files; persistent state lives in host-only `meta.json`.
|
||||
- **Image**: env keys must be shell identifiers; the command runs as the image's user.
|
||||
- **vfkit arguments**: paths with `,` `"` or control characters are refused. Workspaces overlapping `~/.wsbx` are refused.
|
||||
- **Registry**: references validated, digest pins enforced, every blob/manifest sha256-verified, auth realms https-only.
|
||||
Connections to loopback/private/link-local addresses are refused, including auth realms, redirects and IPv6 forms (NAT64, 6to4).
|
||||
A registry is local only if named `localhost` or a private IP literal; use the IP for LAN registries. 30 s network timeouts.
|
||||
- **Guest base**: busybox (PID 1) is pinned by digest; the kernel is sha256-checked against the Kata release.
|
||||
- **exec**: the guest helper accepts sessions only from the host's vsock CID, not from guest processes.
|
||||
- **code**: the in-guest SSH server is reachable only through `wsbx exec`, allows no `-R` or agent forwarding.
|
||||
- **pi config**: allowlisted files only; symlinks only into `~/.pi/agent` or `~/.agents/skills`, capped at 256 MB.
|
||||
|
||||
Remaining risks:
|
||||
- The workspace is read-write. A guest can plant files that run later on the host (`.git/hooks`, `.envrc`,
|
||||
IDE tasks, package scripts). Review changes before running them on the host.
|
||||
- Egress is unrestricted NAT. Anything the VM holds (keys passed with `--keys`, API keys in pi's `models.json`, `--pi-auth`)
|
||||
can be exfiltrated. A host-side credential-injecting egress proxy would fix this; it isn't built yet.
|
||||
- A kernel panic before the root disk mounts (e.g. a corrupt `disk.img`) still restart-loops; panics after boot stop
|
||||
the VM (exit 1).
|
||||
- Image layers are unpacked on the host into one tar, so a decompression bomb can fill the disk.
|
||||
- The workspace is read-write: a guest can plant files that later run on the host (`.git/hooks`, `.envrc`, package scripts).
|
||||
- Egress is unrestricted, so anything in the VM (`--keys`, pi's `models.json`, `--pi-auth`) can be exfiltrated.
|
||||
- Browsers share `localhost` cookies across ports: a page served via `forward` or `code` can read your other localhost apps' cookies.
|
||||
Desktop VS Code also auto-forwards guest ports (`remote.autoForwardPorts`).
|
||||
- Image layers are unpacked on the host, so a decompression bomb can fill the disk.
|
||||
- A kernel panic before the root disk mounts restart-loops; later panics stop the VM.
|
||||
|
||||
[vfkit]: https://github.com/crc-org/vfkit
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# Install wsbx from a release: curl -fsSL https://git.nhaiden.io/niklas/woiken-sandboxes/raw/branch/main/install.sh | sh
|
||||
# Env: WSBX_VERSION (tag, default: latest release), WSBX_INSTALL_DIR (default: ~/.local/bin)
|
||||
set -eu
|
||||
|
||||
REPO=https://git.nhaiden.io/niklas/woiken-sandboxes
|
||||
DIR=${WSBX_INSTALL_DIR:-$HOME/.local/bin}
|
||||
|
||||
[ "$(uname -s)-$(uname -m)" = Darwin-arm64 ] || { echo "wsbx needs macOS on Apple Silicon" >&2; exit 1; }
|
||||
|
||||
TAG=${WSBX_VERSION:-$(curl -fsSL https://git.nhaiden.io/api/v1/repos/niklas/woiken-sandboxes/releases/latest | sed -n 's/.*"tag_name":"\([^"]*\)".*/\1/p')}
|
||||
[ -n "$TAG" ] || { echo "could not determine the latest release" >&2; exit 1; }
|
||||
F="wsbx-$TAG-darwin-arm64.tar.gz"
|
||||
|
||||
TMP=$(mktemp -d)
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
cd "$TMP"
|
||||
echo "downloading $F"
|
||||
curl -fsSLO "$REPO/releases/download/$TAG/$F"
|
||||
curl -fsSLO "$REPO/releases/download/$TAG/$F.sha256"
|
||||
shasum -a 256 -c "$F.sha256" >/dev/null || { echo "checksum mismatch for $F" >&2; exit 1; }
|
||||
tar -xzf "$F" wsbx
|
||||
|
||||
mkdir -p "$DIR"
|
||||
install -m 755 wsbx "$DIR/wsbx"
|
||||
echo "installed $("$DIR/wsbx" --version) to $DIR/wsbx"
|
||||
|
||||
case ":$PATH:" in *":$DIR:"*) ;; *) echo "note: $DIR is not on your PATH" ;; esac
|
||||
command -v vfkit >/dev/null || echo "note: wsbx needs vfkit and e2fsprogs: brew install vfkit e2fsprogs"
|
||||
+5
-1
@@ -13,13 +13,17 @@ const STUB_INIT: &str = "#!/.wsbx/busybox sh
|
||||
echo 'wsbx: cannot mount host share'; exec /.wsbx/busybox sh
|
||||
";
|
||||
|
||||
/// busybox:musl pinned by digest: this binary is PID 1 in every VM, so a moved tag must not change it.
|
||||
/// Bump deliberately (index digest of `docker.io/library/busybox:musl`).
|
||||
const BUSYBOX: &str = "busybox@sha256:ea2b9914a16a4ac1981994af97b318f7c7d4db76b580c56177f08bf76f4a0be8";
|
||||
|
||||
/// Static busybox from the official busybox image; runs PID 1 + helpers in the guest.
|
||||
fn busybox(h: &Path) -> Result<PathBuf> {
|
||||
let p = h.join("busybox");
|
||||
if p.exists() {
|
||||
return Ok(p);
|
||||
}
|
||||
let img = oci::pull(h, "busybox:musl", false)?;
|
||||
let img = oci::pull(h, BUSYBOX, false)?;
|
||||
let tmp = h.join("busybox.tmp");
|
||||
fs::create_dir_all(&tmp)?;
|
||||
let ok = Command::new("tar").arg("-xf").arg(&img.rootfs).arg("-C").arg(&tmp).arg("bin").status()?.success();
|
||||
|
||||
+3
-2
@@ -34,7 +34,8 @@ pub fn kernel(h: &Path, update: bool, version: Option<String>) -> Result<PathBuf
|
||||
Some(v) => format!("https://api.github.com/repos/{KATA_REPO}/releases/tags/{v}"),
|
||||
None => format!("https://api.github.com/repos/{KATA_REPO}/releases/latest"),
|
||||
};
|
||||
let rel: Value = serde_json::from_reader(ureq::get(&api).call().with_context(|| format!("GET {api}"))?.into_reader())?;
|
||||
let agent = oci::agent_for("api.github.com"); // public-only resolver, like registries (redirects to the CDN included)
|
||||
let rel: Value = serde_json::from_reader(agent.get(&api).call().with_context(|| format!("GET {api}"))?.into_reader())?;
|
||||
let tag = rel["tag_name"].as_str().ok_or_else(|| anyhow!("no tag in {api}"))?;
|
||||
if k.exists() && installed.as_deref() == Some(tag) {
|
||||
eprintln!("wsbx: kernel already at Kata {tag}");
|
||||
@@ -62,7 +63,7 @@ pub fn kernel(h: &Path, update: bool, version: Option<String>) -> Result<PathBuf
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()?;
|
||||
let mut w = oci::HashWriter(tar.stdin.take().unwrap(), Sha256::new());
|
||||
std::io::copy(&mut ureq::get(url).call()?.into_reader(), &mut w)?;
|
||||
std::io::copy(&mut agent.get(url).call()?.into_reader(), &mut w)?;
|
||||
let oci::HashWriter(stdin, hasher) = w;
|
||||
drop(stdin);
|
||||
if !tar.wait()?.success() {
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ struct Opts {
|
||||
#[arg(long)]
|
||||
kernel: Option<PathBuf>,
|
||||
/// Tunnel the host's localhost:PORT to localhost:PORT in the VM (vsock, no network exposure)
|
||||
#[arg(short = 'p', long = "host-port")]
|
||||
#[arg(short = 'p', long = "host-port", value_parser = clap::value_parser!(u16).range(1..))]
|
||||
host_ports: Vec<u16>,
|
||||
}
|
||||
|
||||
|
||||
+60
-17
@@ -6,7 +6,7 @@ use sha2::{Digest, Sha256};
|
||||
use std::collections::HashSet;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{BufReader, Read, Write};
|
||||
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs};
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -60,23 +60,40 @@ pub fn is_public(ip: IpAddr) -> bool {
|
||||
|| o[0] == 0
|
||||
|| (o[0] == 100 && o[1] & 0xc0 == 64)) // CGNAT 100.64/10
|
||||
}
|
||||
IpAddr::V6(v) => match v.to_ipv4_mapped() {
|
||||
Some(v4) => is_public(v4.into()),
|
||||
None => !(v.is_loopback() || v.is_unspecified() || v.is_multicast() || v.is_unique_local() || v.is_unicast_link_local()),
|
||||
},
|
||||
IpAddr::V6(v) => {
|
||||
let v4 = |hi: u16, lo: u16| is_public(Ipv4Addr::from((hi as u32) << 16 | lo as u32).into());
|
||||
match v.segments() {
|
||||
[0, 0, 0, 0, 0, 0xffff, hi, lo] => v4(hi, lo), // IPv4-mapped
|
||||
[0x64, 0xff9b, 0, 0, 0, 0, hi, lo] => v4(hi, lo), // NAT64 well-known prefix
|
||||
[0x2002, hi, lo, ..] => v4(hi, lo), // 6to4
|
||||
[0x2001, 0xdb8, ..] | [0x2001, 0, ..] => false, // documentation, Teredo
|
||||
s => s[0] & 0xe000 == 0x2000, // global unicast 2000::/3 only
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Every HTTP agent: a silent server (connect or any single read, TLS handshake included) fails after 30 s instead of hanging.
|
||||
pub fn agent() -> ureq::AgentBuilder {
|
||||
let t = std::time::Duration::from_secs(30);
|
||||
ureq::AgentBuilder::new().timeout_connect(t).timeout_read(t)
|
||||
}
|
||||
|
||||
/// Registry the user named as local: `localhost` or a non-public IP literal. Decided by name only --
|
||||
/// a DNS name pointing at loopback (e.g. *.127.0.0.1.nip.io) is controlled by whoever owns the zone.
|
||||
fn explicit_local(registry: &str) -> bool {
|
||||
let host = registry.split_once(':').map_or(registry, |(h, _)| h);
|
||||
host == "localhost" || host.parse().is_ok_and(|ip| !is_public(ip))
|
||||
}
|
||||
|
||||
/// HTTP agent for a registry. Public registries get an agent that refuses to connect to non-public
|
||||
/// addresses (covers token realms and blob redirects too); a registry that is itself local
|
||||
/// (e.g. localhost:5000) was chosen explicitly by the user and keeps the default agent.
|
||||
fn agent_for(registry: &str) -> ureq::Agent {
|
||||
let addr = if registry.contains(':') { registry.to_string() } else { format!("{registry}:443") };
|
||||
let local = addr.to_socket_addrs().map(|mut a| a.any(|a| !is_public(a.ip()))).unwrap_or(false);
|
||||
if local {
|
||||
return ureq::agent();
|
||||
/// addresses (covers token realms and blob redirects too); an explicitly local registry
|
||||
/// (e.g. localhost:5000, 192.168.1.5:5000) was chosen by the user and keeps the default agent.
|
||||
pub fn agent_for(registry: &str) -> ureq::Agent {
|
||||
if explicit_local(registry) {
|
||||
return agent().build();
|
||||
}
|
||||
ureq::AgentBuilder::new()
|
||||
agent()
|
||||
.resolver(|addr: &str| -> std::io::Result<Vec<SocketAddr>> {
|
||||
let ok: Vec<SocketAddr> = addr.to_socket_addrs()?.filter(|a| is_public(a.ip())).collect();
|
||||
if ok.is_empty() {
|
||||
@@ -199,8 +216,11 @@ pub fn pull(home: &Path, image: &str, refresh: bool) -> Result<Image> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Flattened name for humans plus a hash of the exact reference, so `a_b:t` and `a/b:t` never share a ref file.
|
||||
/// (Pre-hash ref files are simply ignored: the image is re-resolved and gc drops them.)
|
||||
fn ref_path(home: &Path, image: &str) -> PathBuf {
|
||||
home.join("images/refs").join(image.replace(['/', ':', '@'], "_"))
|
||||
let h = hex::encode(Sha256::digest(image));
|
||||
home.join("images/refs").join(format!("{}-{}", image.replace(['/', ':', '@'], "_"), &h[..16]))
|
||||
}
|
||||
|
||||
fn image_dir(home: &Path, digest: &str) -> PathBuf {
|
||||
@@ -224,7 +244,10 @@ pub fn gc(home: &Path, keep: &[String]) -> Result<u64> {
|
||||
for e in fs::read_dir(home.join("images/refs"))?.flatten() {
|
||||
match fs::read_to_string(e.path()) {
|
||||
Ok(d) if keep.contains(&e.path()) => drop(live.insert(image_dir(home, d.trim()))),
|
||||
_ => fs::remove_file(e.path())?,
|
||||
_ => match fs::remove_file(e.path()) {
|
||||
Err(e) if e.kind() != std::io::ErrorKind::NotFound => return Err(e.into()), // gone: a concurrent pull renamed it
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
}
|
||||
let mut freed = 0;
|
||||
@@ -467,14 +490,26 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn public_addresses() {
|
||||
for ip in ["127.0.0.1", "10.1.2.3", "172.16.0.1", "192.168.64.1", "169.254.169.254", "100.64.0.1", "0.0.0.0", "::1", "fe80::1", "fd00::1", "::ffff:127.0.0.1"] {
|
||||
for ip in ["127.0.0.1", "10.1.2.3", "172.16.0.1", "192.168.64.1", "169.254.169.254", "100.64.0.1", "0.0.0.0", "::1", "fe80::1", "fd00::1", "::ffff:127.0.0.1",
|
||||
"64:ff9b::7f00:1", "64:ff9b::a00:1", "64:ff9b:1::1", "2002:7f00:1::1", "2002:c0a8:101::", "::7f00:1", "::a00:1",
|
||||
"2001:db8::1", "2001::1", "ff02::1"] {
|
||||
assert!(!is_public(ip.parse().unwrap()), "{ip} must be rejected");
|
||||
}
|
||||
for ip in ["8.8.8.8", "140.82.121.4", "2606:4700::6810:84e5"] {
|
||||
for ip in ["8.8.8.8", "140.82.121.4", "2606:4700::6810:84e5", "64:ff9b::808:808", "2002:808:808::1", "::ffff:8.8.8.8"] {
|
||||
assert!(is_public(ip.parse().unwrap()), "{ip} must be allowed");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_registries() {
|
||||
for l in ["localhost:5000", "localhost", "127.0.0.1:5000", "192.168.1.5:5000"] {
|
||||
assert!(explicit_local(l), "{l}");
|
||||
}
|
||||
for r in ["evil.127.0.0.1.nip.io:8443", "localhost.evil.com", "ghcr.io", "8.8.8.8:443", "registry-1.docker.io"] {
|
||||
assert!(!explicit_local(r), "{r}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_refs() {
|
||||
for bad in ["alpine@sha256:../../x", "../x", "a/../b", "alpine:../x", "Alpine", "a//b"] {
|
||||
@@ -485,6 +520,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ref_paths_distinct() {
|
||||
let h = Path::new("/h");
|
||||
assert_ne!(ref_path(h, "evil_bar:v1"), ref_path(h, "evil/bar:v1"));
|
||||
assert_ne!(ref_path(h, "docker_sandbox-templates_claude-code"), ref_path(h, "docker/sandbox-templates:claude-code"));
|
||||
assert_eq!(ref_path(h, "alpine"), ref_path(h, "alpine"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn digests() {
|
||||
assert!(check_digest(&format!("sha256:{}", "a".repeat(64))).is_ok());
|
||||
|
||||
+2
-2
@@ -88,9 +88,9 @@ fn rows(h: &Path) -> Result<Vec<Row>> {
|
||||
let Ok(rd) = fs::read_dir(h.join("sandboxes")) else { return Ok(vec![]) };
|
||||
let mut rows = vec![];
|
||||
for e in rd.flatten() {
|
||||
let Ok(m) = fs::read(e.path().join("meta.json")) else { continue };
|
||||
let Some(meta) = fs::read(e.path().join("meta.json")).ok().and_then(|m| serde_json::from_slice(&m).ok()) else { continue };
|
||||
let running = lock_stopped(&e.path()).is_err();
|
||||
rows.push(Row { name: e.file_name().to_string_lossy().into(), dir: e.path(), meta: serde_json::from_slice(&m)?, running });
|
||||
rows.push(Row { name: e.file_name().to_string_lossy().into(), dir: e.path(), meta, running });
|
||||
}
|
||||
rows.sort_by(|a, b| a.name.cmp(&b.name));
|
||||
Ok(rows)
|
||||
|
||||
@@ -76,9 +76,10 @@ pub fn run(h: &Path, o: Opts, image: &str, cmd: Vec<String>, extra: &[String], g
|
||||
}
|
||||
if !disk.exists() {
|
||||
eprintln!("wsbx: creating sandbox {name}");
|
||||
create_disk(h, &disk, o.disk)?;
|
||||
// meta first: it marks the image as in use for `wsbx gc` and makes a crashed create visible to ps/rm
|
||||
meta = json!({"image": image, "digest": img.digest, "workspace": ws, "created": now(), "provisioned": false});
|
||||
fs::write(&meta_path, serde_json::to_vec_pretty(&meta)?)?;
|
||||
create_disk(h, &disk, o.disk)?;
|
||||
}
|
||||
|
||||
// Build the guest-side run script (executed as root by init, then drops to the image user).
|
||||
@@ -119,8 +120,9 @@ pub fn run(h: &Path, o: Opts, image: &str, cmd: Vec<String>, extra: &[String], g
|
||||
}
|
||||
}
|
||||
for e in env {
|
||||
if let Some((k, v)) = e.split_once('=') {
|
||||
s += &format!("export {k}={}\n", sq(v));
|
||||
match export(&e) {
|
||||
Some(line) => s += &line,
|
||||
None => eprintln!("wsbx: skipping env entry with invalid name: {e:?}"),
|
||||
}
|
||||
}
|
||||
s += &format!("export WSBX_USER={}\n", sq(&user));
|
||||
@@ -241,6 +243,13 @@ pub fn run(h: &Path, o: Opts, image: &str, cmd: Vec<String>, extra: &[String], g
|
||||
}
|
||||
}
|
||||
|
||||
/// `export K='v'` line; None unless K is a shell identifier (image Env is hostile and run.sh runs as root).
|
||||
fn export(e: &str) -> Option<String> {
|
||||
let (k, v) = e.split_once('=')?;
|
||||
let ok = k.bytes().next().is_some_and(|b| b.is_ascii_alphabetic() || b == b'_') && k.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'_');
|
||||
ok.then(|| format!("export {k}={}\n", sq(v)))
|
||||
}
|
||||
|
||||
/// Small result file written by the guest; regular files only (no symlinks), size-capped.
|
||||
fn guest_output(share: &Path, name: &str) -> Option<String> {
|
||||
let p = share.join(name);
|
||||
@@ -282,6 +291,14 @@ pub fn term_size() -> Option<(u16, u16)> {
|
||||
mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn env_keys() {
|
||||
assert_eq!(super::export("_A1=x y").as_deref(), Some("export _A1='x y'\n"));
|
||||
for bad in ["PWN$(id > /ws/pwn)=x", "=x", "1A=x", "A B=x", "A;id=x", "noequals"] {
|
||||
assert!(super::export(bad).is_none(), "{bad}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vfkit_injection_rejected() {
|
||||
assert!(super::vf(Path::new("/Users/me/repo")).is_ok());
|
||||
|
||||
Reference in New Issue
Block a user