Skip to content

fix: unblock Smoke Gemini — exclude MCP host env leak, allow api-proxy IP through Squid#2986

Merged
lpcox merged 4 commits into
mainfrom
copilot/awf-fix-gemini-api-allowlist
May 12, 2026
Merged

fix: unblock Smoke Gemini — exclude MCP host env leak, allow api-proxy IP through Squid#2986
lpcox merged 4 commits into
mainfrom
copilot/awf-fix-gemini-api-allowlist

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

  • Add runtime validation for apiProxyPorts values in src/squid-config.ts
  • Fix writeConfigs in src/container-lifecycle.ts to pass apiProxyIp to generatePolicyManifest
  • Add unit tests for api-proxy Squid config behavior (rule ordering, Safe_ports, validation)
  • Run lint/build/test to verify all changes

Copilot AI changed the title [WIP] Fix allowlist for Gemini API domains in Smoke workflow fix: unblock Smoke Gemini — exclude MCP host env leak, allow api-proxy IP through Squid May 12, 2026
Copilot finished work on behalf of lpcox May 12, 2026 02:24
Copilot AI requested a review from lpcox May 12, 2026 02:24
@lpcox lpcox marked this pull request as ready for review May 12, 2026 02:51
@lpcox lpcox requested a review from Mossaka as a code owner May 12, 2026 02:51
Copilot AI review requested due to automatic review settings May 12, 2026 02:51
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 87.89% 87.83% 📉 -0.06%
Statements 87.85% 87.79% 📉 -0.06%
Functions 83.51% 83.51% ➡️ +0.00%
Branches 79.79% 79.59% 📉 -0.20%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/squid-config.ts 96.9% → 94.1% (-2.81%) 97.0% → 94.2% (-2.77%)
src/container-lifecycle.ts 87.3% → 88.4% (+1.13%) 87.7% → 88.8% (+1.10%)

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

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Smoke Gemini failures by preventing an MCP gateway host-domain env var from leaking into the agent container and by allowing the api-proxy sidecar’s raw IPv4 traffic through Squid (including making api-proxy ports eligible for Safe_ports checks).

Changes:

  • Exclude MCP_GATEWAY_HOST_DOMAIN from inherited agent environment and from the workflow’s --env-all passthrough.
  • Extend Squid config generation to (a) allow the api-proxy sidecar IP before raw-IP deny rules and (b) add api-proxy ports to Safe_ports.
  • Update Smoke Gemini workflow allowlists to include generativelanguage.googleapis.com and aiplatform.googleapis.com.
Show a summary per file
File Description
src/types/docker.ts Extends SquidConfig with apiProxyIp and apiProxyPorts inputs.
src/squid-config.ts Generates new Squid ACL/rules for api-proxy IP/ports; adds policy-manifest rule entry.
src/services/agent-environment.ts Adds MCP_GATEWAY_HOST_DOMAIN to excluded env passthrough list.
src/container-lifecycle.ts Passes api-proxy IP/ports into Squid config generation when api-proxy is enabled.
.github/workflows/smoke-gemini.md Adds required Google API domains to network.allowed.
.github/workflows/smoke-gemini.lock.yml Updates locked allowed domains and excludes MCP_GATEWAY_HOST_DOMAIN from --env-all.

Copilot's findings

Tip

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

  • Files reviewed: 6/6 changed files
  • Comments generated: 3

Comment thread src/squid-config.ts
// the per-IP allow rule (below) has a chance to fire.
if (apiProxyPorts && apiProxyPorts.length > 0) {
for (const proxyPort of apiProxyPorts) {
portAclsSection += `\nacl Safe_ports port ${proxyPort} # AWF api-proxy sidecar`;
Comment thread src/squid-config.ts
Comment on lines +767 to +778
// --- api-proxy allow (before raw-IP deny) ---
if (apiProxyIp) {
rules.push({
id: 'allow-api-proxy-ip',
order: ++order,
action: 'allow',
aclName: 'allow_api_proxy_ip',
protocol: 'both',
domains: [apiProxyIp],
description: 'Allow connections to the AWF api-proxy sidecar IP before raw-IP deny rules',
});
}
Comment thread src/squid-config.ts
Comment on lines +648 to +656
${apiProxyIp ? `
# Allow connections to the AWF api-proxy sidecar before raw-IP deny rules.
# Some HTTP clients (e.g., Node.js fetch / undici ProxyAgent) route requests to
# the api-proxy via HTTP_PROXY without honouring NO_PROXY for raw IP addresses,
# causing them to arrive at Squid and be rejected by the raw-IP deny rule below.
# This allow rule fires first for the known api-proxy IP.
acl allow_api_proxy_ip dst ${apiProxyIp}
http_access allow allow_api_proxy_ip
` : ''}
@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented May 12, 2026

@copilot address the review feedback

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

@copilot address the review feedback

All three points addressed in commit fix: validate apiProxyPorts, sync policy manifest, add api-proxy tests:

  1. apiProxyPorts validation (src/squid-config.ts) — each port now undergoes the same checks as allowHostPorts: Number.isInteger, range 1–65535, and a block against DANGEROUS_PORTS. Invalid values throw before anything is written to squid.conf.

  2. generatePolicyManifest call site (src/container-lifecycle.ts) — writeConfigs now spreads apiProxyIp: networkConfig.proxyIp into the generatePolicyManifest call when config.enableApiProxy and networkConfig.proxyIp are both set, matching the same condition used for generateSquidConfig. policy-manifest.json will now include the allow-api-proxy-ip rule and its correct position in rule order.

  3. Unit tests (src/squid-config.test.ts) — added 12 new tests:

    • allow_api_proxy_ip rule is present and ordered before http_access deny dst_ipv4
    • acl Safe_ports entries are emitted for each api-proxy port
    • No api-proxy rules emitted when apiProxyIp is absent
    • Rejects NaN, out-of-range (0, 65536), and dangerous (22) port values
    • Rejects newline-injected and invalid-octet apiProxyIp values
    • generatePolicyManifest includes allow-api-proxy-ip before deny-raw-ipv4, and omits it when apiProxyIp is not set

All 1781 tests pass; lint and build clean.

@lpcox lpcox closed this May 12, 2026
@lpcox lpcox reopened this May 12, 2026
Copilot stopped work on behalf of lpcox due to an error May 12, 2026 03:51
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 87.89% 87.86% 📉 -0.03%
Statements 87.85% 87.81% 📉 -0.04%
Functions 83.51% 92.12% 📈 +8.61%
Branches 79.79% 79.90% 📈 +0.11%
📁 Per-file Coverage Changes (3 files)
File Lines (Before → After) Statements (Before → After)
src/cli.ts 98.3% → 85.7% (-12.59%) 98.3% → 85.7% (-12.62%)
src/squid-config.ts 96.9% → 97.1% (+0.18%) 97.0% → 97.2% (+0.17%)
src/container-lifecycle.ts 87.3% → 88.4% (+1.13%) 87.7% → 88.8% (+1.10%)

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

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test

✅ Merged PRs: refactor: remove dead re-exports from cli.ts and unexport ExecaMockResult; refactor: fix test import path inconsistency for docker-manager
❌ safeinputs-gh: unavailable
✅ Playwright: GitHub title verified
❌ Tavily: no result payload returned
✅ File/Bash: test file verified
❌ Discussion: query tool unavailable
✅ Build: npm ci && npm run build
Overall status: FAIL

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

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP connectivity ❌ (401 - credentials unavailable in sandbox)
GitHub.com HTTP ⚠️ (pre-step template vars not resolved)
File write/read ⚠️ (pre-step template vars not resolved)
BYOK inference (this response)

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com

Overall: PARTIAL — BYOK inference path confirmed working; pre-step data not available for full validation.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

✅ GitHub MCP: 906adff, 35cd74c
✅ Playwright: github.com title verified
✅ File writing: Test file created
✅ Bash verification: File confirmed

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results — PR #2986

Test Result
GitHub MCP connectivity ❌ 401 Bad credentials
GitHub.com HTTP connectivity ⚠️ Template vars not expanded
File write/read /tmp/gh-aw/agent/smoke-test-copilot-25712221684.txt confirmed

Overall: FAIL — GitHub MCP returned 401 and workflow template variables were not substituted.

Actor: @lpcox

📰 BREAKING: Report filed by Smoke Copilot

@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.3
Node.js v24.14.1 v20.20.2
Go go1.22.12 go1.22.12

Overall: ❌ Not all versions match. Go matches, but Python and Node.js differ between host and chroot environments.

Tested by Smoke Chroot

@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 passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit 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 issue #2986 · ● 662.3K ·

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results — FAIL

Check Result
Redis PING ❌ Timeout/no response
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Timeout/no response

host.docker.internal is not reachable from this environment — the agent is not running inside a Docker container with access to the host network. All checks failed.

Overall: ❌ FAIL

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit 6a9fcf9 into main May 12, 2026
63 of 69 checks passed
@lpcox lpcox deleted the copilot/awf-fix-gemini-api-allowlist branch May 12, 2026 04:50
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.

[awf] Squid allowlist: Gemini API domains missing, causing Smoke Gemini failures

3 participants