Refactor host-access port spec parsing to remove duplicate logic#3822
Refactor host-access port spec parsing to remove duplicate logic#3822Copilot wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors host-access port-spec parsing in setupHostIptables() by consolidating duplicated CSV parse/trim/validate logic for allowHostPorts and allowHostServicePorts into a shared helper, while keeping warning text semantics intact via a label parameter.
Changes:
- Added internal helper
parseValidPortSpecs(input, label)to centralize port-spec parsing/validation and warning emission. - Replaced the two duplicated inline loops with calls to the shared helper for
allowHostPortsandallowHostServicePorts. - Added a unit test ensuring invalid
allowHostServicePortsentries are skipped while valid ports still produce iptables rules.
Show a summary per file
| File | Description |
|---|---|
| src/host-iptables-rules.ts | Introduces parseValidPortSpecs() and uses it to remove duplicated validation logic for host-access port specs. |
| src/host-iptables-host-access.test.ts | Adds a test covering invalid-value filtering for allowHostServicePorts while verifying valid ports still generate rules. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
🔬 Smoke Test Results
PR: "Refactor host-access port spec parsing to remove duplicate logic" Overall: PARTIAL — MCP ✅, connectivity tests skipped (workflow template vars unexpanded)
|
Smoke Test: Claude Engine
Result: PASS
|
|
✅ fix(api-proxy): prevent stream_options injection into OpenAI Responses API requests Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( PR author: Overall: PARTIAL — BYOK inference confirmed ✅; pre-step HTTP/file tests had unexpanded template variables.
|
Gemini Smoke Test Results
PASS 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.
|
Chroot Runtime Version Comparison
Result: ❌ Not all runtimes match —
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results — Services Connectivity
Overall: FAIL —
|
|
@copilot adddress review feedback |
I checked the PR review threads and don’t see any actionable review comments to address—the review summary shows 0 findings. Point me to the specific comment or requested change and I’ll update the PR. |
setupHostIptables()had two near-identical parse/trim/validate loops forallowHostPortsandallowHostServicePorts, differing only in warning label text. This change consolidates that logic so both inputs use one validation path while preserving existing behavior and log semantics.Code simplification
parseValidPortSpecs(input, label)insrc/host-iptables-rules.ts.parseValidPortSpecs(hostAccess.allowHostPorts, "port spec")parseValidPortSpecs(hostAccess.allowHostServicePorts, "host service port spec")Behavioral parity
label.customPorts/allPortspath.Test coverage adjustment
src/host-iptables-host-access.test.tsto verify invalidallowHostServicePortsvalues are filtered and valid ones still produce rules.