Skip to content

ci(rust): run unit tests network-off in a loopback-only namespace - #1

Closed
John-David Dalton (jdalton) wants to merge 2 commits into
mainfrom
ci/network-off-tests
Closed

John-David Dalton (jdalton) wants to merge 2 commits into
mainfrom
ci/network-off-tests

Conversation

@jdalton

@jdalton John-David Dalton (jdalton) commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

Spike for #68 — give cargo tests the same network-off guarantee JS/TS has via nock. The test run is wrapped in a net namespace with only loopback up, so real outbound calls fail while localhost fixtures still work; deps are pre-fetched online first, and a curl self-check proves egress is blocked before trusting the sandbox (fail-closed if no namespace can be created).

Validating the unshare/AppArmor mechanism on depot-ubuntu-24.04 here before promoting it to a shared wheelhouse action + cascading to decmpfs/abitious. envrypt's dep budget already forbids network, so its tests should pass offline — a failure means the sandbox caught a real leak.


Note

Medium Risk
CI behavior changes for all Rust tests (sandbox or job failure), but scope is limited to the test job and fail-closed verification reduces risk of silently running tests online.

Overview
Rust CI no longer runs cargo test with full network access. The workflow builds a run-offline.sh wrapper that uses unshare --net with loopback only, relaxes Ubuntu 24.04 AppArmor user-namespace restrictions when needed, and fails the job if namespaces are unavailable or if a curl probe to example.com succeeds inside the sandbox. Dependencies are fetched online with cargo fetch --locked first; workspace tests and envrypt doctests then run with --offline inside that sandbox—mirroring the JS/TS no-live-network test policy (#68).

Repo hygiene: tracked .codex/config.toml and .codex/hooks.json are removed from the tree, and /.codex/ is added to .gitignore so Codex MCP/hook projections stay generated locally like other cross-harness adapter dirs.

Reviewed by Cursor Bugbot for commit 7c232e9. Configure here.

The .codex/ dir (codex harness config) is generated from .claude/ (the source of truth) as part of the release/setup shakeout — like .cursor/, .windsurf/, .janus/ — never committed. Ignore it via the fleet-canonical block and untrack the config.toml + hooks.json that leaked into the cascade.
Compiled-language equivalent of the JS/TS nock.disableNetConnect() gate: wrap
the cargo test run in a net namespace with only loopback up, so real outbound
calls fail while localhost fixtures still work. Deps pre-fetched online; sandbox
wraps only the test run. Fail-closed — errors if no namespace can be created,
with a curl self-check proving egress is blocked before trusting it.

Spike for #68 (network-off tests across fleet langs); validates the mechanism on
depot-ubuntu-24.04 before promoting it to a shared wheelhouse action.
@jdalton

Copy link
Copy Markdown
Collaborator Author

Superseded — the netns network-off change landed on main directly (fleet cadence, no PRs), rebased clean off current main without the stale .codex/ churn. Also fixed the red Windows conformance job on main (command-substitution cases are POSIX-shell-specific; gated off Windows).

@jdalton
John-David Dalton (jdalton) deleted the ci/network-off-tests branch July 22, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant