fix(fetchers): enforce policy on PubMed API requests#170
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
allow_prefixes,block_prefixes,blocked_hosts,allowed_ports) to govern every fetchkit network hop, including secondary API requests from specialized fetchers.Description
validate_url_policyincrates/fetchkit/src/fetchers/mod.rsto centralize host, port, allow-prefix, and block-prefix validation and reuse it for registry dispatch viavalidate_and_find_fetcher.validate_url_policy(&api_url, options)?incrates/fetchkit/src/fetchers/pubmed.rsbefore callingtransport_requestso synthesized PubMed/PMC API URLs are validated against the same policy.#[tokio::test]incrates/fetchkit/src/fetchers/pubmed.rsthat uses a customHttpTransportto assert a blocked API URL returnsFetchError::BlockedUrland the transport is never invoked.specs/fetchers.mdto require that specialized fetchers which rewrite matched URLs must apply the configured URL policy before handing requests to the transport.Testing
cargo test -p fetchkit pubmed -- --nocaptureand all pubmed-related unit tests (including the new regression test) passed.cargo clippy -p fetchkit --all-targets -- -D warningswith no warnings.cargo fmt --alland updatedspecs/fetchers.mdaccordingly; all checks included in the developer workflow succeeded locally.Codex Task