Repository navigation
fix(cli): keep API-set configuration when policy set updates a Cedar policy - #5984
Open
vishwa-raman wants to merge 1 commit into
Open
vishwa-raman wants to merge 1 commit into
vishwa-raman wants to merge 1 commit into
Conversation
…policy A Cedar policy file holds only Cedar source. Landlock compatibility, process identity, network middlewares, and endpoint settings for a Cedar policy are set through the policy API, and UpdateConfig replaces the whole policy. `openshell policy set` with a .cedar file therefore removed that configuration silently: a redaction middleware disappeared and the secret it guarded reached the upstream. When both the new and the current policy are Cedar, policy set now copies those fields from the current revision, which it already fetches to detect no-ops. If that fetch fails for a Cedar file, the command fails rather than dropping the configuration; a missing sandbox or a gateway without the RPC still gets the gateway's own error from the update. YAML files keep full-replace semantics, since they carry these sections themselves. Signed-off-by: Vishwanath Raman <vishwanathr@nvidia.com>
Collaborator
Author
|
/ok to test 7cadf29 |
|
🌿 Preview your docs: https://nvidia-preview-pr-5984.docs.buildwithfern.com/openshell |
This branch has not been deployed
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
openshell policy setwith a.cedarfile replaced the whole policy with the Cedar source only, which silently removed the middleware, endpoint settings, process identity, and Landlock settings set through the policy API. It now keeps that configuration and replaces only the Cedar source.Related Issue
Closes #5983
Refs #4474
Changes
sandbox_policy_setreuses the current revision it already fetches to detect no-ops. When both the new and the current policy are Cedar, it copieslandlock,process,network_middlewares, andendpoint_settingsfrom the current revision into the update.provider_credential_rulesstays gateway-managed and is not sent.NotFoundandUnimplementedstill proceed, so a missing sandbox, or a gateway without the RPC, returns the gateway's own error from the update.cedar_policymessage is present, and carries the other fields unchanged.docs/how-it-works/policies/cedar.mdx: one sentence stating thatpolicy setkeeps API-set configuration.RFC 0020 (#4564) still describes the old behavior. It will be updated together with the upcoming global-policy and incremental-update changes.
Release Notes
openshell policy setwith a Cedar policy file now keeps middleware, endpoint settings, process identity, and Landlock settings that were set through the API, and replaces only the Cedar source.Testing
Run on this branch, rebased onto
df18dc4ef:cargo tree --locked -e normal -p <pkg> -i cedar-policymatches no packages foropenshell-gateway,openshell-supervisor,openshell-cli,openshell-sandbox, andopenshell-tui. With--features experimental, the gateway graph resolvesai-openshell/cedar.cargo test --locked -p openshell-policy-conformance -p openshell-policy-cedar-runtime: 151 and 77 passed, 3 Linux-only ignored.cargo clippy --locked --workspace --all-targets --features experimental -- -D warnings: clean.cargo test --locked -p openshell-cli: 809 passed, 6 ignored, including two new unit tests: Cedar updates keep the four fields, and YAML updates, or a Cedar update over a YAML policy, are unchanged.Cargo.lockis unchanged, so offline packaging is unaffected.e2e/cedar/test.shagainst a Docker gateway and supervisor built withexperimental, with the Cedar sandbox's redaction middleware set through the API. With main's CLI, three middleware checks fail afterpolicy set, and the secret reaches the upstream. With this CLI, all 31 checks pass. That e2e coverage lives ontest/cedar-examples/vishwa-ramanand is not part of this PR.Checklist