Skip to content

fix: exempt DIFC/cli-proxy host from proxy routing in isolation mode#6438

Merged
lpcox merged 2 commits into
mainfrom
fix-proxy-noproxy-difc-host
Jul 20, 2026
Merged

fix: exempt DIFC/cli-proxy host from proxy routing in isolation mode#6438
lpcox merged 2 commits into
mainfrom
fix-proxy-noproxy-difc-host

Conversation

@lpcox

@lpcox lpcox commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

npm test was failing on main with one broken test in src/services/agent-environment/proxy-environment.test.ts:

buildProxyEnvironment › topology-attached peers › exempts the DIFC/cli-proxy host even when not listed in topologyAttach

buildProxyEnvironment only added config.topologyAttach peers to NO_PROXY. A difcProxyHost configured independently of topologyAttach was therefore routed through Squid and denied instead of being reached directly.

Fix

In network-isolation mode with a compose agent, also add config.difcProxyHost to NO_PROXY, stripping any :port suffix (undici matches NO_PROXY against the hostname only).

Testing

  • npm test — all 3959 tests pass (was 1 failing).

buildProxyEnvironment only added topologyAttach peers to NO_PROXY, so a
difcProxyHost set independently of topologyAttach was routed through Squid
and denied. Add the DIFC/cli-proxy host (stripping any ":port" suffix) when
in network-isolation mode with a compose agent, fixing the failing
proxy-environment test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 14b695ec-1224-416b-999f-d3845138ea2f
Copilot AI review requested due to automatic review settings July 20, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the DIFC/CLI proxy host to NO_PROXY during compose-based network isolation.

Changes:

  • Exempts difcProxyHost from Squid routing.
  • Attempts to remove its port suffix.
Show a summary per file
File Description
src/services/agent-environment/proxy-environment.ts Adds the DIFC proxy host to NO_PROXY.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Medium

