Skip to content

fix: Use sigstore-go TUF client for delegation-aware target retrieval#1947

Merged
hectorj2f merged 1 commit intosigstore:mainfrom
k4leung4:fix-tuf-delegation-lookup
Mar 26, 2026
Merged

fix: Use sigstore-go TUF client for delegation-aware target retrieval#1947
hectorj2f merged 1 commit intosigstore:mainfrom
k4leung4:fix-tuf-delegation-lookup

Conversation

@k4leung4
Copy link
Copy Markdown
Member

@k4leung4 k4leung4 commented Mar 23, 2026

Summary

Refactor TUF client usage to use sigstore-go's tuf.Client for target retrieval, which correctly traverses TUF delegations.

  • Introduce TUFClient wrapper providing:
    • GetTarget(): delegates to sigstore-go tuf.Client (delegation-aware)
    • GetTopLevelTargets(): lazy-initialized raw go-tuf v2 updater (legacy fallback only)
  • The raw updater for GetTopLevelTargets is lazily initialized on first call, avoiding a double TUF metadata refresh when only GetTarget is needed (the common trusted_root.json path)
  • GetTarget errors are properly distinguished: "not found" falls through to the legacy custom metadata path, while other errors (network, hash mismatch, corruption) are propagated immediately
  • ClientFromSerializedMirror and ClientFromRemote now return *TUFClient
  • Remove downloadTarget helper — replaced by tufClient.GetTarget()

Based on feedback from sigstore/sigstore-go#602.

Test plan

  • go build ./... passes
  • go test ./... passes (all 14 test packages)
  • gofmt clean
  • golangci-lint — no new issues
  • Existing tests updated to use new TUFClient API

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.32%. Comparing base (49e26b2) to head (771bc40).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
pkg/tuf/repo.go 86.00% 6 Missing and 1 partial ⚠️
pkg/reconciler/trustroot/trustroot.go 50.00% 3 Missing and 2 partials ⚠️
pkg/apis/policy/v1alpha1/trustroot_validation.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1947      +/-   ##
==========================================
+ Coverage   29.98%   30.32%   +0.33%     
==========================================
  Files         122      122              
  Lines        7323     7354      +31     
==========================================
+ Hits         2196     2230      +34     
+ Misses       4894     4892       -2     
+ Partials      233      232       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@k4leung4 k4leung4 force-pushed the fix-tuf-delegation-lookup branch from dfb0436 to 328321f Compare March 23, 2026 16:55
@k4leung4 k4leung4 changed the title fix: Use GetTargetInfo for trusted root lookup to support TUF delegations fix: Use sigstore-go TUF client for delegation-aware target retrieval Mar 23, 2026
Refactor TUF client usage to use sigstore-go's tuf.Client for target
retrieval (GetTarget), which correctly traverses TUF delegations.

Introduce TUFClient wrapper that provides:
- GetTarget(): delegates to sigstore-go tuf.Client (delegation-aware)
- GetTopLevelTargets(): lazy-initialized raw go-tuf v2 updater (legacy)

The raw updater for GetTopLevelTargets is lazily initialized on first
call, avoiding a double TUF metadata refresh for the common path where
only GetTarget is needed (trusted_root.json lookup).

GetTarget errors are now properly distinguished: "not found" falls
through to the legacy custom metadata path, while other errors (network,
hash mismatch, corruption) are propagated immediately.

Based on feedback from sigstore/sigstore-go#602.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Kenny Leung <kleung@chainguard.dev>
@k4leung4 k4leung4 force-pushed the fix-tuf-delegation-lookup branch from 328321f to 771bc40 Compare March 23, 2026 17:31
@k4leung4 k4leung4 marked this pull request as ready for review March 23, 2026 17:43
@hectorj2f hectorj2f merged commit cc75baa into sigstore:main Mar 26, 2026
95 checks passed
@github-actions github-actions Bot added this to the v1 milestone Mar 26, 2026
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