Skip to content

Commit 46978de

Browse files
committed
feat(policy): make Cedar an opt-in cedar feature
Cedar sandbox policies now ship only in builds that enable the gateway and supervisor `cedar` Cargo feature. Release Dev and branch E2E enable it; prerelease and stable builds exclude the Cedar engine. - openshell-policy has no default features. Cedar validation, load warnings, filesystem-grant derivation, and provider-rule conversion live in its gated `cedar` module; clients carry Cedar documents as text. - openshell-supervisor-network gates its Cedar engine behind `cedar`; builds without it use an uninhabited stub that rejects Cedar policies. - The gateway and supervisor derive supports_cedar_policy from the compiled feature. A gateway without Cedar rejects Cedar on create, update, start, and stored-policy reads, and skips such sandboxes in store-wide checks. - The gateway returns policy load warnings (PolicyWarning) from CreateSandbox and sandbox UpdateConfig, including on replay; the CLI prints them and no longer links Cedar. - Compute drivers report driver_enforces_policy, and the gateway rejects Cedar for drivers that enforce policy themselves, such as MXC. - CI lints and tests both configurations, verifies stable dependency graphs exclude Cedar, and release builds fail if a binary embeds a Cedar crate. - The Cedar docs page is published only on the dev docs site. Signed-off-by: Johnny Greco <[email protected]>
1 parent 2927646 commit 46978de

127 files changed

Lines changed: 3833 additions & 1947 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/release-captain/SKILL.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ tag, or start a second `Pre-release` run for a tag; it has no concurrency guard.
4141
- `Release` (`release.yml`) is dispatched by hand with the stable version. It
4242
picks the highest `-pre.N` on `main` whose whole `Pre-release` run passed,
4343
creates the stable tag on that commit, and publishes without requalifying.
44+
- Pre-release and stable builds exclude development-only features such as
45+
Cedar policies. Qualification has no `cedar` or `mcp-cedar` E2E suite; those
46+
run only in `Release Dev` and branch E2E, so their absence from a
47+
`Pre-release` run is expected.
4448

4549
## Setup
4650

‎.agents/skills/update-docs/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Write the smallest update that tells users exactly what changed and what they ne
111111
- **Keep each page URL equal to its file path** under `docs/`. Rename the file when you rename a page, add a `fern/docs.yml` redirect for the old URL, and set a relative `slug:` when the nav label does not produce the file name. `mise run docs` runs `docs:nav`, which fails otherwise.
112112
- **Use `keywords` as a comma-separated string**.
113113
- **Do not add a duplicate H1**. Fern renders the page title from frontmatter.
114+
- **Keep development-only features on development-only pages**. A feature that stable and prerelease builds exclude, such as Cedar policies, belongs on a page with `development-only: true` in frontmatter, which only the `dev` docs version publishes. Do not link to that page or describe the feature from other pages. Refer to `fern/README.md`.
114115
- **Always write NVIDIA in all caps.** Wrong: Nvidia, nvidia.
115116
- **Always capitalize OpenShell correctly.** Wrong: openshell, Openshell, openShell.
116117
- **Do not number section titles.** Wrong: "Section 1: Deploy a Gateway" or "Step 3: Verify." Use plain descriptive titles.

‎.github/actions/build-rust-binary/action.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ inputs:
2929
description: Additional flags passed to cargo build
3030
required: false
3131
default: ""
32+
forbidden-crates:
33+
description: Space-separated crate names that must not appear in the binary's embedded cargo-auditable dependency list
34+
required: false
35+
default: ""
3236
entitlements-file:
3337
description: Path to an entitlements plist for macOS ad-hoc codesigning (skipped when empty or not on macOS)
3438
required: false
@@ -65,12 +69,27 @@ runs:
6569
env:
6670
INPUTS_BINARY: ${{ inputs.binary }}
6771
INPUTS_TRIPLE: ${{ inputs.triple }}
72+
INPUTS_FORBIDDEN_CRATES: ${{ inputs.forbidden-crates }}
6873
run: |
6974
binary="target/${INPUTS_TRIPLE}/release/${INPUTS_BINARY}"
7075
# Confirm the binary runs and reports the expected name.
7176
"$binary" --version | grep -q "^${INPUTS_BINARY} "
7277
# Confirm Syft can decode the embedded cargo-auditable metadata.
73-
SYFT_CHECK_FOR_APP_UPDATE=false syft "file:${binary}" -o cyclonedx-json | grep 'pkg:cargo/' > /dev/null
78+
sbom="$(SYFT_CHECK_FOR_APP_UPDATE=false syft "file:${binary}" -o cyclonedx-json)"
79+
grep -q 'pkg:cargo/' <<< "$sbom"
80+
# Reject crates this build must not link, such as the Cedar policy
81+
# engine in stable release binaries.
82+
read -ra forbidden_crates <<< "${INPUTS_FORBIDDEN_CRATES}"
83+
found=()
84+
for crate in "${forbidden_crates[@]}"; do
85+
if grep -Fq "\"pkg:cargo/${crate}@" <<< "$sbom"; then
86+
found+=("$crate")
87+
fi
88+
done
89+
if [ "${#found[@]}" -gt 0 ]; then
90+
echo "::error::${INPUTS_BINARY} (${INPUTS_TRIPLE}) embeds forbidden crates: ${found[*]}" >&2
91+
exit 1
92+
fi
7493
7594
- name: Codesign with entitlements
7695
if: inputs.entitlements-file != '' && runner.os == 'macOS'

