feat(caps): ILO-345 --allow-env flag for env-read capability#680
Merged
Conversation
Add --allow-env CLI flag (Option<String> allowlist) to gate the `env` and `env-all` builtins. Mirrors the existing --allow-net/read/write/run pattern from ILO-59: omitting the flag stays permissive; any --allow-* flag present switches to Caps::Restricted where only listed vars pass. - caps.rs: add `env: Policy` field to Caps::Restricted; add check_env() method (exact-name match; env-all passes "*" sentinel) - cli/args.rs: add --allow-env=VARS RunArgs field - main.rs: wire allow_env into build_caps(); update all RunArgs literals - interpreter/mod.rs: check_env() guard in Builtin::Env and Builtin::EnvAll - vm/mod.rs: check_env() guard in OP_ENV handler - tests: caps unit tests, dispatch_run integration tests, example file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
--allow-env=VARSCLI flag gating theenvandenv-allbuiltins, following the existing--allow-net/read/write/runpattern from ILO-59 (feat(caps): CLI capability flags — allow-net/read/write/run (ILO-59) #606)Caps::Restrictedgains anenv: Policyfield; newcheck_env(name)method uses exact-name matching (env-all passes"*"sentinel, which thePolicy::Alldefault always permits)OP_ENVhandler are guarded;env-allroutes through the interpreter bridge so its guard is also coveredErrvalue (consistent with--allow-netbehaviour) rather than a hard crashTest plan
cargo test --lib caps— 32 unit tests forCapsincluding 6 newcheck_envcasescargo test --bin ilo allow_env— 3 dispatch-level integration tests (permissive, empty-list blocks, specific-var allowed)cargo test— full suite clean (pre-existingverify.rsdoctest failure unrelated)ilo run --allow-env=PATH,HOME examples/allow-env-cap.ilo main— manual smoke testCloses ILO-345. Extends ILO-59 (#606).
🤖 Generated with Claude Code