fix(policy): reserve provider rule namespace#1991
Conversation
|
🌿 Preview your docs: https://nvidia-preview-pr-1991.docs.buildwithfern.com/openshell |
PR Review StatusValidation: This PR is project-valid because it implements the linked policy/gateway bug fix in #1982, keeps the scope concentrated to provider-derived policy namespace handling, and includes docs plus targeted regression coverage. Review findings:
Docs: Updated for the direct policy UX change, but the warning above should be reconciled with the documented behavior. Next state: |
071b7e3 to
b4f6ced
Compare
|
Addressed the Gator feedback in
Validation:
|
Re-check After Author UpdateI re-evaluated latest head Disposition: partially resolved. The prior runtime-policy mutation and global full-policy ingress findings are addressed, but one blocking legacy-data path remains. Remaining items:
Docs: updated in the relevant Fern docs pages; no navigation change appears necessary. Next state: |
b4f6ced to
5d9c464
Compare
|
Follow-up in Project assumption for this PR: persisted user/source policies with I did remove the unsupported overlap regression that asserted a user/source Validation:
|
Re-check After Author UpdateI re-evaluated latest head Disposition: not resolved. The earlier legacy-data migration scope is no longer the blocking item, but the latest head introduces a new runtime sync regression that needs author changes before gator can move this PR to pipeline watch. Remaining items:
Docs: updated in the relevant Fern docs pages; no navigation change appears necessary. Next state: |
5d9c464 to
ceaf8dc
Compare
|
Addressed the latest Gator feedback and rebased onto current Change made:
Validation:
|
PR Review StatusValidation: This PR is project-valid because it implements the linked provider-policy namespace hardening bug in #1982, keeps the scope concentrated to policy/gateway/sandbox sync boundaries, and updates the relevant Fern docs plus regression coverage. Review findings:
Docs: updated in the relevant Fern docs pages; no navigation change appears necessary. Next state: |
ceaf8dc to
1b887bb
Compare
|
Addressed the latest Gator feedback in The approval merge path now validates the constructed I also added regression coverage for a stored pending draft chunk named Verification run:
|
PR Review StatusValidation: This PR is project-valid because it implements the linked provider-policy namespace hardening bug in #1982, keeps the scope concentrated to policy/gateway/sandbox sync boundaries, and updates the relevant Fern docs plus regression coverage. Review findings:
Docs: updated in the relevant Fern docs pages; no navigation change appears necessary. E2E: Next state: |
|
Label |
pimlock
left a comment
There was a problem hiding this comment.
Looks good, just one comment around the error message/options for getting the policy document with our CLI.
| .find(|key| openshell_policy::is_provider_rule_name(key)) | ||
| { | ||
| return Err(Status::invalid_argument(format!( | ||
| "network_policies key '{key}' uses reserved '_provider_' prefix for provider composition; use 'openshell policy get <sandbox>' without '--full' for round-trippable output, or remove generated provider entries before applying a full policy" |
There was a problem hiding this comment.
Without --full, the policy document is not returned at all. The way to get the policy without provider entries is to do openshell policy get --rev LAST_REV --full.
I think we need a flag to output policy without provider entries.
Thinking through options of how these 2 could be presented
# Option 1. what we have
policy get --user/base
policy get --full
# or
policy get --include-providers # full may be better, because there may be more things contributing to the overall policy
# Option 2. explicit --show with param that controls what is shown (alternatively '--print')
policy get --show full
policy get --show user/base # or --print
# Option 3. use get for metadata and show for policy document?
policy show # prints the base one
policy show --full
policy show --include-providers
Looking at these, I think the clearest setup could be:
- flag/subcommand that controls if the policy document is printed
- flag that controls what should be included in the policy document
So I think the option 2 may be the sweet spot?
There was a problem hiding this comment.
Implemented this in 9430cef2.
openshell policy get now has an explicit --base payload mode for the round-trippable user-authored policy, and --full remains the effective/composed view including provider entries. The flags are mutually exclusive. The --base implementation strips reserved _provider_* entries from the policy payload before YAML/JSON serialization, so users can do:
openshell policy get <sandbox> --base > current-policy.yaml
openshell policy set <sandbox> --policy current-policy.yaml --waitI also updated the reserved-prefix validation message to point at --base and refreshed the Providers v2 / policy docs to use base policy + provider policy => effective policy terminology.
Verification:
cargo fmt --allRUSTC_WRAPPER= cargo test -p openshell-cli policy_get --binsRUSTC_WRAPPER= cargo test -p openshell-cli --test sandbox_name_fallback_integration policy_getRUSTC_WRAPPER= cargo test -p openshell-server validate_no_reserved_provider_policy_keys --libRUSTC_WRAPPER= mise run pre-commit
Closes #1982 Reject user-authored _provider_* network policy keys at gateway boundaries, strip provider-derived rules from sandbox sync, and document the round-trip workflow. Signed-off-by: John Myers <9696606+johntmyers@users.noreply.github.com>
1b887bb to
9430cef
Compare
PR Review StatusValidation: This PR is project-valid because it implements the linked provider-policy namespace hardening bug in #1982, keeps the scope concentrated to policy/gateway/sandbox/CLI boundaries, and updates the relevant Fern docs plus regression coverage. Review findings:
Docs: updated in the relevant Fern docs pages; no navigation change appears necessary. E2E: Next state: |
Summary
Reserve
_provider_*as a provider-derived network policy namespace. User-authored sandbox create, full policy replacement, and incremental add-rule writes now reject reserved keys, while sandbox-originated policy sync strips provider-derived rules before persisting source policy.Related Issue
Closes #1982
Changes
crates/openshell-policy: added shared provider rule namespace helpers and reused them in merge fallback guards.crates/openshell-server: added reserved-key validation for user policy writes, sandbox-principal sync stripping, and regression tests for create/update/merge paths.crates/openshell-sandbox: strips provider-derived entries before supervisor policy sync/write-back.docs/sandboxes/providers-v2.mdxanddocs/sandboxes/policies.mdx: documented the reserved namespace and round-trip behavior.Deviations from Plan
Added rejection for incremental
add_rulemerge operations using_provider_*rule names. This closes the same user-facing policy-key ingress class while still allowing remove-style operations for cleanup.Testing
RUSTC_WRAPPER= cargo test -p openshell-policy provider_ruleRUSTC_WRAPPER= cargo test -p openshell-server reserved_provider --libRUSTC_WRAPPER= cargo test -p openshell-sandbox provider_policy_entries --libRUSTC_WRAPPER= mise run pre-commitpassese2e/changedTests added:
openshell-policy; reserved-key validation inopenshell-server; supervisor strip helper inopenshell-sandbox.spec.policyand policy revision persistence.Checklist
Documentation updated:
docs/sandboxes/providers-v2.mdx: reserved_provider_*namespace behavior.docs/sandboxes/policies.mdx: full-policy round-trip guidance for provider-derived entries.