Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ jobs:
- run: cargo test --locked --lib --bins

msrv:
name: MSRV 1.87
name: MSRV 1.89
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.87
- uses: dtolnay/rust-toolchain@1.89
- uses: Swatinem/rust-cache@v2
- run: cargo check --all-targets --locked

Expand Down
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ members = ["crates/*"]
default-members = [".", "crates/*"]

[workspace.package]
version = "4.0.0"
version = "4.0.1"
edition = "2024"
rust-version = "1.87"
rust-version = "1.89"
license = "LicenseRef-EXA-SL-1.0"
repository = "https://github.com/execution-associates/isb"
homepage = "https://github.com/execution-associates/isb"

[workspace.dependencies]
isb-core = { path = "crates/isb-core", version = "=4.0.0" }
isb-server = { path = "crates/isb-server", version = "=4.0.0" }
isb-apps = { path = "crates/isb-apps", version = "=4.0.0" }
isb-daemon = { path = "crates/isb-daemon", version = "=4.0.0" }
isb-tui = { path = "crates/isb-tui", version = "=4.0.0" }
isb-egress = { path = "crates/isb-egress", version = "=4.0.0" }
isb-core = { path = "crates/isb-core", version = "=4.0.1" }
isb-server = { path = "crates/isb-server", version = "=4.0.1" }
isb-apps = { path = "crates/isb-apps", version = "=4.0.1" }
isb-daemon = { path = "crates/isb-daemon", version = "=4.0.1" }
isb-tui = { path = "crates/isb-tui", version = "=4.0.1" }
isb-egress = { path = "crates/isb-egress", version = "=4.0.1" }

serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down Expand Up @@ -100,7 +100,7 @@ toml = { version = "1", default-features = false, features = ["parse", "serde",
# isb serve's identity store (isb-server auth): SQLite compiled from source,
# so the static musl build needs no system library; argon2id for passwords,
# salted from ring's OS randomness, so no getrandom/password-hash features.
rusqlite = { version = "0.40", features = ["bundled"] }
rusqlite = { version = "0.41", features = ["bundled"] }
argon2 = { version = "0.6", default-features = false, features = ["alloc"] }

# The local registry's TLS: an isb CA and the registry's certificate, on ring.
Expand All @@ -126,6 +126,9 @@ too_many_lines = "warn"
excessive_nesting = "warn"
too_many_arguments = "warn"
type_complexity = "warn"
# Off since the MSRV reached let-chains (1.88): the nested `if let`s that
# predate them are left as they are rather than rewritten all at once.
collapsible_if = "allow"

# Debug builds keep line tables (backtraces with file:line) but no variable
# or type info, which halves the debuginfo rustc emits and the linker reads;
Expand Down
51 changes: 46 additions & 5 deletions crates/isb-core/src/x/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,29 @@ pub fn check_name(name: &str) -> Result<()> {
Ok(())
}

/// A shim that runs installed tool `tool`'s program `bin`.
/// A shim that runs installed tool `tool`'s program `bin`. The `--` keeps
/// every argument the tool's, even one isb itself reads, such as `--help`.
pub fn for_tool(tool: &str, bin: &str) -> String {
format!(
"#!/bin/sh\n{MARK}: `{bin}` runs in the sandbox of isbx tool {tool} (`isb x rm {tool}` removes it)\nexec isb x tool {tool} {bin} \"$@\"\n"
"#!/bin/sh\n{MARK}: `{bin}` runs in the sandbox of isbx tool {tool} (`isb x rm {tool}` removes it)\nexec isb x tool {tool} {bin} -- \"$@\"\n"
)
}

/// Rewrite shim `name` to `body` when it is an isbx shim that says
/// something else (one an older isb wrote); whether it was rewritten.
pub fn refresh(name: &str, body: &str) -> Result<bool> {
refresh_in(&dir(), name, body)
}

fn refresh_in(d: &Path, name: &str, body: &str) -> Result<bool> {
let p = d.join(name);
if !is_shim(&p) || std::fs::read_to_string(&p).is_ok_and(|t| t == body) {
return Ok(false);
}
write_in(d, name, body)?;
Ok(true)
}

/// A shim that runs host command `cmd` as a one-off in the project sandbox.
pub fn for_run(cmd: &str) -> String {
format!(
Expand All @@ -62,10 +78,13 @@ pub fn is_shim(p: &Path) -> bool {

/// Write shim `name` with `body`, replacing only an isbx shim.
pub fn write(name: &str, body: &str) -> Result<PathBuf> {
write_in(&dir(), name, body)
}

fn write_in(d: &Path, name: &str, body: &str) -> Result<PathBuf> {
use std::os::unix::fs::PermissionsExt;
check_name(name)?;
let d = dir();
std::fs::create_dir_all(&d)?;
std::fs::create_dir_all(d)?;
let p = d.join(name);
if p.symlink_metadata().is_ok() && !is_shim(&p) {
return Err(Error::invalid(format!(
Expand Down Expand Up @@ -141,14 +160,36 @@ mod tests {
fn shims_are_marked_and_quote_nothing_from_the_caller() {
let s = for_tool("sume", "sume");
assert!(s.starts_with("#!/bin/sh\n# isbx shim"));
assert!(s.ends_with("exec isb x tool sume sume \"$@\"\n"));
assert!(s.ends_with("\nexec isb x tool sume sume -- \"$@\"\n"));
assert!(for_run("npm").contains("exec isb x run -- npm \"$@\""));
assert!(check_name("npm").is_ok() && check_name("g++").is_ok());
for bad in ["", "a/b", ".hidden", "isb", "isbx", "sudo", "a b"] {
assert!(check_name(bad).is_err(), "{bad:?}");
}
}

#[test]
fn an_old_tool_shim_is_rewritten_and_nothing_else() {
let t = tempfile::tempdir().unwrap();
let d = t.path();
let old = for_tool("nc", "namecheap").replace(" -- \"$@\"", " \"$@\"");
std::fs::write(d.join("namecheap"), &old).unwrap();
let new = for_tool("nc", "namecheap");
assert!(refresh_in(d, "namecheap", &new).unwrap());
assert_eq!(std::fs::read_to_string(d.join("namecheap")).unwrap(), new);
// Up to date already: left alone.
assert!(!refresh_in(d, "namecheap", &new).unwrap());
// Not isbx's, or not there: never written.
std::fs::write(d.join("node"), "#!/bin/sh\nexec node\n").unwrap();
assert!(!refresh_in(d, "node", &for_tool("n", "node")).unwrap());
assert_eq!(
std::fs::read_to_string(d.join("node")).unwrap(),
"#!/bin/sh\nexec node\n"
);
assert!(!refresh_in(d, "gone", &for_tool("g", "gone")).unwrap());
assert!(!d.join("gone").exists());
}

#[test]
fn only_isbx_shims_count() {
let t = tempfile::tempdir().unwrap();
Expand Down
6 changes: 3 additions & 3 deletions docs/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Inside the sandbox, as `dev` (except `apt`, which is root's):

```sh
mise use -g rust@stable bun@latest # cargo, rustc, rustup, bun
rustup toolchain install 1.87 --profile minimal \
-c clippy -c rustfmt # the minimum supported version: cargo +1.87 build
rustup toolchain install 1.89 --profile minimal \
-c clippy -c rustfmt # the minimum supported version: cargo +1.89 build
rustup target add x86_64-unknown-linux-musl # the release target (aarch64-... on arm64)
apt-get install -y musl-tools # root: provides musl-gcc
```
Expand Down Expand Up @@ -149,7 +149,7 @@ Plain `cargo test`, `cargo clippy`, `cargo doc` and `cargo build` cover the
whole workspace (`default-members`). CI runs the same steps
(`.github/workflows/ci.yml` and `build-health.yml`), plus `cargo doc` with
warnings denied, a `cargo package` dry run, a macOS build and test on arm64
and x86_64, the minimum supported Rust version (1.87), and the web UI's lint,
and x86_64, the minimum supported Rust version (1.89), and the web UI's lint,
tests and build.

## The legibility ratchet
Expand Down
6 changes: 5 additions & 1 deletion docs/guides/isbx.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ to look it up on the guest's PATH) names them instead. Each becomes a shim:
$ cat ~/.local/share/isb/x/bin/sume
#!/bin/sh
# isbx shim: `sume` runs in the sandbox of isbx tool sume (`isb x rm sume` removes it)
exec isb x tool sume sume "$@"
exec isb x tool sume sume -- "$@"
```

The `--` hands every argument to the tool, `--help` and `--version` too.
Shims an older isb wrote lack it; `isb x doctor` (or `isb x update`)
rewrites them.

**The shim directory must come first on PATH,** before version managers'
directories, or a host `npm` wins over a shim named `npm`
([Putting the shims on PATH](#putting-the-shims-on-path)). `isbx sume …`
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ it; relative paths resolve against that directory.
When it starts, the server writes one hello line:

```json
{"isb": "4.0.0", "protocol": 1}
{"isb": "4.0.1", "protocol": 1}
```

A client checks `protocol` and refuses versions it does not know.
Expand Down Expand Up @@ -205,7 +205,7 @@ All take `files` (default `./isb.yaml` plus `./isb.override.yaml` if present),
## Example session

```text
<- {"isb":"4.0.0","protocol":1}
<- {"isb":"4.0.1","protocol":1}
-> {"id":1,"method":"sandbox.ensure","params":{"spec":{"name":"web","image":"dev-base","cpus":2}}}
<- {"id":1,"event":"progress","data":"web: creating from dev-base"}
<- {"id":1,"event":"progress","data":"web: starting"}
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "isb-sdk"
version = "4.0.0"
version = "4.0.1"
description = "Python SDK for isb: declarative incus sandboxes (containers and VMs)"
readme = "README.md"
license = "MIT AND LicenseRef-EXA-SL-1.0"
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/src/isb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def main():
from ._util import Duration
from .volumes import Volumes

__version__ = "4.0.0"
__version__ = "4.0.1"

__all__ = [
"PROTOCOL",
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async def test_death_fails_pending_requests(self) -> None:
path = fake_server(
self.tmp.name,
"""\
echo '{"isb":"4.0.0","protocol":1}'
echo '{"isb":"4.0.1","protocol":1}'
read line
echo "boom" >&2
exit 3
Expand All @@ -243,7 +243,7 @@ async def test_close_fails_pending(self) -> None:
path = fake_server(
self.tmp.name,
"""\
echo '{"isb":"4.0.0","protocol":1}'
echo '{"isb":"4.0.1","protocol":1}'
cat >/dev/null
""",
)
Expand All @@ -261,7 +261,7 @@ async def test_events_and_out_of_order_replies(self) -> None:
path = fake_server(
self.tmp.name,
"""\
echo '{"isb":"4.0.0","protocol":1}'
echo '{"isb":"4.0.1","protocol":1}'
read a
read b
echo 'not json'
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/typescript/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/typescript/npm/linux-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@execution-associates/isb-linux-arm64",
"version": "4.0.0",
"version": "4.0.1",
"description": "The static isb binary for Linux arm64 (aarch64-unknown-linux-musl), used by @execution-associates/isb",
"license": "SEE LICENSE IN LICENSE",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/npm/linux-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@execution-associates/isb-linux-x64",
"version": "4.0.0",
"version": "4.0.1",
"description": "The static isb binary for Linux x64 (x86_64-unknown-linux-musl), used by @execution-associates/isb",
"license": "SEE LICENSE IN LICENSE",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions sdk/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@execution-associates/isb",
"version": "4.0.0",
"version": "4.0.1",
"description": "TypeScript SDK for isb: declarative incus sandboxes (containers and VMs)",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -51,8 +51,8 @@
"prepack": "bun run build"
},
"optionalDependencies": {
"@execution-associates/isb-linux-arm64": "4.0.0",
"@execution-associates/isb-linux-x64": "4.0.0"
"@execution-associates/isb-linux-arm64": "4.0.1",
"@execution-associates/isb-linux-x64": "4.0.1"
},
"devDependencies": {
"@biomejs/biome": "^2.2.0",
Expand Down
Loading
Loading