Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/audit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 and v0.1.8 openshell-crypto -> sqlx 0.9.0 -> sqlx-sqlite =0.9.0
# Transitive and not upgradable from this repo: OpenShell v0.1.7 to v0.1.9 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",
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.8` tag (see `Cargo.toml`, `Cargo.lock` pins the commit). Update the tag deliberately and re-run
OpenShell `v0.1.9` 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").
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ version section and adds the squash-merged PR titles since the previous tag. Ver

## [Unreleased]

- chore(deps): build against OpenShell v0.1.9 (`openshell-policy-schema`, `openshell-policy`, commit ce58cf8); docs, generated policy headers and the `diff-logs`/`--image` notes now name v0.1.9 (#107)
- feat(lint): warn when a wildcard host in an `egress` directive or a `--policy` endpoint without `allowed_ips` can match a private IP literal (`10.*.*.*`, `**.*.*`): since OpenShell v0.1.9 a wildcard endpoint no longer allows private IP literals on its own (#107)
- test: the gateway validator rejects middleware selectors with a port (OpenShell v0.1.9); `diff-logs` skips gateway API Activity denials in both the old (`type_uid` 600399) and the new Create/Update/Delete shape (#107)
- chore(deps): update `url` to 2.5.9 (and `form_urlencoded` to 1.2.3) in `Cargo.lock` for RUSTSEC-2026-0592, a stack overflow in `Url::origin()` on nested `blob:` URLs; `url` comes in through OpenShell's crates (#111)
- chore(deps): OpenShell moved to `ai-openshell/openshell`: the git dependencies, `Cargo.lock` sources (same v0.1.8 commit), `deny.toml` `allow-git`, the pin/tag/compat/openshell-next scripts and workflows, and upstream links in the docs use the new URL instead of the `NVIDIA/OpenShell` redirect (#105)
- ci: the `Security` checks `actionlint`, `gitleaks`, `cargo-deny` and `openshell-pin` are required status checks on `main`, next to `check` and `audit` (`protect-main` ruleset, #103)
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ repository = "https://github.com/ilanh/openshell-annotate"
authors = ["Ilan Harel"]

[dependencies]
# Pinned to the OpenShell v0.1.8 tag; Cargo.lock records the exact commit.
openshell-policy-schema = { git = "https://github.com/ai-openshell/openshell", tag = "v0.1.8" }
# Pinned to the OpenShell v0.1.9 tag; Cargo.lock records the exact commit.
openshell-policy-schema = { git = "https://github.com/ai-openshell/openshell", tag = "v0.1.9" }
# Same tag. Schema parsing accepts policies the gateway later rejects; this crate is that validator.
openshell-policy = { git = "https://github.com/ai-openshell/openshell", tag = "v0.1.8" }
openshell-policy = { git = "https://github.com/ai-openshell/openshell", tag = "v0.1.9" }
anyhow = "1"
clap = { version = "4", features = ["derive"] }
ignore = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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/ai-openshell/openshell (tag v0.1.8, commit pinned
# `openshell-policy-schema` is a git dependency on https://github.com/ai-openshell/openshell (tag v0.1.9, 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
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.8).
Early pre-release **v0.1.0-rc.3** (targets OpenShell policy schema v1, `openshell-policy-schema` @ v0.1.9).
Licensed under Apache-2.0.

## Try it in two minutes
Expand Down Expand Up @@ -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.8 only lets the sandbox read `/usr /lib /etc /app /var/log /proc /dev/urandom` (plus the workspace when
OpenShell 0.1.9 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
([ai-openshell/openshell#4270](https://github.com/ai-openshell/openshell/issues/4270)), so an application under `/opt/<app>` fails with a bare
`EACCES`. `generate --image IMAGE` inspects the image (docker, then podman: WORKDIR, ENTRYPOINT, CMD, and the directory
Expand Down Expand Up @@ -355,8 +355,14 @@ the rule; a profile bound to other binaries (the bundled `github` profile is for
(it is evaluated as IPv4, ai-openshell/openshell#5101). A WebSocket client with a computed URL or behind an SDK is not seen.
Filesystem policy paths that go through a symlink inside a writable directory now fail sandbox launch
(ai-openshell/openshell#5278); the symlink lives in the image, so lint cannot see it: put the symlink's target in `@openshell fs`.
- OpenShell v0.1.9 changes: a wildcard endpoint no longer allows a private IP literal (RFC 1918, CGNAT, TEST-NET and
similar) on its own (ai-openshell/openshell#5522), so lint warns when a wildcard host in a directive or a `--policy` file
can match one (`10.*.*.*`, `**.*.*`); declare each private address as its own endpoint, or give the policy endpoint
`allowed_ips`. Middleware selectors (`network_middlewares.*.endpoints`) can no longer include a port
(ai-openshell/openshell#4359); annotate does not generate middlewares, but `lint --policy`, `drift` and `generate` run
the gateway validator on committed policies and report it.
- Filesystem/process/landlock are startup-only in OpenShell; drift labels them `startup`.
- `diff-logs` only sees network and L7 events: OpenShell 0.1.8 does not log Landlock/filesystem denials (upstream #4270), log
- `diff-logs` only sees network and L7 events: OpenShell 0.1.9 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
Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.8, 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.9, 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.
Expand Down
16 changes: 10 additions & 6 deletions docs/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.8` 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.9` 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.8, a running OpenShell gateway, and Docker (see section 7) |
| sandbox flow (optional) | the `openshell` CLI and `openshell-prover` at 0.1.9, a running OpenShell gateway, and Docker (see section 7) |

```
rustup toolchain install 1.94 --profile minimal --component rustfmt,clippy
Expand Down Expand Up @@ -122,7 +122,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.9-pre.3` while `main` is on `v0.1.8`), plus any fix that only
upstream tag, prereleases included (for example `v0.1.10-pre.3` while `main` is on `v0.1.9`), 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.
Expand Down Expand Up @@ -227,11 +227,15 @@ 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.8, so
Sample logs for both formats are in `tests/fixtures/logs/`. Filesystem denials are not logged by OpenShell 0.1.9, 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.*` (ai-openshell/openshell#5048) needs no change; the OCSF fixture
is real v0.1.7 output.

`diff-logs` reads only network (4001) and HTTP (4002) activity. Gateway API Activity records (class 6003) are
skipped, so OpenShell v0.1.9 reporting write-method authorization denials as Create/Update/Delete instead of Other
(`type_uid` 600399, ai-openshell/openshell#5606) needs no change; a unit test covers both shapes.

## 6. Docker image

```
Expand All @@ -255,7 +259,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.8 on PATH and a connected gateway (`openshell status` shows `Connected`), and
It needs `openshell` and `openshell-prover` 0.1.9 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`),
Expand Down Expand Up @@ -301,4 +305,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 <name>` 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.8 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.9 tools; the static commands (`scan`, `generate`, `lint`, `drift`, `diff-logs`) do not need them |
2 changes: 1 addition & 1 deletion examples/polyglot/openshell/policy.yaml
Original file line number Diff line number Diff line change
@@ -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.8 gateway validator. Each entry's comment gives the reason and source file:line.
# Validated against openshell-policy-schema and the OpenShell v0.1.9 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:
Expand Down
19 changes: 17 additions & 2 deletions src/diff_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.8 (upstream #4270), so only network and L7 HTTP events are handled.
//! OpenShell 0.1.9 (upstream #4270), so only network and L7 HTTP events are handled.

use crate::config::Config;
use crate::directive::{Directive, Kind};
Expand Down Expand Up @@ -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.8 (#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.9 (#4270).\n");
for g in &rep.suggestions {
let up = g.kind.to_ascii_uppercase();
s.push_str(&format!(
Expand Down Expand Up @@ -988,6 +988,21 @@ garbage line\n";
);
}

#[test]
fn skips_gateway_api_activity_denials_old_and_new() {
// Gateway authorization denials are OCSF API Activity (class 6003) records, not sandbox egress. OpenShell
// v0.1.9 (ai-openshell/openshell#5606) reports write denials as Create/Update/Delete (type_uid 600301..3)
// instead of Other (600399); diff-logs never selects on type_uid, so both shapes are skipped.
let t = concat!(
"{\"class_uid\":6003,\"activity_id\":99,\"type_uid\":600399,\"status_id\":2,\"action\":\"Denied\",\"dst_endpoint\":{\"domain\":\"gw\",\"port\":8080}}\n",
"{\"class_uid\":6003,\"activity_id\":3,\"type_uid\":600303,\"status_id\":2,\"action\":\"Denied\",\"dst_endpoint\":{\"domain\":\"gw\",\"port\":8080}}\n",
"{\"class_uid\":4001,\"action_id\":2,\"dst_endpoint\":{\"domain\":\"pypi.org\",\"port\":443}}\n",
);
let e = parse_logs(t, "x");
assert_eq!(e.len(), 1);
assert_eq!(e[0].host, "pypi.org");
}

#[test]
fn sandbox_attribution_location_does_not_matter() {
// OpenShell v0.1.8 (ai-openshell/openshell#5048) moved supervisor sandbox attribution from top-level `container.*`
Expand Down
2 changes: 1 addition & 1 deletion src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.8 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.9 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() {
Expand Down
Loading
Loading