Skip to content

Commit f8f13a0

Browse files
vishwa-ramanjohnnygrecodrew
committed
feat(policy): support Cedar as an alternate sandbox policy language
A sandbox policy can be written in Cedar instead of YAML. The format is chosen once per sandbox: YAML policies keep using the Rego engine unchanged, and a .cedar policy makes Cedar the sole authority for network connections, per-request L7 checks, and Landlock filesystem grants. This is the original implementation branch for #4411. It was refactored and merged to main through #5005 and #5006 (152c59d), which supersede it. The full commit history is kept on vishwa/cedar-openshell-history. The branch stays because some of its work did not make it into #5006 and will be pulled selectively into future PRs: - CLI configuration of middleware, endpoint settings, and process for Cedar sandboxes (--middleware) - Load-time policy warnings returned to clients - Clients checking that a gateway supports Cedar before sending a policy - Cedar guidance in the public openshell-cli and generate-sandbox-policy skills Refs #4474 Signed-off-by: Vishwanath Raman <vishwanathr@nvidia.com> Co-authored-by: Johnny Greco <jogreco@nvidia.com> Co-authored-by: Drew Newberry <anewberry@nvidia.com>
1 parent bd2ecaf commit f8f13a0

232 files changed

Lines changed: 50293 additions & 4342 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: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ 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: ""
36+
required-crates:
37+
description: Space-separated crate names that must appear in the binary's embedded cargo-auditable dependency list
38+
required: false
39+
default: ""
3240
entitlements-file:
3341
description: Path to an entitlements plist for macOS ad-hoc codesigning (skipped when empty or not on macOS)
3442
required: false
@@ -65,12 +73,41 @@ runs:
6573
env:
6674
INPUTS_BINARY: ${{ inputs.binary }}
6775
INPUTS_TRIPLE: ${{ inputs.triple }}
76+
INPUTS_FORBIDDEN_CRATES: ${{ inputs.forbidden-crates }}
77+
INPUTS_REQUIRED_CRATES: ${{ inputs.required-crates }}
6878
run: |
6979
binary="target/${INPUTS_TRIPLE}/release/${INPUTS_BINARY}"
7080
# Confirm the binary runs and reports the expected name.
7181
"$binary" --version | grep -q "^${INPUTS_BINARY} "
7282
# 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
83+
sbom="$(SYFT_CHECK_FOR_APP_UPDATE=false syft "file:${binary}" -o cyclonedx-json)"
84+
grep -q 'pkg:cargo/' <<< "$sbom"
85+
# Reject crates this build must not link, such as the Cedar policy
86+
# engine in stable release binaries.
87+
read -ra forbidden_crates <<< "${INPUTS_FORBIDDEN_CRATES}"
88+
found=()
89+
for crate in "${forbidden_crates[@]}"; do
90+
if grep -Fq "\"pkg:cargo/${crate}@" <<< "$sbom"; then
91+
found+=("$crate")
92+
fi
93+
done
94+
if [ "${#found[@]}" -gt 0 ]; then
95+
echo "::error::${INPUTS_BINARY} (${INPUTS_TRIPLE}) embeds forbidden crates: ${found[*]}" >&2
96+
exit 1
97+
fi
98+
# Require crates this build must link, such as the Cedar policy engine
99+
# in Cedar-enabled builds, so the check above cannot pass vacuously.
100+
read -ra required_crates <<< "${INPUTS_REQUIRED_CRATES}"
101+
missing=()
102+
for crate in "${required_crates[@]}"; do
103+
if ! grep -Fq "\"pkg:cargo/${crate}@" <<< "$sbom"; then
104+
missing+=("$crate")
105+
fi
106+
done
107+
if [ "${#missing[@]}" -gt 0 ]; then
108+
echo "::error::${INPUTS_BINARY} (${INPUTS_TRIPLE}) lacks required crates: ${missing[*]}" >&2
109+
exit 1
110+
fi
74111
75112
- name: Codesign with entitlements
76113
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ 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
113+
required-crates: cedar-policy openshell-policy-cedar
111114
secrets:
112115
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
113116

@@ -314,6 +317,7 @@ jobs:
314317
with:
315318
image-tag: ${{ github.sha }}
316319
runner: linux-arm64-cpu8
320+
cedar-suites: true
317321

318322
podman-e2e:
319323
needs: [pr_metadata, build-binaries, build-images]

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ 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: ""
34+
required-crates:
35+
description: >-
36+
Space-separated crate names that must appear in the
37+
openshell-gateway and openshell-supervisor binaries' embedded
38+
dependency lists, such as the crates extra-cargo-features enables.
39+
required: false
40+
type: string
41+
default: ""
2042
secrets:
2143
CACHIX_AUTH_TOKEN:
2244
required: true
@@ -26,6 +48,11 @@ permissions:
2648

2749
env:
2850
EXTRA_CARGO_FLAGS: ""
51+
# Jobs that build openshell-gateway or openshell-supervisor override these
52+
# with inputs.extra-cargo-features and inputs.required-crates. No other
53+
# package defines those features.
54+
EXTRA_CARGO_FEATURES: ""
55+
REQUIRED_CRATES: ""
2956

3057
jobs:
3158
cli:
@@ -60,7 +87,9 @@ jobs:
6087
triple: ${{ matrix.triple }}
6188
cargo-version: ${{ inputs.cargo-version }}
6289
supervisor-image-tag: ${{ inputs.supervisor-image-tag }}
63-
extra-cargo-flags: ${{ env.EXTRA_CARGO_FLAGS }}
90+
extra-cargo-flags: ${{ env.EXTRA_CARGO_FLAGS }}${{ env.EXTRA_CARGO_FEATURES != '' && format(' --features {0}', env.EXTRA_CARGO_FEATURES) || '' }}
91+
forbidden-crates: ${{ inputs.forbidden-crates }}
92+
required-crates: ${{ env.REQUIRED_CRATES }}
6493

6594
prover:
6695
name: openshell-prover (${{ matrix.triple }})
@@ -85,6 +114,8 @@ jobs:
85114
env:
86115
PACKAGE: openshell-gateway
87116
BINARY: openshell-gateway
117+
EXTRA_CARGO_FEATURES: ${{ inputs.extra-cargo-features }}
118+
REQUIRED_CRATES: ${{ inputs.required-crates }}
88119
strategy:
89120
matrix:
90121
include:
@@ -103,6 +134,10 @@ jobs:
103134
env:
104135
PACKAGE: ${{ matrix.package }}
105136
BINARY: ${{ matrix.binary }}
137+
# openshell-sandbox has no cedar or dev feature; only the supervisor
138+
# entries take the extra features.
139+
EXTRA_CARGO_FEATURES: ${{ matrix.package == 'openshell-supervisor' && inputs.extra-cargo-features || '' }}
140+
REQUIRED_CRATES: ${{ matrix.package == 'openshell-supervisor' && inputs.required-crates || '' }}
106141
strategy:
107142
matrix:
108143
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: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ 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
@@ -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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ 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
74+
required-crates: cedar-policy openshell-policy-cedar
7175
secrets:
7276
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
7377

@@ -163,6 +167,7 @@ jobs:
163167
image-tag: ${{ github.sha }}
164168
checkout-ref: ${{ github.sha }}
165169
runner: linux-arm64-cpu8
170+
cedar-suites: true
166171

167172
vm-e2e:
168173
needs: [build-binaries, build-vm-driver]

0 commit comments

Comments
 (0)