Skip to content

fix(cli): keep API-set configuration when policy set updates a Cedar policy - #5984

Open
vishwa-raman wants to merge 1 commit into
mainfrom
fix/5983-cedar-policy-set-keeps-config/vishwa-raman
Open

vishwa-raman wants to merge 1 commit into
mainfrom
fix/5983-cedar-policy-set-keeps-config/vishwa-raman

Conversation

@vishwa-raman

Copy link
Copy Markdown
Collaborator

Summary

openshell policy set with a .cedar file 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_set reuses the current revision it already fetches to detect no-ops. When both the new and the current policy are Cedar, it copies landlock, process, network_middlewares, and endpoint_settings from the current revision into the update. provider_credential_rules stays gateway-managed and is not sent.
  • If that fetch fails for a Cedar file, the command fails rather than dropping the configuration. NotFound and Unimplemented still proceed, so a missing sandbox, or a gateway without the RPC, returns the gateway's own error from the update.
  • YAML files keep full-replace semantics, because they carry these sections themselves.
  • The CLI never parses Cedar. It checks only whether the cedar_policy message is present, and carries the other fields unchanged.
  • docs/how-it-works/policies/cedar.mdx: one sentence stating that policy set keeps 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 set with 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

  • Checks appropriate to the affected code and behavior pass
  • Unit tests added/updated (if applicable)
  • E2E tests added/updated (if applicable)

Run on this branch, rebased onto df18dc4ef:

  • Stable dependency graphs: cargo tree --locked -e normal -p <pkg> -i cedar-policy matches no packages for openshell-gateway, openshell-supervisor, openshell-cli, openshell-sandbox, and openshell-tui. With --features experimental, the gateway graph resolves ai-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.lock is unchanged, so offline packaging is unaffected.
  • End to end: e2e/cedar/test.sh against a Docker gateway and supervisor built with experimental, with the Cedar sandbox's redaction middleware set through the API. With main's CLI, three middleware checks fail after policy set, and the secret reaches the upstream. With this CLI, all 31 checks pass. That e2e coverage lives on test/cedar-examples/vishwa-raman and is not part of this PR.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

…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>
@vishwa-raman vishwa-raman added the topic:policy Policy authoring, validation, proving, distribution, enforcement, ergonomics, and hardening. label Nov 26, 2026
@vishwa-raman

Copy link
Copy Markdown
Collaborator Author

/ok to test 7cadf29

@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Nov 26, 2026
@github-actions

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue topic:policy Policy authoring, validation, proving, distribution, enforcement, ergonomics, and hardening.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: openshell policy set with a .cedar file drops middleware and other API-set configuration

1 participant