Remove suffix matching from host whitelist #35
Reference in New Issue
Block a user
Delete Branch "remove-whitelist-suffix-matching"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #27
Signatures are per-URL, so the host whitelist should only support exact host matches. This PR removes the suffix/wildcard matching that allowed patterns like
.example.comto bypass signature requirements for entire domain trees.Changes
internal/imgcache/whitelist.go: Removed thesuffixHostsfield and all suffix matching logic fromHostWhitelist. All entries are now exact host matches only. Leading dots in config entries are stripped during normalisation (.example.com→example.com), preserving backwards compatibility for existing configs.internal/imgcache/whitelist_test.go: Updated tests to verify exact-only matching behaviour. Added explicit tests confirming that suffix matching is no longer supported, including leading-dot normalisation and deduplication.README.md: Updated whitelist documentation to reflect exact-match-only semantics.config.example.yml: Removed the comment about wildcard subdomain matching.Review: PR #35 — Remove suffix matching from host whitelist
Policy Compliance
.golangci.ymlunmodifiedMakefileunmodifiedDockerfileunmodified.gitea/workflows/unmodifiedNo policy divergences found.
Requirements Checklist (Issue #27)
suffixHostsfield and all suffix-matching logic removed fromHostWhitelistIsWhitelistednow does a single map lookup.example.comis normalised toexample.comas an exact entry"example.com"+".example.com"correctly counts as 1 entryconfig.example.ymlupdated — wildcard comment removed, replaced with "(exact match only)"Code Quality
"."edge case (dot-only pattern) is handled by thepattern != ""guard afterTrimPrefix..example.comentries will silently becomeexample.comexact matches rather than breaking.suffixHostsfield and all references are cleanly removed.NewHostWhitelist,IsWhitelisted,IsEmpty,Count) have thorough table-driven tests covering both positive and negative cases for the new behaviour.Build Result
Verdict: PASS ✅
Clean, focused PR that does exactly what issue #27 asks for — removes suffix matching, keeps exact matches only, maintains backwards compat for existing configs. No policy violations, no scope creep, comprehensive tests, build green.
Review: PR #35 — Remove suffix matching from host whitelist
Policy Compliance
.golangci.ymlunmodifiedgit add -A/git add .No policy divergences found.
Requirements Checklist — Issue #27
suffixHostsfield and all suffix matching logicIsWhitelistednow does a single map lookup.example.comconfig entriesexample.com+.example.comCode Quality
suffixHostsslice and all associated iteration logic. The simplifiedIsWhitelistedis a single map lookup — correct and efficient.suffixHostsdoes not appear anywhere in the codebase. TheNewHostWhitelistAPI is unchanged ([]string) so the single caller inservice.goneeds no modification.Test Coverage
IsWhitelistedcovering exact match, case insensitivity, no-match, no suffix matching, leading dot normalisation, deep subdomains, multiple patterns, empty whitelist, nil URL, port handling, and whitespace.IsEmptyincluding leading-dot normalisation.Countincluding deduplication.service_test.gocontinue to pass.Build Result
Verdict: PASS ✅
Clean, well-scoped change that correctly implements issue #27. Code is simpler than before, tests are thorough, backwards compatibility is preserved, and the build is green.
Pull request closed