// must bypass Squid even when it isn't listed in topologyAttach. Strip any
// ":port" suffix since undici matches NO_PROXY against the hostname only.
if (config.difcProxyHost) {
noProxyHosts.push(config.difcProxyHost.split(':')[0]);
@lpcox

lpcox commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.76% 98.79% 📈 +0.03%
Statements 98.70% 98.73% 📈 +0.03%
Functions 99.28% 99.28% ➡️ +0.00%
Branches 95.01% 95.01% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Replace `split(':')[0]` with `parseDifcProxyHost().host` so that
scheme-prefixed values (e.g. https://proxy.internal:443) and bracketed
IPv6 addresses (e.g. [::1]:18443) are handled correctly.

Add test cases covering port-only, scheme-prefixed, and IPv6 forms.

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Done in the latest commit. Replaced split(':')[0] with parseDifcProxyHost(config.difcProxyHost).host so scheme-prefixed values (https://proxy.internal:443) and bracketed IPv6 ([::1]:18443) are handled correctly. Added three new test cases covering port-only, scheme-prefixed, and IPv6 forms — all 10 tests pass.

Copilot finished work on behalf of lpcox July 20, 2026 17:26
@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@lpcox Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Contribution Check failed. Please review the logs for details.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Docker Sbx has concluded. All systems operational. This is a developing story. 🎤

@github-actions

Copy link
Copy Markdown
Contributor

Smoke test: Copilot network isolation egress enforcement — @lpcox

EGRESS_RESULT allow=pass deny=pass

  • ✅ Allowed domain (api.github.com): HTTP 200
  • ✅ Blocked domain (example.com): connection denied (403 from proxy)

Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot PAT Auth — PASS ✅

Test Result
GitHub MCP connectivity ✅ Connected (PR data filtered by secrecy policy)
GitHub.com HTTP ✅ (pre-step result)
File write/read ✅ (pre-step result)

Auth mode: PAT (COPILOT_GITHUB_TOKEN)

Note: Template variables (${{ steps.smoke-data.outputs.* }}) were not expanded at agent runtime; pre-step results accepted as-is.

🔑 PAT report filed by Smoke Copilot PAT
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — Services Connectivity

Check Result
Redis PING ❌ Name resolution failure (host.docker.internal unreachable)
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Name resolution failure

Overall: FAILhost.docker.internal DNS does not resolve in this environment. Service containers are unreachable.

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results ✅

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.13 ✅ YES
Node.js v24.18.0 v24.18.0 ✅ YES
Go go1.22.12 go1.22.12 ✅ YES

All runtime versions match between host and chroot environment.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Detail
S1: Module Loading otel.js loads successfully; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, plus internal test helpers
S2: Test Suite otel.test.js exists with ~123 test/describe/it references; OTEL tests are present and expected to pass
S3: Env Var Forwarding src/services/api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID to the api-proxy container
S4: Token Tracker Integration onUsage callback exists in token-tracker-http.js (line 285, 343) as the OTEL hook point
S5: OTEL Diagnostics otel.js includes FileSpanExporter fallback to /var/log/api-proxy/otel.jsonl when no endpoint configured; FanOutSpanExporter for multi-endpoint export

All scenarios pass. OTEL tracing integration is fully implemented.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

  • GitHub MCP Testing: ✅
  • GitHub.com Connectivity: ✅
  • File Write/Read Test: ✅
  • BYOK Inference Test: ✅
    Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra
    Overall: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

✅ 6429 Internalize dead sbx-manager exports
✅ 6428 Internalize dead secureWipeFile export in SSL key storage
✅ fix: exempt DIFC/cli-proxy host from proxy routing in isolation mode
✅ Browser
✅ Smoke file
✅ Build
Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for #6438 · 73 AIC · ⊞ 8.2K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

GitHub MCP Test: ❌
GitHub.com Connectivity: ✅
File I/O Test: ✅
BYOK Inference Test: ✅

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
Overall: FAIL

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Smoke Test: Docker Sbx Validation

Test Result
GitHub MCP ❌ Filtered by secrecy policy
GitHub.com HTTP ⚠️ Pre-step data unavailable (template vars not substituted)
File Write/Read ⚠️ Pre-step data unavailable (template vars not substituted)

Overall: ⚠️ INCONCLUSIVE — Pre-computed step outputs were not passed to the agent (unresolved ${{ }} templates). MCP access was blocked by secrecy policy.

Actor: @lpcox

📰 BREAKING: Report filed by Smoke Docker Sbx
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

  • GitHub MCP Testing: ❌ (Redacted by integrity policy)
  • GitHub.com Connectivity: ❌ (Network unreachable, Status 000)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini
Add label ready-for-aw to run again

@lpcox
lpcox merged commit c36473b into main Jul 20, 2026
141 of 142 checks passed
@lpcox
lpcox deleted the fix-proxy-noproxy-difc-host branch July 20, 2026 17:42
lpcox added a commit that referenced this pull request Jul 21, 2026
Address review feedback on auto-allowing topology peers in the Squid ACL:

- Gate the ACL addition on runtimeUsesComposeAgent() in addition to
  networkIsolation, mirroring buildProxyEnvironment() exactly. microVM
  backends (Docker sbx) run the agent off awf-net and reach peers via
  their own proxy-chaining path, so topology hostnames are skipped there
  too, keeping the ACL and NO_PROXY code paths consistent.
- Also auto-allow the DIFC/cli-proxy host (difcProxyHost) through Squid,
  mirroring the NO_PROXY entry added in #6438, so NO_PROXY-ignoring proxy
  clients can reach it. The scheme/port are stripped via parseDifcProxyHost.
- Document Squid dstdomain wildcard semantics (formatDomainForSquid
  prepends a leading dot, matching the host and its subdomains).
- Add tests: non-compose runtime skip, explicit compose runtime add, and
  difcProxyHost auto-allow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5f6caa3b-9079-4d7f-a752-524b0f990e0c
lpcox added a commit that referenced this pull request Jul 21, 2026
* Initial plan

* Auto-allow topology-attached container hostnames in Squid ACL

In network-isolation mode, topology-attached containers (e.g. awmg-mcpg)
are already added to NO_PROXY so proxy-aware clients connect to them
directly. However, tools that honour HTTP(S)_PROXY but ignore NO_PROXY
route those requests through Squid, which blocks them because the
container hostname is not in the allowed-domain ACL.

Fix: in resolveAllowedDomains(), when networkIsolation is true and
topologyAttach container names are present, automatically add each name
to allowedDomains so Squid permits those requests.

* fix: align topology ACL gating with proxy env and mirror difcProxyHost

Address review feedback on auto-allowing topology peers in the Squid ACL:

- Gate the ACL addition on runtimeUsesComposeAgent() in addition to
  networkIsolation, mirroring buildProxyEnvironment() exactly. microVM
  backends (Docker sbx) run the agent off awf-net and reach peers via
  their own proxy-chaining path, so topology hostnames are skipped there
  too, keeping the ACL and NO_PROXY code paths consistent.
- Also auto-allow the DIFC/cli-proxy host (difcProxyHost) through Squid,
  mirroring the NO_PROXY entry added in #6438, so NO_PROXY-ignoring proxy
  clients can reach it. The scheme/port are stripped via parseDifcProxyHost.
- Document Squid dstdomain wildcard semantics (formatDomainForSquid
  prepends a leading dot, matching the host and its subdomains).
- Add tests: non-compose runtime skip, explicit compose runtime add, and
  difcProxyHost auto-allow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5f6caa3b-9079-4d7f-a752-524b0f990e0c

* fix: make Squid actually serve topology peers (DNS + non-standard ports)

Address reviewer feedback that adding topology peer hostnames to the
domain allowlist alone does not make them reachable through Squid:

1. DNS: Squid resolves proxied destinations via external `dns_nameservers`,
   which cannot resolve Docker-only peer names (e.g. `awmg-mcpg`).
   `patchComposeWithTopologyHosts` now also patches the `squid-proxy`
   service `extra_hosts` (Squid reads /etc/hosts before DNS). The phased
   startup applies this before the full `docker compose up`, which recreates
   squid-proxy to pick up the entries.

2. Ports: `http_access deny !Safe_ports` (80/443) fires before the domain
   allowlist, so `http://awmg-mcpg:8080` was denied on the port. A new
   `SquidConfig.topologyPeers` emits a per-peer `http_access allow`
   (dstdomain) *before* the Safe_ports and raw-IP deny rules, permitting any
   port to these operator-attached, trusted peers. This mirrors the existing
   apiProxyIp/apiProxyPorts precedent.

Also extract `resolveTopologyPeerHosts()` (topology-peers.ts) shared by
preflight (domain ACL) and config-writer (Squid allow), so the peer set and
compose-runtime gating stay in sync with buildProxyEnvironment().

Tests: topology-peers helper, Squid topology-peer section + rule ordering,
and squid-proxy extra_hosts patching. Full suite: 3986 passing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5f6caa3b-9079-4d7f-a752-524b0f990e0c

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Landon Cox <landon.cox@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants