Repository navigation
Conversation
Part of git-pkgs#501. The sparse index filter, the pubtime lookup for downloads, the index path and the config.json download template move out of internal/handler into internal/metadata/cargo, which takes its policy, evaluation time and callbacks in Options and doesn't depend on handler.Proxy. The handler keeps fetching, writing the response, logging and recording withheld versions, with its method names as thin wrappers. Cooldown is checked with Evaluate at one EvaluatedAt per index instead of IsAllowed per entry, as in internal/metadata/npm. TestCooldownSupportedCoversHandlers also reads internal/metadata, where the cargo cooldown check now is.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 45 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Part of #501, the Cargo step.
As in #612 for npm, the Cargo metadata transformations move out of
internal/handlerintointernal/metadata/cargo:Filter: leaves out of a sparse index the entries the denylist names and those cooldown holds back by theirpubtime; entries without a readablepubtimeare kept, and lines that aren't JSON entries are left out, as beforePublishTime, which reads a version'spubtimefor a download and reports whether the index lists itIndexPathandDownloadTemplate(theconfig.jsondlvalue)The package takes its inputs explicitly in
Options: the cooldown policy, the time cooldown is evaluated at, and a denylist check. It reports versions cooldown holds back throughOnWithheldand unreadable lines throughOnInvalidEntry, which the handler logs and records as before. It doesn't depend onhandler.Proxy.What stays in the handler: fetching, writing the response, downloads and their cooldown check.
applyCooldownFiltering,buildIndexPathandpublishTimestay as thin wrappers, so the handler tests run unchanged against the real routes.Cooldown in the filter is checked with
Evaluateat oneEvaluatedAtinstead ofIsAllowedper entry, as ininternal/metadata/npm. The handler passestime.Now(), so results are the same unless a filter runs across a cooldown boundary. The filtered index is built and written once instead of line by line. The cooldown log'spublishedfield is the parsed time in RFC 3339, which differs from the rawpubtimeonly for fractional seconds.TestCooldownSupportedCoversHandlersnow also readsinternal/metadata, since that is where the Cargo cooldown check is now. It's the same change as in #804, so the two merge cleanly in either order.Portability:
GOOS=wasip1 GOARCH=wasm go build ./internal/metadata/cargoworks.imports_test.gofails on any non-standard import outside an allowlist (cooldown, purl, vers, packageurl-go,internal/packageurl) and onnet,net/http,log/slogordatabase/sql.New tests in
internal/metadata/cargocover cooldown evaluated atEvaluatedAt, entries without or with an unreadablepubtime, the denylist with and without a policy, a disabled policy, invalid lines, long entries, thepubtimelookup and the index paths. They were mutation-checked, as was the handler's wiring. There are no Cargo benchmarks to compare.go test ./...andgolangci-lint run ./...pass.