Include created_at in compact index /info endpoint#6380
Open
marcbest wants to merge 1 commit intorubygems:masterfrom
Open
Include created_at in compact index /info endpoint#6380marcbest wants to merge 1 commit intorubygems:masterfrom
marcbest wants to merge 1 commit intorubygems:masterfrom
Conversation
Pass the version's created_at timestamp to CompactIndex::GemVersion so it is included in the /info response. The timestamp is formatted as ISO 8601 UTC. This enables Bundler clients to read publication dates from the compact index directly, avoiding separate V1 API calls per gem when implementing supply chain security features like min_age checks. Depends on rubygems/compact_index adding created_at as an optional 8th field to the GemVersion struct.
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.
Problem
Supply chain attacks targeting package registries are a growing concern. Other package managers have already shipped minimum age features — npm, pnpm, and yarn all allow users to reject recently published versions during resolution.
Bundler currently has no equivalent. Adding one requires knowing when each gem version was published, but the compact index has no publication timestamp. Without it, clients must make a separate V1 API call per gem (
/api/v1/versions/<gem>.json) — adding seconds of latency and hitting the RubyGems.org rate limit (10 req/s) on projects with 50+ gems.The compact index
/infoendpoint already carries all the version data Bundler needs during resolution — exceptcreated_at.Solution
Pass the version's
created_at(already in the SQL query) toCompactIndex::GemVersion.newas the 8th argument, formatted as ISO 8601 UTC.Before:
After:
The
created_atcolumn is already selected in therequirements_and_dependenciesquery, included in theGROUP BY, and used forORDER BY. It just wasn't being passed through.Info line output
Old clients ignore unknown requirement fields, so this is fully backwards compatible.
Dependencies
Requires rubygems/compact_index#183 — adds
created_atas an optional 8th field toGemVersionstruct.