Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
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" }
44 changes: 25 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: Tests

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

env:
CARGO_TERM_COLOR: always
Expand All @@ -26,21 +24,24 @@ 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)
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
# Use -E to preserve environment and full path to cargo and nextest
sudo -E $(which cargo) nextest run --profile ci --test macos_integration --verbose

test-linux:
name: Linux Tests
Expand All @@ -60,38 +61,37 @@ 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

- name: Run jail integration tests
run: cargo test --test jail_integration --verbose
run: cargo nextest run --profile ci --test smoke_test --verbose

- name: Debug TLS environment
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 ==="

- name: Run Linux jail integration tests (with sudo)
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
# Use full path to cargo and nextest since sudo doesn't preserve PATH
sudo -E $(which cargo) nextest run --profile ci --test linux_integration --verbose

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

steps:
- uses: actions/checkout@v4

Expand All @@ -103,15 +103,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 +132,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
14 changes: 14 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dirs = "6.0.0"
hyper-rustls = "0.27.7"
tls-parser = "0.12.2"
camino = "1.1.11"
filetime = "0.2"

[target.'cfg(target_os = "macos")'.dependencies]
nix = { version = "0.27", features = ["user"] }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ A cross-platform tool for monitoring and restricting HTTP/HTTPS requests from pr
- [ ] Expand test cases to include WebSockets
- [ ] Add Linux support with parity with macOS
- [ ] Add robust firewall cleanup mechanism for Linux and macOS
- [ ] Support/test concurrent jailing across macOS and Linux

## Quick Start

Expand Down
11 changes: 11 additions & 0 deletions src/jail/linux/iptables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ pub struct IPTablesRule {
}

impl IPTablesRule {
/// Create a rule object for an existing rule (for cleanup purposes)
/// This doesn't add the rule, but will remove it when dropped
pub fn new_existing(table: Option<&str>, chain: &str, rule_spec: Vec<&str>) -> Self {
Self {
table: table.map(|s| s.to_string()),
chain: chain.to_string(),
rule_spec: rule_spec.iter().map(|s| s.to_string()).collect(),
added: true, // Mark as added so it will be removed on drop
}
}

/// Create and add a new iptables rule
pub fn new(table: Option<&str>, chain: &str, rule_spec: Vec<&str>) -> Result<Self> {
let mut args = Vec::new();
Expand Down
Loading