From 709b72a70e1bb18b6fa748d367482fc3616f4361 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Fri, 12 May 2023 10:46:35 +0100 Subject: [PATCH] attestations: replace intoto media type with vendored const We were using a mixture of own custom const and the vendored const. For consistency, we should use only the vendored const everywhere. Signed-off-by: Justin Chadwell --- exporter/containerimage/writer.go | 2 +- solver/llbsolver/solver.go | 4 ++-- util/attestation/types.go | 2 -- util/imageutil/config.go | 4 ++-- util/push/push.go | 3 +-- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/exporter/containerimage/writer.go b/exporter/containerimage/writer.go index 9feb70127..2ace16f90 100644 --- a/exporter/containerimage/writer.go +++ b/exporter/containerimage/writer.go @@ -437,7 +437,7 @@ func (ic *ImageWriter) commitAttestationsManifest(ctx context.Context, opts *Ima } digest := digest.FromBytes(data) desc := ocispecs.Descriptor{ - MediaType: attestationTypes.MediaTypeDockerSchema2AttestationType, + MediaType: intoto.PayloadType, Digest: digest, Size: int64(len(data)), Annotations: map[string]string{ diff --git a/solver/llbsolver/solver.go b/solver/llbsolver/solver.go index efac859bd..3252982b0 100644 --- a/solver/llbsolver/solver.go +++ b/solver/llbsolver/solver.go @@ -9,6 +9,7 @@ import ( "sync" "time" + intoto "github.com/in-toto/in-toto-golang/in_toto" slsa02 "github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/v0.2" controlapi "github.com/moby/buildkit/api/services/control" "github.com/moby/buildkit/cache" @@ -26,7 +27,6 @@ import ( "github.com/moby/buildkit/solver/llbsolver/provenance" "github.com/moby/buildkit/solver/result" spb "github.com/moby/buildkit/sourcepolicy/pb" - "github.com/moby/buildkit/util/attestation" "github.com/moby/buildkit/util/bklog" "github.com/moby/buildkit/util/compression" "github.com/moby/buildkit/util/entitlements" @@ -210,7 +210,7 @@ func (s *Solver) recordBuildHistory(ctx context.Context, id string, req frontend if err != nil { return nil, nil, err } - w, err := s.history.OpenBlobWriter(ctx, attestation.MediaTypeDockerSchema2AttestationType) + w, err := s.history.OpenBlobWriter(ctx, intoto.PayloadType) if err != nil { return nil, nil, err } diff --git a/util/attestation/types.go b/util/attestation/types.go index 35f4404cd..accccd307 100644 --- a/util/attestation/types.go +++ b/util/attestation/types.go @@ -1,8 +1,6 @@ package attestation const ( - MediaTypeDockerSchema2AttestationType = "application/vnd.in-toto+json" - DockerAnnotationReferenceType = "vnd.docker.reference.type" DockerAnnotationReferenceDigest = "vnd.docker.reference.digest" DockerAnnotationReferenceDescription = "vnd.docker.reference.description" diff --git a/util/imageutil/config.go b/util/imageutil/config.go index 76e0a5da3..d7bf6b6a1 100644 --- a/util/imageutil/config.go +++ b/util/imageutil/config.go @@ -13,7 +13,7 @@ import ( "github.com/containerd/containerd/reference" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" - "github.com/moby/buildkit/util/attestation" + intoto "github.com/in-toto/in-toto-golang/in_toto" "github.com/moby/buildkit/util/contentutil" "github.com/moby/buildkit/util/leaseutil" "github.com/moby/buildkit/util/resolver/limited" @@ -174,7 +174,7 @@ func childrenConfigHandler(provider content.Provider, platform platforms.MatchCo descs = append(descs, index.Manifests...) } case images.MediaTypeDockerSchema2Config, ocispecs.MediaTypeImageConfig, docker.LegacyConfigMediaType, - attestation.MediaTypeDockerSchema2AttestationType: + intoto.PayloadType: // childless data types. return nil, nil default: diff --git a/util/push/push.go b/util/push/push.go index 72415171b..8ccbae3ee 100644 --- a/util/push/push.go +++ b/util/push/push.go @@ -15,7 +15,6 @@ import ( "github.com/containerd/containerd/remotes/docker" "github.com/docker/distribution/reference" "github.com/moby/buildkit/session" - "github.com/moby/buildkit/util/attestation" "github.com/moby/buildkit/util/bklog" "github.com/moby/buildkit/util/flightcontrol" "github.com/moby/buildkit/util/imageutil" @@ -250,7 +249,7 @@ func childrenHandler(provider content.Provider) images.HandlerFunc { case images.MediaTypeDockerSchema2Layer, images.MediaTypeDockerSchema2LayerGzip, images.MediaTypeDockerSchema2Config, ocispecs.MediaTypeImageConfig, ocispecs.MediaTypeImageLayer, ocispecs.MediaTypeImageLayerGzip, - attestation.MediaTypeDockerSchema2AttestationType: + intoto.PayloadType: // childless data types. return nil, nil default: