fix(clone): resolve forge auth via configured *_URL env vars (fixes #1704)#1706
Conversation
…oleam00#1704) resolveForgeAuth() only matched forges by exact hostname or hostname label. Self-hosted instances with non-standard hostnames (e.g. git.example.com) were silently ignored even when GITEA_URL pointed to the same host. Add a third fallback step that compares the clone URL hostname against configured GITEA_URL, GITLAB_URL, and FORGEJO_URL env vars. This uses strict hostname equality so tokens are never leaked to unrelated hosts.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesURL-based auth token resolution for self-hosted forges
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review SummaryVerdict: ready-to-merge The PR adds explicit hostname-based matching against Minor / nice-to-have
Compliments
Reviewed via maintainer-review-pr workflow (Pi/Minimax). Aspects run: code-review, error-handling, test-coverage, comment-quality, docs-impact. |
Summary
resolveForgeAuth()ignoresGITEA_TOKENfor self-hosted Gitea instances whose hostname does not contain "gitea" (e.g.git.example.com)*_TOKENand*_URLenv vars setresolveForgeAuth()that compares the clone URL hostname against configuredGITEA_URL,GITLAB_URL, andFORGEJO_URLenv varsUX Journey
Before
After
Architecture Diagram
Before
After
Connection inventory:
Label Snapshot
risk: lowsize: Scorecore:cloneChange Metadata
bugcoreLinked Issue
resolveForgeAuthdoesn't useGITEA_TOKENfor self-hosted Gitea instances with non-standard hostnames #1704Validation Evidence (required)
New tests added:
returns GITEA_TOKEN when GITEA_URL hostname matches clone URL— the exact repro fromresolveForgeAuthdoesn't useGITEA_TOKENfor self-hosted Gitea instances with non-standard hostnames #1704returns GITLAB_TOKEN with oauth2: scheme when GITLAB_URL hostname matches— same pattern for GitLabdoes not leak GITEA_TOKEN when GITEA_URL is set but hostname differs— security: token isolationURL fallback does not activate when token env var is unset— graceful degradationSecurity Impact
===), not substring or label matching.GITEA_TOKENis only returned when the clone URL hostname is identical to theGITEA_URLhostname.Compatibility/Migration
*_URLenv vars are set (opt-in by configuration)Human Verification
resolveForgeAuthdoesn't useGITEA_TOKENfor self-hosted Gitea instances with non-standard hostnames #1704Risks and Mitigations
safeParseUrlreturns null for malformed URLif (forgeParsed &&...)*_URLvars pointing to same hostSide Effects/Blast Radius
resolveForgeAuth()is modified — no callers changedRollback Plan
Revert commit; steps 1 and 2 continue working as before.
Summary by CodeRabbit
Bug Fixes
Tests