‎.github/workflows/branch-checks.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ jobs:
280280
cargo clippy --locked --manifest-path examples/isolation-backend-v8/Cargo.toml --all-targets -- -D warnings
281281
cargo clippy --locked --manifest-path tests/testkit/Cargo.toml --all-targets -- -D warnings
282282
283+
# Stable builds leave Cedar off (the step above); Release Dev builds turn
284+
# it on. Lint the workspace in both configurations.
285+
- name: Lint (Cedar enabled)
286+
shell: nix develop -c bash -euo pipefail {0}
287+
run: cargo clippy --locked --workspace --all-targets --features openshell-gateway/cedar,openshell-supervisor/cedar -- -D warnings
288+
283289
rust-test:
284290
name: Rust test (${{ matrix.system }})
285291
needs: pr_metadata
@@ -329,6 +335,14 @@ jobs:
329335
cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml
330336
cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path tests/testkit/Cargo.toml
331337
338+
# Stable builds leave Cedar off (the step above); Release Dev builds turn
339+
# it on. Test the workspace in both configurations.
340+
- name: Test (Cedar enabled)
341+
shell: nix develop -c bash -euo pipefail {0}
342+
env:
343+
OPENSHELL_TELEMETRY_ENABLED: "false"
344+
run: cargo nextest run --locked --profile ci --workspace --features openshell-server/test-support,openshell-gateway/cedar,openshell-supervisor/cedar
345+
332346
rust-postgres-test:
333347
name: Rust PostgreSQL tests
334348
needs: pr_metadata
@@ -419,6 +433,10 @@ jobs:
419433
exit 1
420434
fi
421435
436+
- name: Verify Cedar opt-in dependency boundary
437+
shell: nix develop -c bash -euo pipefail {0}
438+
run: tasks/scripts/verify-cedar-boundary.sh
439+
422440
rust-feature-alias:
423441
name: Rust feature alias
424442
needs: pr_metadata

‎.github/workflows/branch-e2e.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ jobs:
108108
uses: ./.github/workflows/build-binaries.yml
109109
with:
110110
cargo-version: ${{ needs.version.outputs.cargo }}
111+
# Match Release Dev, which enables the Cedar policy engine.
112+
extra-cargo-features: cedar
111113
secrets:
112114
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
113115

@@ -314,6 +316,7 @@ jobs:
314316
with:
315317
image-tag: ${{ github.sha }}
316318
runner: linux-arm64-cpu8
319+
cedar-suites: true
317320

318321
podman-e2e:
319322
needs: [pr_metadata, build-binaries, build-images]

‎.github/workflows/build-binaries.yml‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ on:
1717
required: false
1818
type: string
1919
default: ""
20+
extra-cargo-features:
21+
description: >-
22+
Cargo features added to the openshell-gateway and openshell-supervisor
23+
builds only. Release Dev passes "cedar"; stable builds pass nothing.
24+
required: false
25+
type: string
26+
default: ""
27+
forbidden-crates:
28+
description: >-
29+
Space-separated crate names that must not appear in any built
30+
binary's embedded dependency list.
31+
required: false
32+
type: string
33+
default: ""
2034
secrets:
2135
CACHIX_AUTH_TOKEN:
2236
required: true
@@ -26,6 +40,9 @@ permissions:
2640

2741
env:
2842
EXTRA_CARGO_FLAGS: ""
43+
# Jobs that build openshell-gateway or openshell-supervisor override this
44+
# with inputs.extra-cargo-features. No other package defines those features.
45+
EXTRA_CARGO_FEATURES: ""
2946

3047
jobs:
3148
cli:
@@ -60,7 +77,8 @@ jobs:
6077
triple: ${{ matrix.triple }}
6178
cargo-version: ${{ inputs.cargo-version }}
6279
supervisor-image-tag: ${{ inputs.supervisor-image-tag }}
63-
extra-cargo-flags: ${{ env.EXTRA_CARGO_FLAGS }}
80+
extra-cargo-flags: ${{ env.EXTRA_CARGO_FLAGS }}${{ env.EXTRA_CARGO_FEATURES != '' && format(' --features {0}', env.EXTRA_CARGO_FEATURES) || '' }}
81+
forbidden-crates: ${{ inputs.forbidden-crates }}
6482

6583
prover:
6684
name: openshell-prover (${{ matrix.triple }})
@@ -85,6 +103,7 @@ jobs:
85103
env:
86104
PACKAGE: openshell-gateway
87105
BINARY: openshell-gateway
106+
EXTRA_CARGO_FEATURES: ${{ inputs.extra-cargo-features }}
88107
strategy:
89108
matrix:
90109
include:
@@ -103,6 +122,9 @@ jobs:
103122
env:
104123
PACKAGE: ${{ matrix.package }}
105124
BINARY: ${{ matrix.binary }}
125+
# openshell-sandbox has no cedar or dev feature; only the supervisor
126+
# entries take the extra features.
127+
EXTRA_CARGO_FEATURES: ${{ matrix.package == 'openshell-supervisor' && inputs.extra-cargo-features || '' }}
106128
strategy:
107129
matrix:
108130
include:

‎.github/workflows/build-vm-driver.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ on:
1717
required: false
1818
type: string
1919
default: ""
20+
forbidden-crates:
21+
description: >-
22+
Space-separated crate names that must not appear in the driver's
23+
embedded dependency list.
24+
required: false
25+
type: string
26+
default: ""
2027
secrets:
2128
CACHIX_AUTH_TOKEN:
2229
required: true
@@ -111,3 +118,4 @@ jobs:
111118
cargo-version: ${{ inputs['cargo-version'] }}
112119
supervisor-image-tag: ${{ inputs['supervisor-image-tag'] }}
113120
entitlements-file: ${{ matrix.entitlements-file }}
121+
forbidden-crates: ${{ inputs['forbidden-crates'] }}

‎.github/workflows/e2e-docker-test.yml‎

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ on:
2525
required: false
2626
type: string
2727
default: ""
28+
cedar-suites:
29+
description: >-
30+
Also run the Cedar suites. The gateway and supervisor under test
31+
must be built with the Cedar feature, as Release Dev and branch E2E
32+
builds are. Stable and pre-release builds exclude Cedar.
33+
required: false
34+
type: boolean
35+
default: false
2836
suite-matrix:
2937
required: false
3038
type: string
3139
default: >-
32-
[{"suite":"python","cmd":"mise run --no-deps --skip-deps e2e:python","apt_packages":"","python_proto":true,"mcp":false},{"suite":"oidc-python","cmd":"mise run --no-deps --skip-deps e2e:oidc-python:docker","apt_packages":"","python_proto":true,"mcp":false},{"suite":"oidc-pkce-docker","cmd":"mise run --no-deps --skip-deps e2e:oidc-pkce:docker","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"rust-docker","cmd":"mise run --no-deps --skip-deps e2e:rust","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"rust-docker-push","cmd":"mise run --no-deps --skip-deps e2e:rust:push","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"oci-image","cmd":"mise run --no-deps --skip-deps e2e:oci-image","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"mcp","cmd":"mise run --no-deps --skip-deps e2e:mcp","apt_packages":"","python_proto":false,"mcp":true},{"suite":"mcp-cedar","cmd":"POLICY_FORMAT=cedar mise run --no-deps --skip-deps e2e:mcp","apt_packages":"","python_proto":false,"mcp":true},{"suite":"cedar","cmd":"mise run --no-deps --skip-deps e2e:cedar","apt_packages":"","python_proto":false,"mcp":false}]
40+
[{"suite":"python","cmd":"mise run --no-deps --skip-deps e2e:python","apt_packages":"","python_proto":true,"mcp":false},{"suite":"oidc-python","cmd":"mise run --no-deps --skip-deps e2e:oidc-python:docker","apt_packages":"","python_proto":true,"mcp":false},{"suite":"oidc-pkce-docker","cmd":"mise run --no-deps --skip-deps e2e:oidc-pkce:docker","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"rust-docker","cmd":"mise run --no-deps --skip-deps e2e:rust","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"rust-docker-push","cmd":"mise run --no-deps --skip-deps e2e:rust:push","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"oci-image","cmd":"mise run --no-deps --skip-deps e2e:oci-image","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"mcp","cmd":"mise run --no-deps --skip-deps e2e:mcp","apt_packages":"","python_proto":false,"mcp":true}]
3341
3442
permissions:
3543
actions: read
@@ -45,7 +53,7 @@ jobs:
4553
fail-fast: false
4654
matrix:
4755
include: ${{ fromJSON(inputs.suite-matrix) }}
48-
container:
56+
container: &e2e_container
4957
image: ghcr.io/nvidia/openshell/ci:37072ee81cd7b294c714bfa5ecc829b6927b3d70@sha256:ffa96b8009de6e28bbf157060440c3abb312d3bcda444e9571c539c8c6115615
5058
credentials:
5159
username: ${{ github.actor }}
@@ -54,13 +62,13 @@ jobs:
5462
volumes:
5563
- /var/run/docker.sock:/var/run/docker.sock
5664
- /home/runner/_work:/home/runner/_work
57-
env:
65+
env: &e2e_env
5866
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5967
IMAGE_TAG: ${{ inputs.image-tag }}
6068
OPENSHELL_REGISTRY: ghcr.io/nvidia/openshell
6169
OPENSHELL_SANDBOX_RUNTIME_IMAGE: ${{ format('ghcr.io/nvidia/openshell/sandbox:{0}', inputs.image-tag) }}
6270
OPENSHELL_SUPERVISOR_IMAGE: ${{ format('ghcr.io/nvidia/openshell/supervisor:{0}', inputs.image-tag) }}
63-
steps:
71+
steps: &e2e_steps
6472
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
6573
with:
6674
ref: ${{ inputs.checkout-ref || github.sha }}
@@ -108,3 +116,26 @@ jobs:
108116
env:
109117
OPENSHELL_MCP_CONFORMANCE_CLIENT_IMAGE: ${{ format('openshell-mcp-conformance-client:{0}', inputs.image-tag) }}
110118
run: ${{ matrix.cmd }}
119+
120+
e2e-cedar:
121+
name: E2E (${{ matrix.suite }})
122+
if: inputs.cedar-suites
123+
runs-on: ${{ inputs.runner }}
124+
timeout-minutes: 30
125+
strategy:
126+
fail-fast: false
127+
matrix:
128+
include:
129+
- suite: mcp-cedar
130+
cmd: POLICY_FORMAT=cedar mise run --no-deps --skip-deps e2e:mcp
131+
apt_packages: ""
132+
python_proto: false
133+
mcp: true
134+
- suite: cedar
135+
cmd: mise run --no-deps --skip-deps e2e:cedar
136+
apt_packages: ""
137+
python_proto: false
138+
mcp: false
139+
container: *e2e_container
140+
env: *e2e_env
141+
steps: *e2e_steps

‎.github/workflows/release-build.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ jobs:
125125
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}
126126
supervisor-image-tag: ${{ needs.compute-versions.outputs.semver }}
127127
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
128+
# Pre-release and stable binaries exclude the Cedar policy engine.
129+
# Release Dev enables it with the gateway and supervisor `cedar` feature.
130+
forbidden-crates: &cedar_crates >-
131+
cedar-policy cedar-policy-core cedar-policy-formatter
132+
openshell-policy-cedar openshell-policy-cedar-schema
128133
secrets:
129134
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
130135

@@ -137,6 +142,7 @@ jobs:
137142
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}
138143
supervisor-image-tag: ${{ needs.compute-versions.outputs.semver }}
139144
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}
145+
forbidden-crates: *cedar_crates
140146
secrets:
141147
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
142148

‎.github/workflows/release-dev.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ jobs:
6868
cargo-version: ${{ needs.compute-versions.outputs.cargo_version }}
6969
supervisor-image-tag: dev
7070
checkout-ref: ${{ github.sha }}
71+
# Release Dev publishes the Cedar policy engine in the gateway and
72+
# supervisor. Stable releases leave it off.
73+
extra-cargo-features: cedar
7174
secrets:
7275
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
7376

@@ -163,6 +166,7 @@ jobs:
163166
image-tag: ${{ github.sha }}
164167
checkout-ref: ${{ github.sha }}
165168
runner: linux-arm64-cpu8
169+
cedar-suites: true
166170

167171
vm-e2e:
168172
needs: [build-binaries, build-vm-driver]

0 commit comments

Comments
 (0)