Allow add URL importer auth for api.githubcopilot.com#33402
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot allow domains from the GitHub domain set by default. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the CLI URL importer so authenticated fetches can include Copilot-hosted workflow URLs on api.githubcopilot.com, and aligns allowlist behavior/tests accordingly.
Changes:
- Expands the importer auth-attachment logic from exact-host matching to a pattern-based host match derived from the
githubecosystem domains, plusapi.githubcopilot.comandGH_HOST. - Updates inline contract comments describing when
Authorization: Bearer <token>is attached. - Adds regression tests for
api.githubcopilot.comand additional GitHub content hosts; fixes a Datadog application key env var reference in a workflow lock file.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/import_url_fetcher.go | Switches auth-attachment allowlist to domain patterns + adds helper matchers and Copilot MCP domain inclusion. |
| pkg/cli/import_url_fetcher_test.go | Adds tests asserting auth header attachment for Copilot and additional GitHub content domains, plus a suffix-confusion case. |
| .github/workflows/smoke-otel-backends.lock.yml | Fixes Datadog header env var placeholder to use DD_APPLICATION_KEY. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 3
| // Authoritative GitHub hosts to which the token may be sent. | ||
| allowedHosts := []string{"github.com"} | ||
| allowedHosts := getDefaultImportAuthHostPatterns() | ||
| if ghHost := os.Getenv("GH_HOST"); ghHost != "" { | ||
| // GH_HOST may carry a scheme prefix; extract just the hostname. | ||
| if u, parseErr := url.Parse(ghHost); parseErr == nil && u.Host != "" { |
| // Authoritative GitHub hosts to which the token may be sent. | ||
| allowedHosts := []string{"github.com"} | ||
| allowedHosts := getDefaultImportAuthHostPatterns() | ||
| if ghHost := os.Getenv("GH_HOST"); ghHost != "" { |
| // attachImportAuthHeader adds "Authorization: Bearer <token>" to req if and only if | ||
| // ALL of the following are true: | ||
| // - the request scheme is "https" (tokens are never sent over plaintext HTTP) | ||
| // - the request host is an exact match for one of the allowed GitHub hosts: | ||
| // "github.com" or the hostname extracted from the GH_HOST environment variable | ||
| // - the request host matches one of the default GitHub ecosystem domain | ||
| // patterns (plus api.githubcopilot.com), or is an exact match for the | ||
| // hostname extracted from the GH_HOST environment variable |
Updated in ceb874f to derive the default approved import hosts from the GitHub domain set, while still allowing |
🧪 Test Quality Sentinel ReportTest Quality Score: 78/100
Test Classification Details
Analysis SummaryThis PR adds support for authenticating URL imports from Strengths: ✅ 100% behavioral coverage — All tests verify observable behavior (whether the Authorization header is correctly attached or omitted) ✅ Security-focused — ✅ No guideline violations — Proper ✅ Proportional growth — Test file grew 32 lines vs 29 net lines in production code (ratio 1.10:1, well under the 2:1 threshold) Improvement Opportunities:
Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.
|
|
@copilot review all comments |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Reviewed the actionable comments and pushed 363f342. The importer auth policy is now narrowed to an explicit cached host allowlist plus |
The
add/add-wizardURL importer allowed authenticated fetches forgithub.comandGH_HOST, but not forhttps://api.githubcopilot.com/.... This updates the importer so Copilot-hosted workflow URLs are treated as approved authenticated import sources.Importer allowlist
FetchImportURL/attachImportAuthHeaderto includeapi.githubcopilot.com.Code contract
Regression coverage
Authorization: Bearer <token>is attached forhttps://api.githubcopilot.com/....