refactor(suidhelper): move jailer exec mechanics behind a bon builder#66
Merged
Conversation
Split the jailer subcommand along the tools=glue/util=laws line: the validated newtypes (VmId, CgroupSetting, JailSock), their refusal contracts, and the become-root/execve mechanics move to util::jailer as a bon-built Jailer struct; tools::jailer keeps only the clap surface, trusted-config resolution, and re-exports. Ad-hoc cstr_* helpers become a ToCStringExt extension trait in util::path (TryFrom<&Path> for CString is orphan-rule-forbidden).
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Splits the
jailersubcommand along the tools=glue / util=laws line:src/util/jailer.rs(new) — the validated newtypes (VmId,CgroupSetting,JailSock),validate_id_number, their refusal-contract docs, and the become-root/execvemechanics now live here as aJailerstruct built withbon::Builder. Trusted-config fields (jailer,firecracker,jail_base,parent_cgroup) and caller-validated fields (vm,uid,gid,cgroups,api_sock) are documented as distinct trust classes;invoke()consumes the struct, enforces the cgroup cap, builds argv, raises privilege, closes inherited fds, andexecves (Ok arm isInfallible).src/util/path.rs(new) —ToCStringExtextension trait (to_cstring()onPathandstr) replaces the ad-hoccstr_path/cstr_str/cstr_byteshelpers.impl TryFrom<&Path> for CStringwould be the natural spelling but is orphan-rule-forbidden (both types are std's).src/tools/jailer.rs— shrinks to the clap surface + trusted-config resolution; re-exports the validators sotests/tools/jailer.rsandmain.rsare untouched.Why
Same shape as the rest of the crate's typed-proof style: named builder setters instead of a 9-positional-arg
build_argv, compile-time-required fields via bon's typestate, and the security core (refusal contracts + execve) in one audited util module instead of interleaved with CLI glue.Adds
bon = 3.9as a dependency.Testing
cargo fmt --check,cargo clippy --all-targets(0 warnings),cargo nextest run— 121/121 passcargo check --all-targets --features insecure_test_seamscleantests/tools/jailer.rsunchanged and green