refactor: run sandboxed scripts through a sandbox runner #2888
All Vouch review confidence checks passed
Residual risk 0.36 = Change Risk (0.61) × (1 − Review Confidence (0.42)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.61 · 353 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.351
Shallow Review Depth
shallow_review_depth
0.344
No Reviewer Assigned
no_reviewer_assigned
0.120
Real PR Conversation Timeline
1 comments
"Review active on #2888"
general
weight: 0.35
baszalmstra
Stacked on #2885.
run_scripthas two execution paths. Without--sandboxit runs the wrapper through aSession; with--sandboxit falls back to a host-side helper that spawnsrattler-sandboxitself, so the sandbox bypasses the runner entirely and anything that configures a runner (tests, library callers) silently loses it. The fallback also only knows about the build directory, so package tests never ran sandboxed, and a missingrattler-sandboxonly showed up after every environment was solved.This turns sandboxing into a runner.
SandboxRunnerwraps aLocalRunnerand prefixes everyexecwithrattler-sandbox, the static policy from the configuration, and the access derived from the session mounts: a writable mount gets read, write and execute, a read-only mount gets read.SandboxRunner::newchecks the platform and looks up the executable, so--sandboxon Windows warns and runs locally, and a missingrattler-sandboxfails before solving. Build, staging and package tests all pass their mounts through the newMountsbuilder (Mounts::new().writable(build_dir).read_only(recipe_dir)), which keeps insertion order and nothing else; the sandbox runner rejects a mount whose guest path differs from its host path because it cannot remap paths.The host-side fallback,
run_process_with_replacements,SandboxConfiguration::with_cwdandShellDialect::supports_sandboxare gone, andBuildLogSinkno longer captures output in memory because nothing read it.Two behaviour changes worth knowing about: package tests now run under the sandbox too, and the recipe directory is always readable, which matters with
--overwrite-default-sandbox-config.Testing
Unit tests cover the sandbox argv for writable and read-only mounts, rejection of unmirrored mounts, the platform and executable checks at construction and in
check_usable, andrun_scriptconfined through a fakerattler-sandboxonPATH.The second commit adds the first end-to-end coverage of
--sandbox: two recipes try to write a marker under the home directory (the default policy leaves/tmpwritable, so that is not a useful target), one from the build script and one from a package test. Each test first builds without the sandbox to show the marker appears, then with it to show the build fails and the marker does not.rattler-sandboxis now a Unix dependency of the pixi workspace, and the Ubuntu CI job lifts the AppArmor restriction on unprivileged user namespaces first, which 24.04 enables by default and which the sandbox needs. Both tests pass natively on Linux (WSL Ubuntu, "Read-only file system" from the script); macOS is only covered by CI. Please look closely at the derived grants inDirectories::session_mountsand the test call sites; that is where the old behaviour could differ.