fix: auto-inject GHEC tenant domains into firewall allowlist#1316
fix: auto-inject GHEC tenant domains into firewall allowlist#1316
Conversation
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
|
🔮 Oracle smoke trace:
Warning
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
There was a problem hiding this comment.
Pull request overview
Updates the CLI’s firewall allowlist auto-injection so GitHub Enterprise Cloud tenants (*.ghe.com) are automatically permitted based on GITHUB_SERVER_URL / GITHUB_API_URL, preventing Copilot-related requests from being blocked in GHEC environments.
Changes:
- Added
extractGhecDomainsFromServerUrl()to derive GHEC tenant + API subdomain allowlist entries. - Integrated GHEC domain auto-injection into
resolveApiTargetsToAllowedDomains(). - Added unit tests covering GHEC extraction and allowlist injection behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/cli.ts |
Adds GHEC domain extraction and injects derived domains into the firewall allowlist resolution flow. |
src/cli.test.ts |
Adds unit tests for GHEC domain extraction and allowlist injection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| for (const domain of ghecDomains) { | ||
| if (!allowedDomains.includes(domain)) { | ||
| allowedDomains.push(domain); | ||
| } | ||
| } | ||
| debug(`Auto-added GHEC domains from GITHUB_SERVER_URL/GITHUB_API_URL: ${ghecDomains.join(', ')}`); |
| // GHEC tenant: add the tenant domain and its API subdomain | ||
| // e.g., company.ghe.com → company.ghe.com + api.company.ghe.com | ||
| domains.push(hostname); | ||
| domains.push(`api.${hostname}`); |
When
GITHUB_SERVER_URLis a GitHub Enterprise Cloud (GHEC) tenant (e.g.,https://company.ghe.com), the firewall now automatically adds the tenant domain and its API subdomain to the allowlist so Copilot CLI requests are not blocked.Root cause:
resolveApiTargetsToAllowedDomains()insrc/cli.tsonly auto-added domains from explicitCOPILOT_API_TARGET/ENGINE_API_TARGETenv vars, but did not inspectGITHUB_SERVER_URLorGITHUB_API_URLfor GHEC tenants.Fix:
extractGhecDomainsFromServerUrl(env)that detects*.ghe.comhostnames inGITHUB_SERVER_URLand derives both{tenant}.ghe.comandapi.{tenant}.ghe.comGITHUB_API_URLwhen it points to a*.ghe.comAPI endpointresolveApiTargetsToAllowedDomains()so GHEC domains are automatically allowed alongside any explicit API targetsNote: The api-proxy's
deriveCopilotApiTarget()already correctly routes Copilot token exchange requests toapi.{tenant}.ghe.comusingGITHUB_SERVER_URL— that part was not broken. This PR fixes only the missing firewall allowlist injection.