Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e18997d
Add CLAUDE.local.md to .gitignore
ammario Sep 4, 2025
3920643
ci: enable for all branches
ammario Sep 4, 2025
b2e1153
ci: improve debugging
ammario Sep 4, 2025
4670ca5
more debugging
ammario Sep 4, 2025
be0bc62
resolve more issues
ammario Sep 4, 2025
1109aaf
cleanup curl
ammario Sep 4, 2025
ccd2827
Update nextest config
ammario Sep 4, 2025
ed32ecd
Add CI debugging improvements and increase test timeouts
ammario Sep 4, 2025
7fc9d8a
Fix macOS PF rules loading and replace unreliable httpbin.org
ammario Sep 4, 2025
f1cb8b6
Fix PF rules loading issues and clippy warnings
ammario Sep 4, 2025
5592b13
ci: add verbose logging to failing tests for debugging
ammario Sep 4, 2025
4fb2fae
ci: clean up debug output while keeping verbose flags
ammario Sep 4, 2025
4a70d50
refactor: separate lifecycle management from jail implementations
ammario Sep 5, 2025
57b2a69
fix: remove super:: prefix for LINUX_NS_SUBNET references
ammario Sep 5, 2025
8db4591
CI fixes
ammario Sep 5, 2025
8f4ee2e
Remove unnecessary retry logic
ammario Sep 5, 2025
32dff02
DRY cleanup logic
ammario Sep 5, 2025
44a8fde
Use system resource abstraction for better cleanup handling
ammario Sep 5, 2025
feaeac6
Add ManagedResource abstraction
ammario Sep 5, 2025
48394c7
resolve clippy?
ammario Sep 5, 2025
db9caab
ManagedResource refactor
ammario Sep 5, 2025
8648103
Fix linux subnet clashing
ammario Sep 8, 2025
04ab870
Cleanup macOS impl
ammario Sep 8, 2025
cc639b1
cargo fmt
ammario Sep 8, 2025
b399978
add codex config
ammario Sep 8, 2025
830c759
Rm macOS strong jail
ammario Sep 8, 2025
d198e08
Convert Linux strong jail to nftables
ammario Sep 8, 2025
78b60f8
make concurrent isolation test more robust
ammario Sep 8, 2025
77068eb
Fix nftables rule blocking jail traffic
ammario Sep 8, 2025
dc7193b
Add root/sudo matrix to Linux integration tests
ammario Sep 8, 2025
e46d4df
Fix Linux test matrix in CI
ammario Sep 8, 2025
04e232d
Fix cargo path for root variant in CI
ammario Sep 8, 2025
27d9f37
Fix DNS resolution in CI environments
ammario Sep 8, 2025
763ad77
Add explicit nftables input rules for proxy ports
ammario Sep 8, 2025
cdc8cf2
Fix DNS resolution by creating config before namespace
ammario Sep 8, 2025
208602c
Add more debug logging for DNS setup
ammario Sep 8, 2025
562149f
Add DNS resolution test to isolate CI issue
ammario Sep 8, 2025
379d4d4
Fix nftables INPUT priority for CI compatibility
ammario Sep 8, 2025
998b5c7
Fix nftables forward chain priority for CI compatibility
ammario Sep 8, 2025
7d4c1ec
Use very early nftables priority (-100) and add explicit output chain
ammario Sep 8, 2025
79bc6eb
Add prerouting chain and comprehensive accept rules
ammario Sep 8, 2025
6a03074
Switch from link-local to RFC1918 addresses for jail networking
ammario Sep 8, 2025
af1a189
Add network diagnostic test to understand CI failures
ammario Sep 8, 2025
8d19cbc
Fix clippy warning in diagnostic test
ammario Sep 8, 2025
9549c66
Run diagnostic test separately first in CI
ammario Sep 8, 2025
4983474
Fix CI tests by improving proxy discovery in network namespaces
ammario Sep 9, 2025
ed1d939
Improve network diagnostics and fix host IP detection in tests
ammario Sep 9, 2025
1d3778b
Fix shell syntax error in diagnostic test
ammario Sep 9, 2025
b207fb6
Simplify diagnostic test and use raw string literal
ammario Sep 9, 2025
2fe5f2c
Fix root cause: default route not being added in CI environments
ammario Sep 9, 2025
3fb5246
Fix remaining CI issues: veth link status and sed syntax
ammario Sep 9, 2025
adb8419
Simplify host IP detection in tests
ammario Sep 9, 2025
91d015c
Simplify all tests to use direct curl commands
ammario Sep 9, 2025
10290c3
Add CI timeout workarounds for network jail tests
ammario Sep 9, 2025
018714e
Clean up debug code from CI investigation
ammario Sep 9, 2025
f7b091a
Fix timeout argument in tests
ammario Sep 9, 2025
45429a0
Remove duplicate timeout arguments from tests
ammario Sep 9, 2025
a9124ea
Add CI workarounds for DNS/HTTPS timeout tests
ammario Sep 9, 2025
257e0d6
Fix clippy warning about collapsible if statements
ammario Sep 9, 2025
6d621ec
Fix DNS resolution in namespaces for CI
ammario Sep 9, 2025
128640e
Improve DNS fix with better error handling and multiple fallback appr…
ammario Sep 9, 2025
ef97ed8
Re-add CI workarounds for DNS-dependent tests
ammario Sep 9, 2025
c3cdceb
Add comprehensive DNS namespace debugging script
ammario Sep 9, 2025
1ab0e06
Document root cause of CI network namespace failures
ammario Sep 9, 2025
82509cd
Switch Linux CI to self-hosted runner
ammario Sep 9, 2025
89dc16c
Fix self-hosted runner cargo path issue
ammario Sep 9, 2025
5b93f72
Trigger CI after installing nftables on self-hosted runner
ammario Sep 9, 2025
a271225
Retry CI after fixing permissions
ammario Sep 9, 2025
c644f55
Use numeric nftables priorities for compatibility
ammario Sep 9, 2025
d9d0350
Fix permission issues on self-hosted runner
ammario Sep 9, 2025
e8fa6fc
Move permission fix to be first step
ammario Sep 9, 2025
0703792
Use generic workspace path instead of hardcoded home directory
ammario Sep 9, 2025
847957b
Fix clippy collapsible-if warning
ammario Sep 9, 2025
257bfef
Remove redundant permission fix after tests
ammario Sep 9, 2025
e5e668d
Remove obsolete CI network limitations doc
ammario Sep 9, 2025
6563f4f
Remove unnecessary route add fallback code
ammario Sep 9, 2025
763db18
improve cleanup robustness
ammario Sep 10, 2025
77b1b8c
readme update
ammario Sep 10, 2025
560d090
Fix test isolation
ammario Sep 10, 2025
b517cb3
Cargo.toml
ammario Sep 10, 2025
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
3 changes: 3 additions & 0 deletions .codex/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# See https://github.com/openai/codex/blob/main/docs/config.md
[tools]
web_search = true
26 changes: 26 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Nextest configuration file
# https://nexte.st/book/configuration

[profile.default]
# Stop test run after 5 failures
fail-fast = { max-fail = 5 }

# Test output settings
success-output = "never"
status-level = "pass"

# Retry settings
retries = { backoff = "fixed", count = 0 }

# Timeout settings
slow-timeout = { period = "60s", terminate-after = 2 }

[profile.ci]
# CI-specific configuration (inherits from default)
# More verbose output for debugging CI failures
failure-output = "final"
success-output = "never"
status-level = "retry"

# Allow more retries in CI for flaky tests
retries = { backoff = "exponential", count = 2, delay = "1s", max-delay = "10s" }
109 changes: 66 additions & 43 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: [main]
branches:
- main
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
Expand All @@ -26,72 +26,89 @@ jobs:
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2

- name: Install nextest
uses: taiki-e/install-action@nextest

- name: Build
run: cargo build --verbose

- name: Run unit tests
run: cargo test --bins --verbose
run: cargo nextest run --profile ci --bins --verbose

- name: Run smoke tests
run: cargo test --test smoke_test --verbose
run: cargo nextest run --profile ci --test smoke_test --verbose

- name: Run macOS integration tests (with sudo)
- name: Run weak mode integration tests
run: |
# The tests require root privileges for PF rules on macOS
# GitHub Actions provides passwordless sudo on macOS runners
# Use -E to preserve environment and full path to cargo
sudo -E $(which cargo) test --test macos_integration --verbose
# On macOS, we only support weak mode due to PF limitations
# (PF translation rules cannot match on user/group)
cargo nextest run --profile ci --test weak_integration --verbose

test-linux:
name: Linux Tests
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable]
runs-on: [self-hosted, linux]

steps:
- uses: actions/checkout@v4
- name: Fix permissions from previous runs
run: |
# Clean up any files left from previous sudo runs before checkout
# Use GITHUB_WORKSPACE parent directory or current working directory
WORK_DIR="${GITHUB_WORKSPACE:-$(pwd)}"
if [ -d "$WORK_DIR" ]; then
sudo chown -R $(whoami):$(whoami) "$WORK_DIR" || true
fi

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: actions/checkout@v4

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Fix permissions on current directory
run: |
# Clean up any files left from previous sudo runs
if [ -d target ]; then
sudo chown -R $(whoami):$(whoami) target || true
fi
if [ -d ~/.cargo/registry ]; then
sudo chown -R $(whoami):$(whoami) ~/.cargo/registry || true
fi

