Repository navigation
feat: implement DNS namespace validation and remote URL uniqueness checks - #306
Conversation
6d0abc3 to
1b3dcaa
Compare
…ecks - Add DNS namespace validation for publisher domains - Implement remote URL uniqueness checks to prevent duplicates - Handle edge cases for null and non-array remotes in PostgreSQL queries - Increase query limit for better conflict detection - Update domain validation logic with proper 4xx error codes - Add comprehensive test coverage for validation scenarios 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
a42d3de to
52d1443
Compare
|
@claude please review |
|
Claude finished @domdomegg's task —— View job Code Review: DNS Namespace Validation and Remote URL UniquenessReview Summary ✅This is a well-implemented feature that adds important governance controls to the registry. The implementation is comprehensive, well-tested, and follows good architectural patterns. Detailed Review FindingsReview Checklist
✅ Strengths1. Robust Validation Logic (
2. Excellent Test Coverage (
3. Clean Service Integration (
4. Database Layer Enhancement (
🔍 Technical ObservationsSecurity Considerations:
Performance Notes:
Error Handling:
📝 Minor Suggestions
🧪 Test Quality
|
| for _, remote := range serverDetail.Remotes { | ||
| // Use filter to find servers with this remote URL | ||
| filter := map[string]any{ | ||
| "remote_url": remote.URL, |
There was a problem hiding this comment.
Would it make sense to add name to the filter here?
| "remote_url": remote.URL, | |
| "remote_url": remote.URL, | |
| "name": serverDetail.Name |
Just trying to understand if we can move the "Check if any conflicting server has a different name" to the db query level and if it makes sense.
There was a problem hiding this comment.
I think it's not possible (with our current filtering) to filter for the name not being a particular value unfortunately.
A publisher can currently block an endpoint's operator from listing it under their own namespace simply by registering the remote URL first. The registry authenticates namespaces but does not verify remote URL ownership, so registration order cannot establish the canonical publisher. This change allows different server names to reference the same remote URL on both `/v0` and `/v0.1`. It removes the conflict check from publication, admin metadata edits, single-version restores, and all-version restores. Namespace authorization, URL validation, name/version uniqueness, and per-name version history remain intact. Existing records, response schemas, and database indexes are unchanged; no data migration is needed. The existing `remotes_ms` log field is retained at zero. The original uniqueness rule accompanied namespace/hostname matching in #180 and #306; #769 later removed hostname matching. ## Downstream compatibility This changes a previously documented behavioral guarantee, even though the API shape is unchanged. Consumers that use a remote URL as a unique key, or resolve it to a single canonical listing, must support multiple matching server names. Records should be keyed by name/version (and registry when combining sources), with each listing's metadata, headers, and template variables kept separate. A shared endpoint does not establish publisher ownership or endorsement. The publishing guide and changelog explain this change. Review the compatibility implications and coordinate rollout with downstream consumers. Re-enabling uniqueness after shared URLs have been accepted could block those servers' subsequent publications, edits, and restores. Discovery grouping and endpoint ownership verification are outside this PR. ## Validation Updates the indirect `github.com/klauspost/compress` dependency from v1.20.1 to v1.20.2 to fix GO-2026-6865, which was reported by CI's vulnerability scan. Local `govulncheck ./...` and the CI vulnerability scan pass with the update. - Added database-backed regressions for independent metadata, version histories, latest-only pagination, encoded listings, admin edits, and single/all-version restores to active or deprecated. - Added HTTP publish coverage on both API versions proving shared URLs succeed while unauthorized namespaces, duplicate name/version pairs, and invalid remote URLs still fail. - Confirmed the new publication, edit, and active-restore regressions fail against the original service implementation and pass with this change. - Passed `go test -race -coverprofile=coverage.out -covermode=atomic ./internal/... ./cmd/...` using an isolated local PostgreSQL 17 instance. - Passed `make lint` with golangci-lint v2.14.0, `make validate build`, and `git diff --check`. - CI passed all checks, including `make test-all` (with Docker/ko integration tests), build/lint/validation, vulnerability scanning, and CodeQL. The Docker/ko integration harness was not run locally. --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Summary
Fixes #180 by ensuring proper namespace governance and preventing URL conflicts.