Skip to content

Withhold Composer archives still in cooldown - #469

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
simonchrz:fix/composer-download-cooldown
Oct 14, 2026
Merged

andrew merged 1 commit into
git-pkgs:mainfrom
simonchrz:fix/composer-download-cooldown

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Cooldown only filtered Composer metadata. A composer.lock records the proxy's /composer/files/... URL, so composer install fetched versions still inside the cooldown window without ever reading the filtered metadata. npm already checks publish time on tarball downloads (versionInCooldown).

Changes

  • composerDistURL and findDownloadURLFromMetadata return a composerDist with the URL, the dist type and the version's publish time. The time follows the minified format's field inheritance.
  • handleDownload answers 404 for a version in cooldown before fetching its archive, using the existing shouldFilterVersion.
  • The download lookup reads metadata through ReadMetadata, so it has the same size limit as other metadata reads.

Testing

  • New TestComposerDownloadCooldown, which requests /files/... directly with a 3-day cooldown and minified metadata. Before the fix, the recent version and a version that inherits its time both returned 200 and were fetched upstream. Now both return 404 without an upstream archive request, and an older version still downloads.
  • go test -race ./internal/handler/..., go vet and golangci-lint v2.13.1 pass.

Cooldown only filtered the metadata. A composer.lock names the proxy's
/files URL directly, so `composer install` fetched versions still inside
the cooldown window without ever seeing the filtered metadata. npm already
checks the publish time on tarball downloads.

- Return the version's publish time with its dist URL, following the
  minified format's inheritance
- Answer 404 for a version in cooldown before fetching its archive
- Read the download lookup's metadata through ReadMetadata, so it has the
  same size limit as other metadata reads
@andrew
andrew merged commit ab413e8 into git-pkgs:main Oct 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants