You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(slsa): implement SLSA L3 auto-enablement with precedence hierarchy
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 <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+138-1Lines changed: 138 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -517,7 +517,7 @@ variables have an effect on leeway:
517
517
- `LEEWAY_EXPERIMENTAL`: Enables exprimental features
518
518
519
519
# Provenance (SLSA) - EXPERIMENTAL
520
-
leeway can produce provenance information as part of a build. At the moment only [SLSA](https://slsa.dev/spec/v0.1/) is supported. This supoprt is **experimental**.
520
+
leeway can produce provenance information as part of a build. At the moment only [SLSA Provenance v0.2](https://slsa.dev/provenance/v0.2) is supported. This support is **experimental**.
521
521
522
522
Provenance generation is enabled in the `WORKSPACE.YAML` file.
523
523
```YAML
@@ -528,6 +528,100 @@ provenance:
528
528
529
529
Once enabled, all packages carry an [attestation bundle](https://github.com/in-toto/attestation/blob/main/spec/bundle.md) which is compliant to the [SLSA v0.2 spec](https://slsa.dev/provenance/v0.2) in their cached archive. The bundle is complete, i.e. not only contains the attestation for the package build, but also those of its dependencies.
530
530
531
+
## Automatic SLSA L3 Feature Activation
532
+
533
+
When `provenance.slsa: true` is set, Leeway automatically enables all SLSA L3 runtime features to ensure build integrity and artifact distinguishability:
534
+
535
+
- ✅ **Cache verification**: Downloads are verified against Sigstore attestations
536
+
- ✅ **In-flight checksums**: Build artifacts are checksummed during the build to prevent tampering
537
+
- ✅ **Docker export mode**: Docker images go through the cache and signing flow (workspace default)
538
+
539
+
These features are automatically enabled by setting environment variables:
540
+
- `LEEWAY_SLSA_CACHE_VERIFICATION=true`
541
+
- `LEEWAY_ENABLE_IN_FLIGHT_CHECKSUMS=true`
542
+
- `LEEWAY_DOCKER_EXPORT_TO_CACHE=true`
543
+
- `LEEWAY_SLSA_SOURCE_URI`(set from Git origin)
544
+
545
+
### Configuration Precedence
546
+
547
+
The Docker export mode follows a clear precedence hierarchy (highest to lowest):
When SLSA provenance is enabled, the package manifest includes `provenance: version=3 slsa`, which changes the artifact version hash. This ensures artifacts built with SLSA L3 features are automatically distinguishable from legacy artifacts in the cache.
611
+
612
+
```yaml
613
+
# With SLSA enabled:
614
+
buildProcessVersion: 1
615
+
provenance: version=3 slsa # ← N.B.
616
+
sbom: version=1
617
+
environment: f92ccd7479251ffa...
618
+
619
+
# Without SLSA:
620
+
buildProcessVersion: 1
621
+
sbom: version=1
622
+
environment: f92ccd7479251ffa...
623
+
```
624
+
531
625
## Dirty vs clean Git working copy
532
626
When building from a clean Git working copy, leeway will use a reference to the Git remote origin as [material](https://github.com/in-toto/in-toto-golang/blob/26b6a96f8a7537f27b7483e19dd68e022b179ea6/in_toto/model.go#L360) (part of the SLSA [link](https://github.com/slsa-framework/slsa/blob/main/controls/attestations.md)).
- provenance is part of the leeway package version, i.e. when you enable provenance that will naturally invalidate previously built packages.
561
655
- if attestation bundle entries grow too large this can break the build process. Use `LEEWAY_MAX_PROVENANCE_BUNDLE_SIZE` to set the buffer size in bytes. This defaults to 2MiB. The larger this buffer is, the larger bundle entries can be used, but the more memory the build process will consume. If you exceed the default, inspect the bundles first (especially the one that fails to load) and see if the produced `subjects` make sense.
562
656
657
+
## Troubleshooting SLSA L3 Features
658
+
659
+
**Features not activating?**
660
+
661
+
Check if SLSA is properly enabled in your workspace:
**Environment variables set before workspace loading?**
688
+
689
+
User environment variables must be set BEFORE running leeway:
690
+
```bash
691
+
# Correct: set before running leeway
692
+
export LEEWAY_DOCKER_EXPORT_TO_CACHE=false
693
+
leeway build :package
694
+
695
+
# Incorrect: too late, workspace already loaded
696
+
leeway build :package
697
+
export LEEWAY_DOCKER_EXPORT_TO_CACHE=false
698
+
```
699
+
563
700
# Debugging
564
701
When a build fails, or to get an idea of how leeway assembles dependencies, run your build with `leeway build -c local` (local cache only) and inspect your `$LEEWAY_BUILD_DIR`.
0 commit comments