feat: auto-enable SLSA L3 features when provenance.slsa is true#250
Merged
feat: auto-enable SLSA L3 features when provenance.slsa is true#250
provenance.slsa is true#250Conversation
4490897 to
3facf99
Compare
geropl
reviewed
Oct 22, 2025
204cd66 to
43f6e96
Compare
SUMMARY When provenance.slsa: true is configured in WORKSPACE.yaml, automatically enable all SLSA L3 runtime features to ensure build integrity and supply chain security. FEATURES Automatically enables when provenance.slsa: true: - Cache verification (LEEWAY_SLSA_CACHE_VERIFICATION=true) - In-flight checksums (LEEWAY_ENABLE_IN_FLIGHT_CHECKSUMS=true) - Docker export mode (LEEWAY_DOCKER_EXPORT_TO_CACHE=true) - Source URI (LEEWAY_SLSA_SOURCE_URI from Git origin) PRECEDENCE HIERARCHY Implements 5-layer precedence for Docker export mode: 1. CLI flag (--docker-export-to-cache) - highest priority 2. User environment variable (set before workspace loading) 3. Package config (exportToCache in BUILD.yaml) 4. Workspace default (auto-set by provenance.slsa: true) 5. Global default (false - legacy behavior) BREAKING CHANGES - ExportToCache field changed from bool to *bool in DockerPkgConfig - Enables pointer-based detection: nil (not set) vs false (explicit) - Allows package-level overrides of workspace SLSA defaults ARTIFACT DISTINGUISHABILITY Artifacts built with SLSA enabled include "provenance: version=3 slsa" in their manifest, changing the version hash. This ensures SLSA L3 artifacts are automatically distinguishable from legacy artifacts in the cache, preventing collision and enabling proper verification. BACKWARD COMPATIBILITY Fully backward compatible: - Existing workspaces without provenance.slsa continue working unchanged - Explicit environment variables take precedence over auto-set values - Package-level exportToCache config still respected - All existing tests updated and passing DOCUMENTATION - Fixed SLSA version reference (v0.1 → v0.2) - Added "Automatic SLSA L3 Feature Activation" section - Added configuration precedence documentation - Added 4 usage scenarios with examples - Added troubleshooting guidance TESTING - 16 new test scenarios covering all precedence layers - TestDockerExport_PrecedenceHierarchy: 11 scenarios - TestWorkspace_ApplySLSADefaults: 5 scenarios - All existing tests updated for pointer-based config - Smoke test verified in real workspace Co-authored-by: Ona <no-reply@ona.com>
3facf99 to
edd432e
Compare
- Extract precedence logic from buildDocker into determineDockerExportMode - Improves code readability and maintainability - Makes the 5-layer precedence hierarchy more testable - No functional changes, pure refactoring Co-authored-by: Ona <no-reply@ona.com>
csweichel
approved these changes
Oct 24, 2025
aledbf
reviewed
Oct 24, 2025
aledbf
approved these changes
Oct 24, 2025
Contributor
|
@leodido can you make all those env vars like LEEWAY_DOCKER_EXPORT_TO_CACHE a constant? |
Define constants for all LEEWAY_* environment variables to prevent typos and improve maintainability. This follows the existing pattern established in the codebase. Changes: - Add EnvvarDockerExportToCache, EnvvarDefaultCacheLevel, EnvvarSegmentKey, EnvvarTrace, EnvvarProvenanceKeypath, and EnvvarExperimental to cmd/root.go - Add EnvvarDockerExportToCache and EnvvarWorkspaceRoot to pkg/leeway/build.go - Add EnvvarSLSACacheVerification, EnvvarSLSASourceURI, and EnvvarEnableInFlightChecksums to pkg/leeway/workspace.go - Replace all string literal usages with constants across codebase - Update test files to use constants with leeway. package prefix Co-authored-by: Ona <no-reply@ona.com>
The determineDockerExportMode() function always sets cfg.ExportToCache to a non-nil value before these conditions are evaluated, making the nil checks unreachable dead code. Simplified: - Line 1958: (cfg.ExportToCache == nil || !*cfg.ExportToCache) → !*cfg.ExportToCache - Line 2015: cfg.ExportToCache != nil && *cfg.ExportToCache → *cfg.ExportToCache Co-authored-by: Ona <no-reply@ona.com>
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.
Description
This PR implements automatic SLSA Level 3 feature activation when
provenance.slsa: trueis configured in WORKSPACE.yaml.Problem
Previously, SLSA L3 features required manual configuration of multiple environment variables:
provenance.slsa: trueonly enabled metadata generation, not runtime featuresSolution
When
provenance.slsa: trueis set, automatically enable:LEEWAY_SLSA_CACHE_VERIFICATION=true)LEEWAY_ENABLE_IN_FLIGHT_CHECKSUMS=true)LEEWAY_DOCKER_EXPORT_TO_CACHE=true)LEEWAY_SLSA_SOURCE_URIfrom Git origin)Key Changes
1. Workspace Auto-Enablement
2. Five-Layer Precedence for Docker Export
3. Package-Level Override
4. Artifact Distinguishability
Artifacts built with SLSA include
provenance: version=3 slsain manifest, ensuring different cache keys than legacy builds.Technical Changes
ExportToCache bool→ExportToCache *bool(distinguishes "not set" from "explicitly false")ApplySLSADefaults()in workspace loadingbuildDocker()Usage Examples
Enable SLSA L3 globally:
Package opts out:
User override for testing:
export LEEWAY_DOCKER_EXPORT_TO_CACHE=false leeway build :backendCLI override:
Backward Compatibility
✅ 100% backward compatible:
provenance.slsa: trueunchangedRelated Issue(s)
Fixes https://linear.app/ona-team/issue/CLC-2018/implement-slsa-l3-workspace-driven-auto-enablement-leeway
How to test
1. Verify Auto-Enablement
2. Test Precedence Layers
3. Test Artifact Distinguishability
4. Run Tests
Expected: 16 new test scenarios, all passing
5. Test Backward Compatibility
Documentation
/hold