- name: Install nextest
run: |
source ~/.cargo/env
if ! command -v cargo-nextest &> /dev/null; then
cargo install cargo-nextest --locked
fi

- name: Build
run: cargo build --verbose
run: |
source ~/.cargo/env
cargo build --verbose

- name: Run unit tests
run: cargo test --bins --verbose
run: |
source ~/.cargo/env
cargo nextest run --profile ci --bins --verbose

- name: Run smoke tests
run: cargo test --test smoke_test --verbose

- name: Run jail integration tests
run: cargo test --test jail_integration --verbose
run: |
source ~/.cargo/env
cargo nextest run --profile ci --test smoke_test --verbose

- name: Debug TLS environment
- name: Run Linux jail integration tests
run: |
echo "=== Debugging TLS/Certificate Environment ==="
chmod +x scripts/debug_tls_env.sh
./scripts/debug_tls_env.sh
sudo ./scripts/debug_tls_env.sh
echo "=== End TLS Debug ==="
source ~/.cargo/env
# Run all tests without CI workarounds since this is a self-hosted runner
sudo -E $(which cargo) nextest run --profile ci --test linux_integration --verbose

- name: Run Linux jail integration tests (with sudo)
- name: Run isolated cleanup tests
run: |
# Ensure ip netns support is available
sudo ip netns list || true
# Run the Linux-specific jail tests with root privileges
# Use full path to cargo since sudo doesn't preserve PATH
sudo -E $(which cargo) test --test linux_integration --verbose
source ~/.cargo/env
# Run only the comprehensive cleanup and sigint tests with the feature flag
# These tests need to run in isolation from other tests
sudo -E $(which cargo) test --test linux_integration --features isolated-cleanup-tests -- test_comprehensive_resource_cleanup test_cleanup_after_sigint

test-weak:
name: Weak Mode Integration Tests (Linux)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

Expand All @@ -103,15 +120,21 @@ jobs:
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2

- name: Install nextest
uses: taiki-e/install-action@nextest

- name: Build
run: cargo build --verbose

- name: Run weak mode integration tests
run: cargo test --test weak_integration --verbose
run: cargo nextest run --profile ci --test weak_integration --verbose

clippy:
name: Clippy
runs-on: ubuntu-latest
name: Clippy (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v4
Expand All @@ -126,7 +149,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Run clippy
run: cargo clippy -- -D warnings
run: cargo clippy --all-targets -- -D warnings

fmt:
name: Format
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
target/

# Local Claude Code instructions (not committed to repo)
CLAUDE.local.md
1 change: 1 addition & 0 deletions AGENTS.md
11 changes: 11 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@ User-facing documentation should be in the README.md file.
Code/testing/contributing documentation should be in the CONTRIBUTING.md file.

When updating any user-facing interface of the tool in a way that breaks compatibility or adds a new feature, update the README.md file.

## Clippy

CI requires the following to pass on both macOS and Linux targets:

```
cargo clippy --all-targets -- -D warnings
```

When the user asks to run clippy and provides the ability to run on both targets, try to run it
on both targets.
17 changes: 8 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ Run the standard unit tests:
cargo test
```

### Integration Tests (macOS)
### Integration Tests

The integration tests require sudo access to set up PF rules and groups:
#### macOS

```bash
# Run all integration tests (requires sudo)
sudo -E cargo test -- --ignored
On macOS, httpjail runs in weak mode (environment variable-based):

# Run a specific integration test suite
sudo -E cargo test --test jail_integration -- --ignored
```bash
# Run weak mode tests
cargo test --test weak_integration

# Run with output for debugging
sudo -E cargo test -- --ignored --nocapture
cargo test --test weak_integration -- --nocapture
```

### Manual Testing
Expand All @@ -71,7 +70,7 @@ sudo ./target/release/httpjail --log-only -- curl http://example.com

- `tests/smoke_test.rs` - Basic CLI tests that don't require network or sudo
- `tests/jail_integration.rs` - Comprehensive integration tests for jail functionality
- `tests/macos_integration.rs` - macOS-specific integration tests using assert_cmd
- `tests/weak_integration.rs` - Weak mode (environment-based) integration tests

## Code Style

Expand Down
Loading