Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,13 @@ jobs:
run: |
buf generate
git diff --exit-code -- gen/
# The smoke test pins an OpenShell release; the vendored contract must be
# the one that release ships, or the smoke test proves nothing about it.
- name: Vendored extension protos match the pinned OpenShell release
run: |
source examples/openshell-smoke/openshell-release.env
for f in extension gateway_interceptor supervisor_middleware; do
curl -fsSL "https://raw.githubusercontent.com/NVIDIA/OpenShell/$OPENSHELL_COMMIT/proto/$f.proto" \
| diff -u "third_party/openshell/proto/$f.proto" - \
|| { echo "third_party/openshell/proto/$f.proto differs from OpenShell $OPENSHELL_VERSION ($OPENSHELL_COMMIT)"; exit 1; }
done
60 changes: 60 additions & 0 deletions .github/workflows/openshell-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Runs the extension against the pinned OpenShell release with a real gateway,
# supervisor and sandbox on the Docker driver. Slower than the unit suite and
# dependent on GitHub's Docker daemon and ghcr.io, so it runs on pushes to main,
# on pull requests that touch what it exercises, and on demand.
name: OpenShell smoke

on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- "cmd/ans-openshell-middleware/**"
- "cmd/ans-reference-callee/**"
- "internal/**"
- "gen/**"
- "third_party/openshell/**"
- "examples/openshell-smoke/**"
- "go.mod"
- "go.sum"
- "Makefile"
- ".github/workflows/openshell-smoke.yml"
workflow_dispatch:

permissions:
contents: read

jobs:
smoke:
name: Gateway, supervisor and sandbox on Docker
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e #v7.0.0
with:
go-version: "1.26.9"
- name: Cache OpenShell release assets
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 #v4.3.0
with:
path: ~/.cache/ans-openshell-smoke
key: openshell-${{ hashFiles('examples/openshell-smoke/openshell-release.env') }}-${{ runner.os }}-${{ runner.arch }}
- name: Run the smoke test
# A fixed TMPDIR makes the retained log directory addressable by the
# upload step below; the gateway runs at debug so a middleware_failed
# verdict on CI explains itself.
env:
TMPDIR: ${{ runner.temp }}/smoke
ANS_SMOKE_LOG_LEVEL: debug
run: |
mkdir -p "$TMPDIR"
make openshell-smoke
- name: Upload retained logs
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 #v7.0.2
with:
name: openshell-smoke-logs
path: ${{ runner.temp }}/smoke/ans-openshell-smoke.*/logs/
if-no-files-found: ignore
retention-days: 7
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/ans-ocsf-hydrator
/ans-reference-callee
/demo
/fixtures

# Test binaries, built with `go test -c`
*.test
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LINT_GOTOOLCHAIN ?= local
BIN := bin
CMDS := ans-openshell-middleware ans-openshell-interceptor ans-ocsf-hydrator ans-reference-callee

.PHONY: all build proto test cover lint vet demo clean
.PHONY: all build proto test cover lint vet demo openshell-smoke clean

all: build

Expand Down Expand Up @@ -44,3 +44,7 @@ demo:

clean:
rm -rf $(BIN) coverage*.out

# End-to-end check against a real OpenShell gateway (Docker). See examples/openshell-smoke/README.md.
openshell-smoke:
examples/openshell-smoke/smoke.sh
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ Run the tests:
make cover
```

Run the extension against a real OpenShell gateway, supervisor and sandbox on Docker. It
downloads the pinned OpenShell release, mints disposable identity and trust material, and
asserts that an authorized sandbox's plain request arrives signed, forged identity headers are
replaced, an unapproved sandbox is denied, and a request is blocked while the middleware is
down. See [examples/openshell-smoke](examples/openshell-smoke/README.md):

```bash
make openshell-smoke
```

## Running the services

Every service takes one YAML file. Flags: `--config` (required), `--listen` to override the
Expand Down
133 changes: 133 additions & 0 deletions examples/openshell-smoke/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# OpenShell smoke test

Runs `ans-openshell-middleware` and `ans-reference-callee` against a real OpenShell gateway,
supervisor and sandbox, and asserts the identity guarantees the middleware makes. The in-process
demo (`make demo`) plays the supervisor itself; this test shows what only a real runtime can:
that OpenShell invokes the service, applies its header mutations before the request leaves,
and blocks the request when the service is down.

> OpenShell's supervisor-middleware contract is a research preview upstream and may change.
> The test pins one release; see [Updating the OpenShell pin](#updating-the-openshell-pin).

## What it does

```bash
make openshell-smoke
```

1. Builds the middleware, the callee and the fixture generator from this checkout, and a
workload image ([workload/Dockerfile](workload/Dockerfile)): OpenShell's default workload
image plus `curl`, the one binary the policy lets reach the callee.
2. Downloads the pinned OpenShell CLI and gateway release assets, verifies their SHA-256
against [openshell-release.env](openshell-release.env), and caches them under
`~/.cache/ans-openshell-smoke`.
3. Mints everything a deployment normally receives from elsewhere into a temporary directory:
a fixture transparency-log root key; one registered identity with its key, certificate,
receipt and status token; the gateway's Ed25519 JWT signing key with the matching JWKS;
and a private CA with a serving certificate for the middleware's gRPC listener. The
repository holds no key material and the production transparency log is never contacted.
4. Starts the callee, the middleware (TLS, gateway JWTs verified) and an OpenShell gateway on
the Docker driver with the middleware registered under
`binding_policy = "allowlist"` and `bindings = ["http_request_pre_credentials"]`.
5. Creates a sandbox with [policy.template.yaml](policy.template.yaml), reads its
gateway-issued id, approves exactly that id for the identity in the middleware's
`sandbox_identities`, and restarts the middleware.
6. Runs the assertions below and tears everything down. On failure the logs are kept, including
each sandbox's supervisor container log, and the minted keys are not.

| Check | Expected observation |
|-------|----------------------|
| Authorized sandbox | A plain `POST /v1/tasks` from the workload reaches the callee signed; the callee returns the operator-assigned ANS name and agent id. |
| Forged identity headers | `DPoP`, `X-SCITT-Receipt` and `X-ANS-Status-Token` set by the workload are overwritten; the callee still verifies the assigned identity. |
| Unsigned direct request | A request to the callee that bypasses OpenShell is rejected with `401`, and the callee logs the rejection. This arms the sentinel the next two checks use. |
| Unapproved sandbox | A second sandbox whose id is not in `sandbox_identities` gets `403 middleware_denied` with reason `ans_identity_unauthorized`; the callee's log does not grow, so it never saw the request. |
| Middleware unavailable | With the middleware stopped, the request gets `403 middleware_failed` (`on_error: fail_closed`); the callee's log does not grow. |

Replay and body tampering are covered by the verifier's own tests and by `make demo`, and are
reported there, not here.

## Requirements

- Linux (x86_64 or arm64) or macOS on Apple silicon, with Bash, `curl`, `jq`, `tar`,
`sha256sum` or `shasum`, and Go.
- A Docker daemon reachable over the Unix socket named by the current `docker context`, with
host networking for the supervisor container (the OpenShell Docker driver's default), and
access to `ghcr.io` and `nvcr.io` for the pinned supervisor and sandbox runtime images and
the workload base image.
- A non-loopback IPv4 address on this machine that containers can reach. It is detected
automatically; set `ANS_SMOKE_HOST` to override. For the duration of the run the gateway
(mTLS), the middleware (TLS, gateway JWTs) and the callee (DPoP-verified) listen on all
interfaces so the supervisor, which runs in the daemon's network namespace, can reach them.

The test never touches an existing OpenShell installation: it points `XDG_CONFIG_HOME`,
`XDG_STATE_HOME` and `OPENSHELL_LOCAL_TLS_DIR` at its temporary directory, so the gateway's
database, TLS bundle and the CLI's gateway registration all live and die with the run. On the
Docker daemon its gateway works under its own `sandbox_label`, `ans-openshell-smoke`, so the
startup reconciliation that removes a gateway's stray supervisor containers cannot reach another
gateway's sandboxes, and leftovers from a crashed run are reclaimed by the next one.

## Options

| Flag or variable | Effect |
|------------------|--------|
| `--keep-running` | After the assertions pass, keep the gateway, middleware, callee and sandbox up until Ctrl-C and print the commands to use them. |
| `--print-config` | Print the rendered `gateway.toml` and `middleware.yaml` and exit. |
| `ANS_SMOKE_HOST` | Address the gateway and sandboxes use to reach the middleware and callee. |
| `ANS_SMOKE_CACHE` | Where release assets are cached. |
| `ANS_SMOKE_LOG_LEVEL` | Gateway log level, default `info`. |

## Fixture trust versus production trust

The fixture transparency log is one ES256 key minted per run. Its root key is handed to the
middleware (`transparency_log.root_keys_file`) and to the callee (`--root-keys-file`), and the
identity's receipt and status token are pinned with `receipt_file` and `status_token_file`, so
the middleware verifies them against that key at startup and never fetches anything. In
production the middleware is given the real log's base URL and published root keys, fetches
and refreshes the artifacts itself, and the callee pins the same published keys. Nothing else
differs: the proof, the headers, the verifier and the sandbox authorization path are the
production code.

The gateway's own TLS bundle and the CLI's client certificate come from OpenShell's
`openshell-gateway generate-certs`; only the JWT signing key is replaced with the one the
fixtures minted so the middleware's JWKS matches.

## What is pinned, and how

| Artifact | Pin | Verified by |
|----------|-----|-------------|
| OpenShell CLI and gateway tarballs | SHA-256 per asset in [openshell-release.env](openshell-release.env) | `smoke.sh`, every run, before extraction into the run directory |
| Vendored extension protos | `OPENSHELL_COMMIT` in the same file | CI's proto-drift job diffs them against that commit |
| Supervisor and sandbox runtime images | manifest-list digests in the same file, passed to the gateway as `supervisor_image` and `sandbox_runtime_image` | the container engine, by digest |
| Workload base image | manifest-list digest in [workload/Dockerfile](workload/Dockerfile) | the container engine, by digest |

The `apt-get install curl` layer in the workload image is the one unpinned input; the identity
assertions do not rest on it, because the callee's own log corroborates the two denial checks and
its rejection logging is proven live first.

## Limitations

- `sandbox_identities` is read when the middleware starts. Approving a sandbox means editing the
map and restarting the service, and until the supervisor's channel to it reconnects (a few
seconds) matching requests fail closed with `middleware_failed`. The harness does exactly this
and retries the first request through that window; a production operator would see the same
window on every approval.
- The fixture status token lives one hour. A `--keep-running` stack stops signing when it lapses.
- Only Linux and macOS on Apple silicon are supported; the pinned release has no Intel macOS
gateway build.

## Ownership

The harness, its OpenShell pin and the `OpenShell smoke` workflow are maintained by this
repository's maintainers under its normal [contribution process](../../CONTRIBUTING.md); a
maintainer roster is proposed in the governance change under review. File problems as issues
on this repository. The link from OpenShell's supervisor-middleware documentation belongs to
the upstream contribution and is not part of this repository.

## Updating the OpenShell pin

1. Edit [openshell-release.env](openshell-release.env): the version, the tag's commit, and the
SHA-256 of each asset from the release's `openshell-checksums-sha256.txt` and
`openshell-gateway-checksums-sha256.txt`.
2. Re-pin the vendored contract (`third_party/openshell`, then `make proto`) if the proto-drift
job reports a difference at the new commit.
3. Run `make openshell-smoke`.
Loading
Loading