fix(fetchers): enforce GitHub commit API URL policy#166
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://api.github.com:443URL and sent it viatransport_requestwithout re-checking operatorFetchOptionspolicy, allowing an egress bypass of host/port/prefix restrictions.blocked_hosts, andallowed_portsmust apply to every outbound hop, including API subrequests produced by specialized fetchers.github.comURL (for examplehttp://github.com:80) but disallowsapi.github.com:443.Description
validate_url_policy(url, options)helper incrates/fetchkit/src/fetchers/mod.rsthat runsoptions.validate_urlplus prefix and block-prefix checks and returnBlockedUrlon violation.validate_url_policyand callvalidate_url_policyincrates/fetchkit/src/fetchers/github_commit.rsbefore thetransport_requestto the GitHub API.github_commit_fetcher_enforces_policy_on_api_subrequestincrates/fetchkit/tests/transport.rsand updatespecs/fetchers.mdto document that fetchers deriving secondary API URLs must enforce the same host/port/prefix policy.Testing
cargo test -p fetchkit --test transport github_commit_fetcher_enforces_policy_on_api_subrequestwhich passed and asserts the injected transport received zero calls when policy blocks the API URL.cargo test --workspacewhich completed successfully with all tests passing (343 passedreported in this run).cargo clippy --workspace --all-targets -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps, andcargo build --workspace --exclude fetchkit-python --release, all of which completed without errors.Codex Task