Repository navigation
Refuse package mirroring from the CLI while scanning is enabled - #493
Open
abhinavgautam01 wants to merge 1 commit into
Open
abhinavgautam01 wants to merge 1 commit into
abhinavgautam01 wants to merge 1 commit into
Conversation
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.
Closes #478
Problem
With
scanning.enabled,proxy mirroralready refused container images and pointed at the mirror API, but packages from every other ecosystem were still fetched and cached.server.NewMirrorProxynever setsproxy.Scanners, so those artifacts skipped the pre-cache scan (handler.go:594).servethen served them from the cache as ordinary hits, so a proxy configured to scan everything could end up with unscanned artifacts in its cache.Turning scanning on for the CLI is not an option. Scanners pull the staged bytes from the running server through the signed
/_internal/scan-fetchURL and the CLI does not start a server.Changes
internal/mirror: newMirror.RefusePackagesfield. When set, every itemImagesdoes not take is recorded as failed with that reason and logged asmirror refused, without being fetched. Images still go toImagesfirst, so they keep their own refusal.cmd/proxy: the inline image check becomesrefuseUnscannedMirroring, which sets both refusals while scanning is enabled. Both reasons are named constants and the package one carries the same pointer to the mirror API as the image one:Docs: the README mirror section and the scanning section of
docs/configuration.mdnow explain the restriction. Neither mentioned it before, even for images.Unchanged:
--dry-runstill lists what would be mirrored, since it caches nothing.serveproxy and its scanner group.Example output with scanning enabled:
Mirror complete: 0 downloaded, 0 skipped (cached), 1 failed, 0 B total
Errors:
npm/lodash@4.17.21: packages cannot be mirrored by this command while scanning is enabled; use the mirror API of the running server
Tests
cmd/proxy/mirror_test.go(new): runs the realproxy mirrorcommand in a subprocess with a scanning-enabled config, as the issue asked.0 downloadedand1 failedand nothing is written to the database or to storage.--dry-runwith scanning enabled still lists the package.refuseUnscannedMirroringsets both refusals.internal/mirror/mirror_test.go:With the refusal disabled, the mirror test fails and lists the npm and crates.io URLs that would have been fetched.
go build,go vet,golangci-lint(v2.13.1),go test -race ./...and Swagger regeneration all pass locally.