Add version endpoints to the Collection API#1261
Merged
Merged
Conversation
6431642 to
d865fb6
Compare
ed2684b to
67c2e58
Compare
The single-version endpoints pass the URL `versionId` straight to `findById`, which placed it in a `git log` revision position with no separator. A value such as `--output=/path` was therefore parsed by git as an option, letting an unauthenticated caller create or overwrite an arbitrary file with `git log` output. Reject any record ID that is not a hexadecimal commit SHA before it reaches git, mirroring the `ObjectId.isValid` guard already used by the MongoDB backend, and pass validated IDs after `--end-of-options` as a second line of defence.
The version lookups compose a service ID, terms type or document ID into a Git pathspec. A value with a path separator or a `..` segment resolved outside the repository, and the resulting fatal git error exposed the repository filesystem location. Reject such values before they reach git, where they cannot match a record anyway, so the lookups return empty and the endpoints answer 404 instead of 500.
Diff statistics are only meaningful for the Git backend, which retains diffs; the MongoDB backend stores full snapshots and cannot provide them. The interface declared the method as returning numbers while MongoDB stubbed it with nulls. Move the null default into the repository interface so snapshot-based backends inherit it, drop the MongoDB stub, and document the statistics as an optional, nullable capability.
67c2e58 to
15e5898
Compare
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.
Adds read endpoints to the Collection API for browsing recorded versions:
GET /versions,GET /versions/{serviceId},GET /versions/{serviceId}/{termsType}GET /version/{versionId}andGET /version/{serviceId}/{termsType}/latest, and enriches the existing by-date endpointVersion responses now expose
serviceId,termsType,isFirstRecord,isTechnicalUpgrade, sourcefetchUrls, navigationlinksand diff statistics, implemented symmetrically for the Git and MongoDB backends.GET /service/{serviceId}not-found response is now JSON instead of plain text500s