Normalize cooldown package PURL overrides#201
Merged
Conversation
NormalizedPackages runs config keys through purl.Parse().String(), which applies per-type rules like lowercasing pypi names. The handler side was building lookup keys with MakePURLString, which does not, so a config entry for pkg:pypi/Django would be normalized to pkg:pypi/django and never match the runtime key pkg:pypi/Django. Route both sides through the same canonical form: a new canonicalPackagePURL helper calls Normalize() on the constructed PURL before stringifying, and all cooldown IsAllowed call sites use it.
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.
Per-package cooldown overrides keyed by PURL were matched by exact string equality, so
pkg:npm/@typescript/typescript-darwin-arm64in config never matched the%40-encoded key the npm handler builds at runtime.Both sides now go through the same PURL canonicalisation: config keys are parsed and re-serialised, and handlers build lookup keys via a helper that calls
Normalize()on the constructed PURL. This also makes case-insensitive ecosystems behave sensibly, sopkg:pypi/Djangoandpkg:pypi/djangorefer to the same override.When two config keys normalize to the same package, the canonical form wins; invalid PURLs are left as written.
Fixes #197