From 5b615eaa4d8395d009ca0c2868717adc88d79920 Mon Sep 17 00:00:00 2001 From: Ilan Harel Date: Mon, 16 Nov 2026 14:04:38 +0200 Subject: [PATCH] chore(deps): bump OpenShell crates to v0.1.8 Closes #80 Pins openshell-policy-schema and openshell-policy to the stable OpenShell v0.1.8 tag and updates every version string, the generated policy headers and goldens. Handles the v0.1.8 upgrade notes that touch annotate (see PR description). Signed-off-by: Ilan Harel --- .cargo/audit.toml | 2 +- AGENTS.md | 2 +- CHANGELOG.md | 1 + Cargo.lock | 10 +++++----- Cargo.toml | 6 +++--- Dockerfile | 2 +- README.md | 12 +++++++---- ROADMAP.md | 2 +- docs/DEVELOPING.md | 16 ++++++++------- docs/DIRECTIVES.md | 2 +- docs/RELEASING.md | 6 ++++++ examples/polyglot/openshell/policy.yaml | 2 +- src/diff_logs.rs | 22 +++++++++++++++++++-- src/generate.rs | 2 +- src/image.rs | 6 +++--- src/render.rs | 2 +- src/scaffold.rs | 3 +++ src/spec.rs | 2 +- src/validate.rs | 2 +- tests/fixtures/sample/policy.expected.yaml | 2 +- tests/gateway_policies.rs | 18 +++++++++++++++++ tests/golden/diff_logs_human_color.txt | 2 +- tests/golden/diff_logs_human_plain.txt | 2 +- tests/golden/diff_logs_ocsf_1_8_0_plain.txt | 2 +- 24 files changed, 90 insertions(+), 38 deletions(-) diff --git a/.cargo/audit.toml b/.cargo/audit.toml index 7a5579a..612847a 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -5,7 +5,7 @@ ignore = [ # RUSTSEC-2026-0459: libsqlite3-sys 0.37.0 (C SQLite CVE-2026-119375), fixed in >= 0.39.0. # https://rustsec.org/advisories/RUSTSEC-2026-0459 - tracked in https://github.com/ilanh/openshell-annotate/issues/76 - # Transitive and not upgradable from this repo: OpenShell v0.1.7 openshell-crypto -> sqlx 0.9.0 -> sqlx-sqlite =0.9.0 + # Transitive and not upgradable from this repo: OpenShell v0.1.7 and v0.1.8 openshell-crypto -> sqlx 0.9.0 -> sqlx-sqlite =0.9.0 # (exact pin) -> libsqlite3-sys 0.37.0. openshell-annotate does not use SQLite itself. # Remove this entry once an OpenShell release bumps sqlx/libsqlite3-sys and we move the pin to it. "RUSTSEC-2026-0459", diff --git a/AGENTS.md b/AGENTS.md index 6b58d02..1cb1821 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,7 +10,7 @@ subprocesses; add directives with reasons; run `scan`, `generate`, `lint`, `drif ## When changing this tool - Build/test: `cargo build && cargo test` (Rust 1.94+). The schema crate is a git dependency pinned to the - OpenShell `v0.1.7` tag (see `Cargo.toml`, `Cargo.lock` pins the commit). Update the tag deliberately and re-run + OpenShell `v0.1.8` tag (see `Cargo.toml`, `Cargo.lock` pins the commit). Update the tag deliberately and re-run the golden tests. `openshell-next` builds against the newest upstream tag, prereleases included, and is moved by `.github/workflows/openshell-next.yml`; fixes that need the newer OpenShell go there, fixes valid on the current pin go to `main` (see `docs/DEVELOPING.md`, "Tracking the next OpenShell release"). diff --git a/CHANGELOG.md b/CHANGELOG.md index ed0e611..6e0678a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ version section and adds the squash-merged PR titles since the previous tag. Ver ## [Unreleased] +- chore(deps): build against OpenShell v0.1.8 (`openshell-policy-schema`, `openshell-policy`); docs and generated policy headers now name v0.1.8. The gateway validator now rejects `websocket_credential_rewrite: true` on `protocol: rest` (covered by a test); `--scaffold-profiles` skeletons explain the v0.1.8 credential placement rule (credentials go only where the profile declares them); `diff-logs` needs no change for the OCSF `device.container.*` move; the RUSTSEC-2026-0459 ignore stays (v0.1.8 still pins `sqlx` 0.9.0) - ci: the `openshell-next` workflow also runs at 07:17 UTC as a backup for the 04:17 UTC schedule, because GitHub may delay or drop a scheduled run; both slots share one concurrency group and no-op when the pin is unchanged - docs: README try-path and install notes for early testers; feedback issue template and Discussions contact link; Contributor Covenant; SECURITY.md supported versions - ci: `openshell-next` branch automation: a daily workflow merges main into `openshell-next`, moves its OpenShell pin to the newest upstream tag (prereleases included), runs the tests and reports on the tracking issue; `scripts/openshell-tags.sh` and `scripts/openshell-next.sh` do the same by hand diff --git a/Cargo.lock b/Cargo.lock index dab4c01..1fd3f8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2111,7 +2111,7 @@ dependencies = [ [[package]] name = "openshell-core" version = "0.0.0" -source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.7#5d25211b25a8fc887e8d5c606d57d6ab22f1d76c" +source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.8#f3d976590d3eb1379690a2abaf0f0e26c21d487d" dependencies = [ "async-trait", "base64 0.22.1", @@ -2146,7 +2146,7 @@ dependencies = [ [[package]] name = "openshell-crypto" version = "0.0.0" -source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.7#5d25211b25a8fc887e8d5c606d57d6ab22f1d76c" +source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.8#f3d976590d3eb1379690a2abaf0f0e26c21d487d" dependencies = [ "aws-lc-rs", "jsonwebtoken", @@ -2164,7 +2164,7 @@ dependencies = [ [[package]] name = "openshell-extension-core" version = "0.0.0" -source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.7#5d25211b25a8fc887e8d5c606d57d6ab22f1d76c" +source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.8#f3d976590d3eb1379690a2abaf0f0e26c21d487d" dependencies = [ "hyper-util", "serde", @@ -2177,7 +2177,7 @@ dependencies = [ [[package]] name = "openshell-policy" version = "0.0.0" -source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.7#5d25211b25a8fc887e8d5c606d57d6ab22f1d76c" +source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.8#f3d976590d3eb1379690a2abaf0f0e26c21d487d" dependencies = [ "hickory-proto", "miette", @@ -2191,7 +2191,7 @@ dependencies = [ [[package]] name = "openshell-policy-schema" version = "0.0.0" -source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.7#5d25211b25a8fc887e8d5c606d57d6ab22f1d76c" +source = "git+https://github.com/NVIDIA/OpenShell?tag=v0.1.8#f3d976590d3eb1379690a2abaf0f0e26c21d487d" dependencies = [ "miette", "noyalib", diff --git a/Cargo.toml b/Cargo.toml index c107c3b..210d16a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ repository = "https://github.com/ilanh/openshell-annotate" authors = ["Ilan Harel"] [dependencies] -# Pinned to the OpenShell v0.1.7 tag; Cargo.lock records the exact commit. -openshell-policy-schema = { git = "https://github.com/NVIDIA/OpenShell", tag = "v0.1.7" } +# Pinned to the OpenShell v0.1.8 tag; Cargo.lock records the exact commit. +openshell-policy-schema = { git = "https://github.com/NVIDIA/OpenShell", tag = "v0.1.8" } # Same tag. Schema parsing accepts policies the gateway later rejects; this crate is that validator. -openshell-policy = { git = "https://github.com/NVIDIA/OpenShell", tag = "v0.1.7" } +openshell-policy = { git = "https://github.com/NVIDIA/OpenShell", tag = "v0.1.8" } anyhow = "1" clap = { version = "4", features = ["derive"] } ignore = "0.4" diff --git a/Dockerfile b/Dockerfile index 13ba5bb..d1eaab9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1.7 # Build: scripts/docker-build.sh (or: docker build -t openshell-annotate:dev .) # -# `openshell-policy-schema` is a git dependency on https://github.com/NVIDIA/OpenShell (tag v0.1.7, commit pinned +# `openshell-policy-schema` is a git dependency on https://github.com/NVIDIA/OpenShell (tag v0.1.8, commit pinned # in Cargo.lock), fetched by cargo during the build, so no local OpenShell checkout is needed. FROM rust:1.94-bookworm AS build WORKDIR /build diff --git a/README.md b/README.md index 49c83f1..6b2dbf3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ un-annotated calls, and gates CI on drift. > **Independent community project.** openshell-annotate is not affiliated with, endorsed by, or sponsored by > NVIDIA. It uses NVIDIA OpenShell's public policy schema crate (Apache-2.0) to validate what it generates. -Early pre-release **v0.1.0-rc.3** (targets OpenShell policy schema v1, `openshell-policy-schema` @ v0.1.7). +Early pre-release **v0.1.0-rc.3** (targets OpenShell policy schema v1, `openshell-policy-schema` @ v0.1.8). Licensed under Apache-2.0. ## Try it in two minutes @@ -136,7 +136,7 @@ stderr. Exit codes and `--deny-warnings` do not depend on the format. ### Files the image keeps outside OpenShell's baseline (`generate --image`) -OpenShell 0.1.7 only lets the sandbox read `/usr /lib /etc /app /var/log /proc /dev/urandom` (plus the workspace when +OpenShell 0.1.8 only lets the sandbox read `/usr /lib /etc /app /var/log /proc /dev/urandom` (plus the workspace when `include_workdir` is on) once a `filesystem_policy` exists, and it does not log filesystem denials ([NVIDIA/OpenShell#4270](https://github.com/NVIDIA/OpenShell/issues/4270)), so an application under `/opt/` fails with a bare `EACCES`. `generate --image IMAGE` inspects the image (docker, then podman: WORKDIR, ENTRYPOINT, CMD, and the directory @@ -310,7 +310,11 @@ exclude = [] # files diff-logs never picks as the place for a sugg cloud APIs only. For every credential nothing declares (reported as `unmapped`), `generate --scaffold-profiles DIR` writes `DIR/.yaml`: the credential, and the endpoints, `access` and binaries taken from the `egress` directives in the file that declares it (`tls=skip` endpoints get `allow_uninspected_credentials: true`, which OpenShell -requires). Files that already exist are kept. Review the auth style, then check and import it: +requires). Files that already exist are kept. Review the auth style, then check and import it. The skeleton sends the +credential as a bearer token in `Authorization`; since OpenShell v0.1.8 a credential is substituted only where the profile +declares it ([NVIDIA/OpenShell#4886](https://github.com/NVIDIA/OpenShell/pull/4886)), so an API that takes it in another header +(`x-api-key`), a query parameter or a URL path needs `auth_style: header|query|path` with `header_name`, `query_param` or +`path_template`: ``` openshell-annotate generate -o openshell/policy.yaml --providers-out openshell/providers.sh --scaffold-profiles openshell/profiles @@ -346,7 +350,7 @@ the rule; a profile bound to other binaries (the bundled `github` profile is for listed in `[lint] ignore_hosts`. - JS regex literals are not parsed; Python docstrings are strings (directives must be `#` comments). - Filesystem/process/landlock are startup-only in OpenShell; drift labels them `startup`. -- `diff-logs` only sees network and L7 events: OpenShell 0.1.7 does not log Landlock/filesystem denials (upstream #4270), log +- `diff-logs` only sees network and L7 events: OpenShell 0.1.8 does not log Landlock/filesystem denials (upstream #4270), log delivery is batched and best-effort (wait a few seconds after the workload; absence of an event is not proof), and `NET:REFUSE` lines carry no binary. A helper spawned by an allowed binary (git -> git-remote-http) is matched through its parent. - Semantic checks mirror `openshell-policy::validate_sandbox_policy` (documented rules) but the authoritative diff --git a/ROADMAP.md b/ROADMAP.md index 3f3a938..175e5ae 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -18,7 +18,7 @@ Order matters: each milestone builds on the previous one. Nothing is published ( ## 2. Docker image (publish) - **Scope:** small runtime image with the binary (tree-sitter grammars compiled in; distroless/cc base, 34.9 MB), entrypoint `openshell-annotate`, workdir `/src`. - **Deliverables:** multi-stage `Dockerfile`, `scripts/docker-build.sh` (local tag `openshell-annotate:dev`, no OpenShell checkout needed), then, after approval, a publish workflow to a registry (ghcr.io) with version tags. -- **Depends on:** a public home for the repo (the `openshell-policy-schema` dependency now resolves from the public OpenShell repo at tag v0.1.7, so the build is portable). Publishing to a registry needs the maintainer's approval. +- **Depends on:** a public home for the repo (the `openshell-policy-schema` dependency now resolves from the public OpenShell repo at tag v0.1.8, so the build is portable). Publishing to a registry needs the maintainer's approval. ## 3. GitHub Action + GitLab CI template - **Scope:** run `lint --deny-warnings` and `drift --policy openshell/policy.yaml` on every pull/merge request; fail with annotations. diff --git a/docs/DEVELOPING.md b/docs/DEVELOPING.md index 2d1201d..18e24c6 100644 --- a/docs/DEVELOPING.md +++ b/docs/DEVELOPING.md @@ -8,10 +8,10 @@ build that downloads crates takes longer. | Needed for | What | |---|---| -| everything | Git, a C compiler (`build-essential` / Xcode command line tools: the tree-sitter grammars are C), network access to crates.io and github.com (the OpenShell schema crate is a git dependency pinned to the `v0.1.7` tag) | +| everything | Git, a C compiler (`build-essential` / Xcode command line tools: the tree-sitter grammars are C), network access to crates.io and github.com (the OpenShell schema crate is a git dependency pinned to the `v0.1.8` tag) | | build and test | Rust **1.94** or newer through [rustup](https://rustup.rs). CI pins 1.94 | | Docker image (optional) | Docker with BuildKit | -| sandbox flow (optional) | the `openshell` CLI and `openshell-prover` at 0.1.7, a running OpenShell gateway, and Docker (see section 7) | +| sandbox flow (optional) | the `openshell` CLI and `openshell-prover` at 0.1.8, a running OpenShell gateway, and Docker (see section 7) | ``` rustup toolchain install 1.94 --profile minimal --component rustfmt,clippy @@ -93,7 +93,7 @@ sorts after its own prereleases (`latest`, `latest-stable`, `list`, `pinned`, `n ### Tracking the next OpenShell release (`openshell-next`) `openshell-next` is the one long-lived branch besides `main`. It is `main` plus the OpenShell pin moved to the newest -upstream tag, prereleases included (for example `v0.1.8-pre.3` while `main` is on `v0.1.7`), plus any fix that only +upstream tag, prereleases included (for example `v0.1.9-pre.3` while `main` is on `v0.1.8`), plus any fix that only makes sense on that version. It exists so the next OpenShell is integrated, and its breakage fixed, before it ships as stable. A draft pull request `openshell-next` → `main` and an issue labelled `openshell-next` track it; the issue gets a comment for every new upstream tag. @@ -196,8 +196,10 @@ openshell-annotate diff-logs path/to/sandbox.log --write # inserts directives a # otherwise writes openshell/observed-egress.sh (scanned like any source: review or delete it) ``` -Sample logs for both formats are in `tests/fixtures/logs/`. Filesystem denials are not logged by OpenShell 0.1.7, so -`diff-logs` only sees network and L7 events. +Sample logs for both formats are in `tests/fixtures/logs/`. Filesystem denials are not logged by OpenShell 0.1.8, so +`diff-logs` only sees network and L7 events. It reads no sandbox attribution fields, so OpenShell v0.1.8 moving +`container.uid`/`container.name` to `device.container.*` (NVIDIA/OpenShell#5048) needs no change; the OCSF fixture +is real v0.1.7 output. ## 6. Docker image @@ -222,7 +224,7 @@ scripts/flow.sh /path/to/project --diff-logs sandbox.log # + diff-logs scripts/flow.sh /path/to/project --image my-image:tag --run-seconds 30 --exercise exercise.js -- sleep 600 ``` -It needs `openshell` and `openshell-prover` 0.1.7 on PATH and a connected gateway (`openshell status` shows `Connected`), and +It needs `openshell` and `openshell-prover` 0.1.8 on PATH and a connected gateway (`openshell status` shows `Connected`), and `OPENSHELL_ANNOTATE=/path/to/binary` if the binary is not on PATH. The image's interpreter paths must be real executables (not symlinks) and match `[languages]` in `openshell-annotate.toml`, because OpenShell matches the resolved binary path. A bare `sleep` workload produces no traffic and so no events: drive the sandbox with `--exercise FILE.js` (run with `node -e`), @@ -268,4 +270,4 @@ public repo or a paid plan). `.github/rulesets/protect-openshell-next.json` bloc | `docs are stale` | run `scripts/gen-docs.sh` and commit `docs/` | | `docs/GITHUB_ACTIONS.md is out of date with actions/*/action.yml` | run `scripts/gen-actions-docs.sh` and commit it; add a `BEGIN/END actions-docs ` section for a new action | | sandbox probes get `403` from `api.github.com` | unauthenticated GitHub API rate limit (60 requests per hour per IP), not a policy decision; wait for the reset or use another host | -| `openshell-prover: not found` in `flow.sh` | install the OpenShell 0.1.7 tools; the static commands (`scan`, `generate`, `lint`, `drift`, `diff-logs`) do not need them | +| `openshell-prover: not found` in `flow.sh` | install the OpenShell 0.1.8 tools; the static commands (`scan`, `generate`, `lint`, `drift`, `diff-logs`) do not need them | diff --git a/docs/DIRECTIVES.md b/docs/DIRECTIVES.md index 40ecd8e..397f07e 100644 --- a/docs/DIRECTIVES.md +++ b/docs/DIRECTIVES.md @@ -58,7 +58,7 @@ Attributes: | Attribute | Values | Repeatable | Meaning | |---|---|---|---| | `access` | `read-only \| read-write \| full` | no | OpenShell access preset; turns on request inspection (protocol defaults to `rest`). Mutually exclusive with `allow`. For `protocol=mcp` the preset is not written out (MCP rejects access presets); it is emitted as `mcp.allow_all_known_mcp_methods: true`. | -| `protocol` | `rest \| websocket \| graphql \| mcp \| json-rpc \| tcp` | no | L7 protocol. `tcp` is uninspected L4 and cannot be combined with `access`/`allow`/`deny`. `rest`, `websocket`, and `graphql` need `access` or `allow` (a protocol alone is rejected). `mcp` never emits `access`; an `access` value becomes `mcp.allow_all_known_mcp_methods: true`. | +| `protocol` | `rest \| websocket \| graphql \| mcp \| json-rpc \| tcp` | no | L7 protocol. `tcp` is uninspected L4 and cannot be combined with `access`/`allow`/`deny`. `rest`, `websocket`, and `graphql` need `access` or `allow` (a protocol alone is rejected). `mcp` never emits `access`; an `access` value becomes `mcp.allow_all_known_mcp_methods: true`. Since OpenShell v0.1.8 a `rest` endpoint answers WebSocket upgrade requests with 403, so a WebSocket client needs `protocol=websocket`. | | `enforce` | `enforce \| audit` | no | Enforcement mode for inspected endpoints (default from `[policy] enforcement`, itself defaulting to `enforce`). | | `allow` | `METHOD:/path \| query \| mutation \| subscription` | yes | Explicit allowed request, e.g. `GET:/v1/**`. Repeatable. Implies inspection. For `protocol=graphql` the value is `query`, `mutation`, or `subscription`, optionally `:operationName`. That is emitted as `rules[].allow.operation_type` and only for GraphQL. | | `deny` | `METHOD:/path \| query \| mutation \| subscription` | yes | Request subtracted from what is allowed. Repeatable; needs `allow` or `access`. For `protocol=graphql` the value is an operation type (`query`, `mutation`, or `subscription`), emitted as `deny_rules[].operation_type` and only for GraphQL. | diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 30f0c03..88a5a3e 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -79,6 +79,12 @@ release" note to the tracking issue. To bring it to `main`: workflow create the issue at the next upstream tag; it links a compare view for opening the PR. 5. Cut a release of openshell-annotate as usual if users should get the new pin. +If `openshell-next` has already moved past the stable tag (to the next release's prereleases) before you promote, bump +`main` directly instead: on a branch from `main`, run `scripts/openshell-next.sh bump vX.Y.Z`, do step 2 there and open a +PR with `Closes #` (OpenShell v0.1.8 went this way). `sync` keeps the newer pin when it merges `main`, so +`openshell-next` stays on the prerelease; retitle the draft tracking PR for the next version or close it and let step 4 +replace it. + Never promote a prerelease pin to `main`: stable openshell-annotate releases build against stable OpenShell only. ## Installing diff --git a/examples/polyglot/openshell/policy.yaml b/examples/polyglot/openshell/policy.yaml index 513f2ed..77e238d 100644 --- a/examples/polyglot/openshell/policy.yaml +++ b/examples/polyglot/openshell/policy.yaml @@ -1,5 +1,5 @@ # Generated by openshell-annotate @VERSION@ - DO NOT EDIT. Change the @openshell directives in source and regenerate. -# Validated against openshell-policy-schema and the OpenShell v0.1.7 gateway validator. Each entry's comment gives the reason and source file:line. +# Validated against openshell-policy-schema and the OpenShell v0.1.8 gateway validator. Each entry's comment gives the reason and source file:line. # Startup-only sections (filesystem_policy, landlock, process) need a sandbox recreate to change; network_policies are live. version: 1 filesystem_policy: diff --git a/src/diff_logs.rs b/src/diff_logs.rs index 778174f..9b54658 100644 --- a/src/diff_logs.rs +++ b/src/diff_logs.rs @@ -3,7 +3,7 @@ //! directives that never matched an event are reported as stale. //! //! Delivery of these logs is best-effort: *absence of a deny or an allow is not proof*. Filesystem denials are not logged by -//! OpenShell 0.1.7 (upstream #4270), so only network and L7 HTTP events are handled. +//! OpenShell 0.1.8 (upstream #4270), so only network and L7 HTTP events are handled. use crate::config::Config; use crate::directive::{Directive, Kind}; @@ -876,7 +876,7 @@ pub fn render_text(rep: &Report) -> String { "diff-logs: {} event(s) ({} denied, {} allowed); {} suggestion(s), {} stale directive(s)\n", rep.events, rep.denied, rep.allowed, rep.suggestions.len(), rep.stale.len() ); - s.push_str("note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.7 (#4270).\n"); + s.push_str("note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.8 (#4270).\n"); for g in &rep.suggestions { let up = g.kind.to_ascii_uppercase(); s.push_str(&format!( @@ -988,6 +988,24 @@ garbage line\n"; ); } + #[test] + fn sandbox_attribution_location_does_not_matter() { + // OpenShell v0.1.8 (NVIDIA/OpenShell#5048) moved supervisor sandbox attribution from top-level `container.*` + // to `device.container.*`. diff-logs never reads either, so both shapes give the same event. + let body = "\"class_uid\":4001,\"activity_id\":1,\"status_detail\":\"transparent_tcp_policy_denied\",\"dst_endpoint\":{\"domain\":\"pypi.org\",\"port\":443},\"actor\":{\"process\":{\"name\":\"/usr/bin/python3\"}},\"action_id\":2,\"action\":\"Denied\""; + let v017 = format!("{{{body},\"device\":{{\"hostname\":\"sandbox\"}},\"container\":{{\"name\":\"s\",\"uid\":\"u\"}}}}\n"); + let v018 = format!("{{{body},\"device\":{{\"hostname\":\"sandbox\",\"container\":{{\"name\":\"s\",\"uid\":\"u\"}}}}}}\n"); + let key = |t: &str| { + parse_logs(t, "x") + .into_iter() + .map(|e| (e.action, e.host, e.port, e.binary)) + .collect::>() + }; + let a = key(&v017); + assert_eq!(a.len(), 1); + assert_eq!(a, key(&v018)); + } + #[test] fn git_helpers_match_their_parent_binary() { assert!(bin_matches( diff --git a/src/generate.rs b/src/generate.rs index 1de0090..ce30b5a 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -652,7 +652,7 @@ pub fn generate( // Emit let mut y = String::new(); y.push_str(&format!("# Generated by {TOOL} - DO NOT EDIT. Change the @openshell directives in source and regenerate.\n")); - y.push_str("# Validated against openshell-policy-schema and the OpenShell v0.1.7 gateway validator. Each entry's comment gives the reason and source file:line.\n"); + y.push_str("# Validated against openshell-policy-schema and the OpenShell v0.1.8 gateway validator. Each entry's comment gives the reason and source file:line.\n"); y.push_str("# Startup-only sections (filesystem_policy, landlock, process) need a sandbox recreate to change; network_policies are live.\n"); y.push_str("version: 1\n"); if !fs_read.is_empty() || !fs_write.is_empty() { diff --git a/src/image.rs b/src/image.rs index 9148bb5..a4cc937 100644 --- a/src/image.rs +++ b/src/image.rs @@ -1,8 +1,8 @@ //! `generate --image IMAGE`: propose `fs read` directives for application paths in a container image. //! //! The OpenShell supervisor only grants read access to a fixed baseline (`/usr /lib /etc /app /var/log /proc -//! /dev/urandom`, plus `/tmp` and `/dev/null` for writing, verified in v0.1.7 `PROXY_BASELINE_*`). An app that lives -//! elsewhere (`/opt/context7`) fails at startup with EACCES, and OpenShell 0.1.7 does not log filesystem denials +//! /dev/urandom`, plus `/tmp` and `/dev/null` for writing, verified in v0.1.7 and v0.1.8 `PROXY_BASELINE_*`). An app that lives +//! elsewhere (`/opt/context7`) fails at startup with EACCES, and OpenShell 0.1.8 does not log filesystem denials //! (upstream #4270), so neither the logs nor `diff-logs` can point at it. The image says where the app lives: its //! WORKDIR, ENTRYPOINT and CMD. @@ -260,7 +260,7 @@ pub fn add_dirs(props: &mut Vec, dirs: Vec, declared: &[String /// Renders the stderr note listing the proposals and the `@openshell fs read` lines to add for them. pub fn render_note(image: &str, props: &[Proposal]) -> String { let mut s = format!( - "note: image {image} keeps files outside OpenShell's baseline read set ({}); the sandbox cannot read them, and OpenShell 0.1.7 does not log that denial (#4270):\n", + "note: image {image} keeps files outside OpenShell's baseline read set ({}); the sandbox cannot read them, and OpenShell 0.1.8 does not log that denial (#4270):\n", ["/usr", "/lib", "/etc", "/app", "/var/log", "/proc", "/dev/urandom"].join(" ") ); for p in props { diff --git a/src/render.rs b/src/render.rs index 47c7be6..142b77c 100644 --- a/src/render.rs +++ b/src/render.rs @@ -662,7 +662,7 @@ pub fn diff_logs_human( } out.push_str(&style.paint( "2", - "note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.7 (#4270).\n", + "note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.8 (#4270).\n", )); out } diff --git a/src/scaffold.rs b/src/scaffold.rs index 0b6264b..13c8e4f 100644 --- a/src/scaffold.rs +++ b/src/scaffold.rs @@ -101,6 +101,9 @@ pub fn scaffold(unmapped: &[Unmapped], dirs: &[Directive], cfg: &Config) -> Vec< y.push_str(&format!(" env_vars: [{}]\n", u.env)); y.push_str(" required: true\n"); y.push_str(" # TODO: how does the API take this credential? bearer (authorization header) is the common case.\n"); + y.push_str(" # OpenShell v0.1.8+ substitutes it only where declared: another header needs `auth_style: header` and its\n"); + y.push_str(" # `header_name` (e.g. x-api-key), a query parameter `auth_style: query` + `query_param`, a URL path slot\n"); + y.push_str(" # `auth_style: path` + `path_template` (with {credential}).\n"); y.push_str(" auth_style: bearer\n"); y.push_str(" header_name: authorization\n"); y.push_str("discovery:\n"); diff --git a/src/spec.rs b/src/spec.rs index 61c2b02..bfbf1a2 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -74,7 +74,7 @@ pub const VERBS: &[VerbSpec] = &[ args: &[("host:port[,port...]", "Destination. A port is mandatory (OpenShell rejects endpoints without one); the host is lower-cased.")], attrs: &[ AttrSpec { name: "access", multi: false, values: "read-only | read-write | full", help: "OpenShell access preset; turns on request inspection (protocol defaults to `rest`). Mutually exclusive with `allow`. For `protocol=mcp` the preset is not written out (MCP rejects access presets); it is emitted as `mcp.allow_all_known_mcp_methods: true`." }, - AttrSpec { name: "protocol", multi: false, values: "rest | websocket | graphql | mcp | json-rpc | tcp", help: "L7 protocol. `tcp` is uninspected L4 and cannot be combined with `access`/`allow`/`deny`. `rest`, `websocket`, and `graphql` need `access` or `allow` (a protocol alone is rejected). `mcp` never emits `access`; an `access` value becomes `mcp.allow_all_known_mcp_methods: true`." }, + AttrSpec { name: "protocol", multi: false, values: "rest | websocket | graphql | mcp | json-rpc | tcp", help: "L7 protocol. `tcp` is uninspected L4 and cannot be combined with `access`/`allow`/`deny`. `rest`, `websocket`, and `graphql` need `access` or `allow` (a protocol alone is rejected). `mcp` never emits `access`; an `access` value becomes `mcp.allow_all_known_mcp_methods: true`. Since OpenShell v0.1.8 a `rest` endpoint answers WebSocket upgrade requests with 403, so a WebSocket client needs `protocol=websocket`." }, AttrSpec { name: "enforce", multi: false, values: "enforce | audit", help: "Enforcement mode for inspected endpoints (default from `[policy] enforcement`, itself defaulting to `enforce`)." }, AttrSpec { name: "allow", multi: true, values: "METHOD:/path | query | mutation | subscription", help: "Explicit allowed request, e.g. `GET:/v1/**`. Repeatable. Implies inspection. For `protocol=graphql` the value is `query`, `mutation`, or `subscription`, optionally `:operationName`. That is emitted as `rules[].allow.operation_type` and only for GraphQL." }, AttrSpec { name: "deny", multi: true, values: "METHOD:/path | query | mutation | subscription", help: "Request subtracted from what is allowed. Repeatable; needs `allow` or `access`. For `protocol=graphql` the value is an operation type (`query`, `mutation`, or `subscription`), emitted as `deny_rules[].operation_type` and only for GraphQL." }, diff --git a/src/validate.rs b/src/validate.rs index c918bcc..470f08d 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -2,7 +2,7 @@ //! //! Authoritative checks live in `openshell-policy-schema` (parsing, unknown fields) and in //! [`gateway_violations`], which calls `openshell_policy::validate_and_canonicalize_sandbox_policy` -//! (OpenShell v0.1.7, the same tag as the schema crate). This module also re-implements the +//! (OpenShell v0.1.8, the same tag as the schema crate). This module also re-implements the //! file-level semantic rules documented in `docs/how-it-works/policies/schema.mdx` so errors carry //! directive locations. `generate` round-trips its output through `parse_policy` and the gateway //! validator. diff --git a/tests/fixtures/sample/policy.expected.yaml b/tests/fixtures/sample/policy.expected.yaml index 3575288..4306257 100644 --- a/tests/fixtures/sample/policy.expected.yaml +++ b/tests/fixtures/sample/policy.expected.yaml @@ -1,5 +1,5 @@ # Generated by openshell-annotate @VERSION@ - DO NOT EDIT. Change the @openshell directives in source and regenerate. -# Validated against openshell-policy-schema and the OpenShell v0.1.7 gateway validator. Each entry's comment gives the reason and source file:line. +# Validated against openshell-policy-schema and the OpenShell v0.1.8 gateway validator. Each entry's comment gives the reason and source file:line. # Startup-only sections (filesystem_policy, landlock, process) need a sandbox recreate to change; network_policies are live. version: 1 filesystem_policy: diff --git a/tests/gateway_policies.rs b/tests/gateway_policies.rs index 6a0ef53..ab76d94 100644 --- a/tests/gateway_policies.rs +++ b/tests/gateway_policies.rs @@ -56,3 +56,21 @@ fn example_and_golden_policies_pass_the_gateway_validator() { failed.join("\n") ); } + +/// OpenShell v0.1.8 (NVIDIA/OpenShell#5336): `websocket_credential_rewrite: true` needs `protocol: websocket`. +/// `lint --policy`, `drift` and `generate` run the gateway validator, so they report it with the upstream hint. +#[test] +fn websocket_credential_rewrite_needs_the_websocket_protocol() { + let policy = |protocol: &str| { + format!( + "version: 1\nnetwork_policies:\n gw:\n binaries:\n - path: /usr/bin/node\n endpoints:\n - host: gateway.example.com\n port: 443\n protocol: {protocol}\n access: full\n websocket_credential_rewrite: true\n" + ) + }; + let rest = openshell_annotate::validate::gateway_violations(&policy("rest")).unwrap(); + assert!( + rest.iter().any(|v| v.contains("use protocol: websocket")), + "{rest:?}" + ); + let ws = openshell_annotate::validate::gateway_violations(&policy("websocket")).unwrap(); + assert!(ws.is_empty(), "{ws:?}"); +} diff --git a/tests/golden/diff_logs_human_color.txt b/tests/golden/diff_logs_human_color.txt index 59c5b9d..7778dfb 100644 --- a/tests/golden/diff_logs_human_color.txt +++ b/tests/golden/diff_logs_human_color.txt @@ -59,5 +59,5 @@ ✖ 4 suggestions (1 stale directive · 1 not actionable) 💡 next: `openshell-annotate diff-logs denied.log --write` inserts 3 directives (review, then regenerate the policy) -note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.7 (#4270). +note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.8 (#4270).  \ No newline at end of file diff --git a/tests/golden/diff_logs_human_plain.txt b/tests/golden/diff_logs_human_plain.txt index bc2ec05..ddfc288 100644 --- a/tests/golden/diff_logs_human_plain.txt +++ b/tests/golden/diff_logs_human_plain.txt @@ -59,4 +59,4 @@ blocked: 169.254.169.254:80 x1 4 suggestions (1 stale directive, 1 not actionable) next: `openshell-annotate diff-logs denied.log --write` inserts 3 directives (review, then regenerate the policy) -note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.7 (#4270). +note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.8 (#4270). diff --git a/tests/golden/diff_logs_ocsf_1_8_0_plain.txt b/tests/golden/diff_logs_ocsf_1_8_0_plain.txt index a761077..2489c23 100644 --- a/tests/golden/diff_logs_ocsf_1_8_0_plain.txt +++ b/tests/golden/diff_logs_ocsf_1_8_0_plain.txt @@ -39,4 +39,4 @@ stale: jsonplaceholder.typicode.com:443 /usr/local/bin/python3.12 3 suggestions (1 stale directive) next: `openshell-annotate diff-logs ocsf.jsonl --write` inserts 3 directives (review, then regenerate the policy) -note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.7 (#4270). +note: logs are best-effort and lossy; absence of an event is not proof. Filesystem denials are not logged by OpenShell 0.1.8 (#4270).