Skip to content

fix(fetchers): enforce policy for GitHub API subrequests#131

Merged
chaliy merged 1 commit into
mainfrom
2026-05-18-fix-github-fetcher-url-policy-bypass
May 18, 2026
Merged

fix(fetchers): enforce policy for GitHub API subrequests#131
chaliy merged 1 commit into
mainfrom
2026-05-18-fix-github-fetcher-url-policy-bypass

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 18, 2026

Motivation

  • The GitHub repo fetcher constructed api.github.com subrequests after the registry only validated the original github.com URL, allowing an egress policy bypass.
  • The fetcher also always used GET for its API calls, ignoring callers that requested HEAD, which could violate caller expectations and policies.

Description

  • Added GitHubRepoFetcher::validate_policy_url to enforce allow_prefixes / block_prefixes for secondary outbound URLs. This helper is invoked before the /repos/{owner}/{repo} and /readme API calls.
  • Honor the caller's method by using request.effective_method() to issue GET or HEAD for the repo metadata request, and return early for HEAD (skip README fetch and JSON parsing).
  • Added HttpMethod to imports and light unit tests for the new policy validation helper (test_validate_policy_url).
  • Kept behavior scoped to the GitHub fetcher so other fetchers remain unchanged.

Testing

  • Ran the targeted fetcher unit tests with cargo test -p fetchkit github_repo -- --nocapture, and all tests passed (10 passed, 0 failed).
  • Package-level test run completed successfully during the change verification with no regressions observed in the fetcher test suite.

Codex Task

@chaliy chaliy force-pushed the 2026-05-18-fix-github-fetcher-url-policy-bypass branch from 58eeeb0 to 851eb0e Compare May 18, 2026 04:00
@chaliy chaliy merged commit 5a6f958 into main May 18, 2026
11 checks passed
@chaliy chaliy deleted the 2026-05-18-fix-github-fetcher-url-policy-bypass branch May 18, 2026 04:41
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.

1 participant