fix(web-tools): align web_fetch domain matching with spec-correct web_search matcher#209
Merged
Merged
Conversation
…_search matcher Route checkDomainPolicy (web_fetch) through the shared isHostAllowed matcher instead of the spec-divergent hostMatches (exact-only + `*.` glob). Subdomains of a listed domain are now auto-included, suffix lookalikes rejected, and path/wildcard entries matched on their host portion — matching web_search post-filtering. Delete the now-unused hostMatches. Add checkFetchPolicy coverage. Behavior change: web_fetch clients relying on exact-only or `*.`-glob semantics are affected; this aligns both tools with the published spec. Refs #208, #205.
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.
What
Routes
web_fetch's domain policy check through the same spec-correctisHostAllowedmatcher thatweb_searchresult post-filtering already uses, and deletes the now-unused legacyhostMatches.Before this change the two tools disagreed on an identical
allowed_domains/blocked_domainslist:web_fetchused exact-only +*.-glob matching, whileweb_search(shipped in #205) used subdomain-inclusive matching per Anthropic's server-tools spec.Why it matters
Concrete leak the old matcher allowed: a client declaring
blocked_domains: ["example.com"]onweb_fetchand fetchinghttps://tracker.example.com/x— spec says block (subdomain of a blocked domain), oldhostMatchesallowed it (exact-only). The symmetric allowlist case wrongly rejected legitimate subdomains.Changes
checkDomainPolicy(web_fetch) now delegates toisHostAllowed(host, decl)— subdomains auto-included, blocked-first mutual exclusion, path/wildcard entries matched on host portion. Error semantics unchanged (url_not_allowed).hostMatches(grep-confirmed no other callers).checkFetchPolicy — domain policytest coverage: blocklist/allowlist subdomain inclusion, suffix-lookalike rejection, path-entry host match, and the intentional*.-glob behavior change.Behavior change
web_fetch clients relying on the old exact-only or
*.-glob semantics are affected — intended, aligning both tools with the published spec.Verification
bun run typecheck— passbun run lint:all— pass, 0 problemsbun test tests/web-tools-state.test.ts— 12 pass / 0 failCloses #208. Refs #205.