-
Notifications
You must be signed in to change notification settings - Fork 20
fix: upload and download provenance bundles in S3 cache #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Integration Tests AddedAdded comprehensive integration tests in Test Coverage
Test ResultsAll existing remote cache tests continue to pass (59.7s total runtime). |
0c347c7 to
1843ce1
Compare
62f47a2 to
4245a86
Compare
1843ce1 to
372a050
Compare
4245a86 to
bb687dd
Compare
Fixed: Backward Compatibility for Missing Provenance Bundles✅ Added graceful degradation for artifacts built before v0.15.0-rc4. ProblemArtifacts built before v0.15.0-rc4 don't have SolutionModified
Key Features✅ Security maintained: SLSA attestation verification still works Tracking
Testing
CommitThis fix enables smooth transition to external provenance storage without breaking existing builds. |
c594a2c to
7b2010c
Compare
geropl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests and Code LGTM! ✔️
When building packages with SLSA enabled, provenance bundles are stored alongside artifacts as <artifact>.provenance.jsonl. These bundles are needed for dependency provenance collection during local builds. Previously, only the artifact (.tar.gz) and attestation (.tar.gz.att) were uploaded/downloaded from S3, causing builds to fail with: "error accessing provenance bundle: no attestation bundle found" This fix: - Uploads .provenance.jsonl files alongside artifacts (non-blocking) - Downloads .provenance.jsonl files after SLSA verification (best effort) - Gracefully handles missing provenance for backward compatibility The provenance download is non-critical and logs a debug message if missing, allowing older artifacts without provenance to work correctly. Fixes dependency provenance collection for SLSA L3 compliant builds. Co-authored-by: Ona <no-reply@ona.com>
Extract provenance upload/download logic into dedicated helper functions with improved error handling and verification: uploadProvenanceBundle(): - Checks if provenance file exists before attempting upload - Proper rate limiting and timeout handling - Non-blocking operation with clear logging - Returns early on any error to avoid cascading failures downloadProvenanceBundle(): - Rate limiting and timeout protection - Verifies downloaded file exists and has content - Atomic move to final location - Returns bool to indicate success/failure - Graceful handling of missing provenance (expected for older artifacts) Benefits: - Better separation of concerns - More robust error handling - Easier to test and maintain - Clear success/failure indicators - Improved logging at each step Co-authored-by: Ona <no-reply@ona.com>
Add integration tests for provenance bundle upload/download functionality: TestS3Cache_ProvenanceUpload: - Successful upload with valid provenance - Skip upload when provenance file missing - Handle empty provenance files TestS3Cache_ProvenanceDownload: - Successful download with content verification - Backward compatibility (missing provenance) - Empty file detection and rejection TestS3Cache_ProvenanceRoundTrip: - End-to-end upload and download - Content integrity verification TestS3Cache_ProvenanceAtomicMove: - Atomic file operations - Temporary file cleanup - No leftover .tmp files All tests pass and verify: - Non-blocking behavior - Proper error handling - File integrity checks - Backward compatibility - Atomic operations Co-authored-by: Ona <no-reply@ona.com>
When artifacts built before v0.15.0-rc4 are used as dependencies, they don't have .provenance.jsonl files, causing builds to fail with 'no attestation bundle found' error. This fix adds graceful degradation: - Detects missing provenance bundles (ErrNoAttestationBundle) - Logs warning instead of failing the build - Allows gradual cache population during transition period - Maintains SLSA attestation verification (security not compromised) The fallback is temporary and should be removed after all cached artifacts have provenance bundles (estimated 4 weeks). Tracking: #293 Co-authored-by: Ona <no-reply@ona.com>
48e8cdf to
72c405f
Compare
Implements the test for TestGetDependenciesProvenanceBundles_MissingProvenance that was previously skipped with a TODO. The test verifies backward compatibility when dependency provenance bundles are missing (artifacts built before v0.15.0-rc5): 1. Tests that missing provenance returns ErrNoAttestationBundle 2. Tests that existing provenance is read correctly 3. Documents the backward compatibility mechanism This validates the error detection that enables getDependenciesProvenanceBundles() to gracefully handle missing provenance with a warning instead of failing builds during the transition period. Co-authored-by: Ona <no-reply@ona.com>
Summary
This PR fixes the "no attestation bundle found" error when building packages with SLSA enabled. The issue occurs when a package downloaded from S3 remote cache is used as a dependency for a local build.
Problem
When building packages with SLSA enabled (Leeway v0.15.0-rc3), builds fail with:
Root Cause
After PR #283, provenance bundles were moved outside the
.tar.gzfile to maintain artifact determinism. However, the S3 cache implementation was not updated to handle these separate.provenance.jsonlfiles:Package A is downloaded from S3 with SLSA verification
<hash>.tar.gzand<hash>.tar.gz.att✅<hash>.tar.gz.provenance.jsonl❌Package B is built locally and needs Package A as a dependency
getDependenciesProvenanceBundles()to collect provenance/var/lib/leeway/cache/<hash>.tar.provenance.jsonlSolution
Modified
pkg/leeway/cache/remote/s3.goto:1. Upload Provenance Bundles
.provenance.jsonlexists2. Download Provenance Bundles
.provenance.jsonlFile Types
Three separate files with different purposes:
.tar.gz- The build artifact (deterministic).tar.gz.att- Sigstore Bundle v0.3 (SLSA attestation for verification).tar.gz.provenance.jsonl- In-toto v0.2 provenance bundle (for dependency provenance collection)Backward Compatibility
✅ Fully backward compatible:
Testing
Related
Checklist