Refactor host iptables setup into validation, chain, and rule modules#5355
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the host iptables implementation by separating validation, chain lifecycle management, and rule orchestration into dedicated modules, while keeping the setupHostIptables(...) entrypoint and runtime behavior intended to remain unchanged.
Changes:
- Added
src/host-iptables-validation.tsto house port-spec parsing and iptables error-shape helpers (plus test-only helper export). - Added
src/host-iptables-chain.tsto encapsulate chain setup/cleanup, DOCKER-USER jump insertion, and chain debug logging. - Updated
src/host-iptables-rules.tsto focus on rule construction/orchestration and delegate chain + validation responsibilities to the new modules.
Show a summary per file
| File | Description |
|---|---|
| src/host-iptables-validation.ts | New validation/error-shape helper module extracted from the prior monolithic rules file. |
| src/host-iptables-chain.ts | New chain lifecycle module for permissions checks, chain creation/cleanup, and DOCKER-USER jump management. |
| src/host-iptables-rules.ts | Reduced to orchestration + rule application; imports chain/validation helpers from new modules. |
| src/host-iptables-rules.test-utils.ts | Redirected test-only helper re-export to the new validation module. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
✅ Smoke Claude passed |
|
❌ Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed... |
|
❌ Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed... |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
|
✅ Smoke Gemini completed. All facets verified. 💎 |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
🔌 Smoke Services — All services reachable! ✅ |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
✅ Build Test Suite completed successfully! |
Smoke Test: BYOK Mode ✅Mode: Direct BYOK via api-proxy → api.githubcopilot.com
Status: PASS — All BYOK inference tests verified.
|
Smoke Test: Claude Engine Validation
Overall result: PASS
|
🔬 Smoke Test ResultsPR: Refactor host iptables setup into validation, chain, and rule modules
Overall: FAIL — pre-step outputs were not resolved (unsubstituted
|
🔍 Smoke Test: PAT Auth — PASSPR: Refactor host iptables setup into validation, chain, and rule modules
Overall: PASS (2/2 verifiable tests passed; file test skipped — pre-step template expansion issue)
|
|
PRs reviewed:
|
🧪 Chroot Version Comparison Results
Overall result: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
🔍 Smoke Test: API Proxy OpenTelemetry Tracing
All scenarios pass. ✅
|
Smoke Test Results: Gemini
Overall status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
Smoke test results:
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) Overall: PASS
|
src/host-iptables-rules.tshad grown into a single security-critical module mixing input validation, chain lifecycle management, and rule application. This change splits those concerns into focused modules while keeping the publicsetupHostIptablesAPI and rule behavior intact.Validation helpers
src/host-iptables-validation.tssrc/host-iptables-rules.test-utils.tsChain lifecycle management
DOCKER-USERjump insertion, and debug logging intosrc/host-iptables-chain.tsRule application module
src/host-iptables-rules.tsto rule construction/orchestration plus the public host-access config typessetupHostIptables(...)and its caller-facing contract unchangedExample of the new separation: