feat: registry proxy/mirror rewriting support#352
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 38 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis pull request introduces a proxy registry mapping feature to the SBOM adapter. The implementation adds a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Summary:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@adapters/v1/syft.go`:
- Around line 59-85: rewriteImageRef currently special-cases only exact keys
"docker.io" and "index.docker.io", so compound keys like "docker.io/library"
won't match "index.docker.io/library/..." and the rewrite is skipped; update
rewriteImageRef to normalize both the configured key and the incoming imageRef
when performing prefix checks (e.g., map "index.docker.io" to "docker.io" or
vice‑versa) before comparing prefixes: compute normalizedOriginal
(strings.ReplaceAll(original, "index.docker.io", "docker.io")) and normalizedRef
(strings.ReplaceAll(imageRef, "index.docker.io", "docker.io")) and use those for
the strings.HasPrefix checks while still returning the properly reconstructed
proxy URL using the original proxy value (proxy :=
strings.TrimRight(proxyMap[original], "/")) so compound keys like
"docker.io/library" correctly match "index.docker.io/library/...".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ff94c64a-3768-4ed8-805f-45a830e3c901
📒 Files selected for processing (4)
adapters/v1/syft.goadapters/v1/syft_test.gocmd/http/main.goconfig/config.go
|
Summary:
|
1 similar comment
|
Summary:
|
|
Summary:
|
Add proxyRegistryMap config field and rewriteImageRef helper so image pulls are redirected through a registry mirror while SBOM annotations retain the original image reference. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
- Sort proxy map keys by descending length so longest prefix always wins over a shorter one, making matching deterministic. - Skip entries with an empty proxy value to prevent malformed refs. - Strip trailing slashes from proxy values to prevent double-slash refs. - Warn when proxyRegistryMap is set but sidecar mode is active (map has no effect there). - Add TestRewriteImageRef covering all edge cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
Extend SidecarSBOMAdapter with proxyRegistryMap so the client-side ref rewrite also applies in sidecar mode. pullImageID/pullImageTag are computed after annotations are set, keeping the original refs in the SBOM metadata. Removes the now-unnecessary warning log. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
975a256 to
9d6b1ba
Compare
|
Summary:
|
Summary
proxyRegistryMap map[string]stringfield toConfig(mapstructure key:proxyRegistryMap) so operators can declare registry mirror mappings inclusterData.json.proxyRegistryMapfield toSyftAdapterand arewriteImageRefhelper that rewrites image pull references using simple string-prefix replacement, treatingdocker.ioandindex.docker.ioas equivalent.syft.GetSourcecall sites (initial pull, MANIFEST_UNKNOWN retry, 401 retry) use the rewrittenpullRef;imageID/imageTagvariables are untouched so SBOM annotations always record the original image reference.proxyRegistryMapis nil or empty, behaviour is identical to before.Test plan
go build ./...— passes with no errorsgo vet ./config/... ./cmd/...— cleango test ./adapters/v1/ -run TestNormalizeImageID— 6/6 passproxyRegistryMap: {"docker.io": "my-mirror.example.com"}in config and verify pulls are redirected🤖 Generated with Claude Code
Summary by CodeRabbit