refactor: extract addDnsRules helper to eliminate duplicate DNS iptables rule pairs#3273
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR refactors host firewall rule setup to remove duplicated DNS (port 53) allowlist rule pairs by extracting a shared helper, reducing the risk of future drift between UDP/TCP DNS rules across multiple call sites.
Changes:
- Added
addDnsRules(cmd, chain, destination)helper insrc/host-iptables-shared.tsto append both UDP and TCP ACCEPT rules for port 53. - Replaced three duplicated UDP+TCP port-53 rule blocks in
src/host-iptables-rules.tswithaddDnsRules(...)calls.
Show a summary per file
| File | Description |
|---|---|
src/host-iptables-shared.ts |
Introduces addDnsRules helper for adding UDP+TCP DNS ACCEPT rules to a chain. |
src/host-iptables-rules.ts |
Switches existing DNS allowlist rule additions (IPv4, IPv6, DoH proxy) to use the shared helper. |
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: 1
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🧪 Smoke Test Results
Overall: FAIL — workflow template variables (
|
|
Smoke test FAILED: MCP missing, Connectivity failed. 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 Results
Overall: 2/3 PASS — GitHub API authentication issue prevents full validation.
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: PARTIAL PASS — BYOK inference path works; GitHub MCP unauthenticated (infra issue, not product regression) PR author:
|
Chroot Smoke Test Results
Result: FAIL — Python and Node.js versions differ between host and chroot. Go matches.
|
|
Smoke test Codex: FAIL 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.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL —
|
The UDP+TCP port-53
iptables/ip6tablesrule pair was duplicated across three sites inhost-iptables-rules.ts— any structural change (logging, connection tracking, comments) required synchronized edits in all three places; missing one would silently create a security inconsistency in the DNS allowlist.Changes
src/host-iptables-shared.ts— newaddDnsRules(cmd, chain, destination)helper that atomically adds the UDP+TCP ACCEPT pair for port 53:src/host-iptables-rules.ts— all three duplicate rule pairs replaced withaddDnsRulescalls:addDnsRules('iptables', CHAIN_NAME, dnsServer)addDnsRules('ip6tables', CHAIN_NAME_V6, dnsServer)addDnsRules('iptables', CHAIN_NAME, dohProxyIp)