Skip to content

Commit 67c0095

Browse files
committed
provenance slsa v1
Signed-off-by: CrazyMax <[email protected]>
1 parent 1bd26bf commit 67c0095

File tree

31 files changed

+1990
-737
lines changed

31 files changed

+1990
-737
lines changed

control/control.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/moby/buildkit/solver/llbsolver"
3636
"github.com/moby/buildkit/solver/llbsolver/cdidevices"
3737
"github.com/moby/buildkit/solver/llbsolver/proc"
38+
provenancetypes "github.com/moby/buildkit/solver/llbsolver/provenance/types"
3839
"github.com/moby/buildkit/solver/pb"
3940
"github.com/moby/buildkit/util/bklog"
4041
"github.com/moby/buildkit/util/db"
@@ -508,7 +509,19 @@ func (c *Controller) Solve(ctx context.Context, req *controlapi.SolveRequest) (*
508509
}
509510

510511
if attrs, ok := attests["provenance"]; ok {
511-
procs = append(procs, proc.ProvenanceProcessor(attrs))
512+
var slsaVersion provenancetypes.ProvenanceSLSA
513+
params := make(map[string]string)
514+
for k, v := range attrs {
515+
if k == "version" {
516+
slsaVersion = provenancetypes.ProvenanceSLSA(v)
517+
if err := slsaVersion.Validate(); err != nil {
518+
return nil, err
519+
}
520+
} else {
521+
params[k] = v
522+
}
523+
}
524+
procs = append(procs, proc.ProvenanceProcessor(slsaVersion, params))
512525
}
513526

514527
resp, err := c.solver.Solve(ctx, req.Ref, req.Session, frontend.SolveRequest{

frontend/attestations/parse.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package attestations
33
import (
44
"strings"
55

6+
provenancetypes "github.com/moby/buildkit/solver/llbsolver/provenance/types"
67
"github.com/pkg/errors"
78
"github.com/tonistiigi/go-csvvalue"
89
)
@@ -14,6 +15,7 @@ const (
1415

1516
const (
1617
defaultSBOMGenerator = "docker/buildkit-syft-scanner:stable-1"
18+
defaultSLSAVersion = string(provenancetypes.ProvenanceSLSA02)
1719
)
1820

1921
func Filter(v map[string]string) map[string]string {
@@ -57,8 +59,11 @@ func Parse(values map[string]string) (map[string]map[string]string, error) {
5759
for k, v := range attests {
5860
attrs := make(map[string]string)
5961
out[k] = attrs
60-
if k == KeyTypeSbom {
62+
switch k {
63+
case KeyTypeSbom:
6164
attrs["generator"] = defaultSBOMGenerator
65+
case KeyTypeProvenance:
66+
attrs["version"] = defaultSLSAVersion
6267
}
6368
if v == "" {
6469
continue

frontend/attestations/parse_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ func TestParse(t *testing.T) {
2424
"generator": "docker.io/foo/bar",
2525
},
2626
"provenance": {
27-
"mode": "max",
27+
"mode": "max",
28+
"version": "v0.2",
2829
},
2930
},
3031
},

0 commit comments

Comments
 (0)