fix(fetchers): enforce GitLab API URL policy#172
Open
chaliy wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
https://gitlab.com/api/v4/...URL from a validated page URL and called transport without reapplying outbound policy, allowing an egress-policy bypass (port and prefix checks) for the hardcoded GitLab API.FetchOptionsbefore transport execution.Description
enforce_url_policy(url, options)helper incrates/fetchkit/src/fetchers/mod.rsthat consolidatesoptions.validate_urlplus allow/block prefix checks and ispub(crate)for reuse.enforce_url_policy(&parsed_url, options)invalidate_and_find_fetcherso initial dispatch behavior is unchanged but centralized.GitLabFetcher::fetchcallenforce_url_policy(&api_url, options)?before invokingtransport_request, preventing API subrequests from bypassingallowed_ports,blocked_hosts,allow_prefixes, orblock_prefixes.gitlab_fetcher_enforces_policy_on_api_subrequestincrates/fetchkit/tests/transport.rsand updatespecs/fetchers.mdto document that specialized-fetcher API subrequests must reapply URL policy.Testing
gitlab_fetcher_enforces_policy_on_api_subrequestwhich passed locally (ok).cargo test --workspaceand all workspace tests passed (343 passed; 0 failed).cargo clippy --workspace --all-targets -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps, andcargo build --workspace --exclude fetchkit-python --release; all completed successfully.Codex Task