Skip to content

Commit 855534d

Browse files
authored
feat(attestation): add tag to container image attestation (#747)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent c736f90 commit 855534d

File tree

8 files changed

+117
-78
lines changed

8 files changed

+117
-78
lines changed

app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/attestation/crafter/api/attestation/v1/crafting_state.pb.go

Lines changed: 82 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/attestation/crafter/api/attestation/v1/crafting_state.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ message Attestation {
6262
string name = 2 [(buf.validate.field).string.min_len = 1];
6363
string digest = 3 [(buf.validate.field).string.min_len = 1];
6464
bool is_subject = 4;
65+
// provided tag
66+
string tag = 5;
6567
}
6668

6769
message Artifact {

internal/attestation/crafter/materials/oci_image.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -65,6 +65,7 @@ func (i *OCIImageCrafter) Craft(_ context.Context, imageRef string) (*api.Attest
6565
M: &api.Attestation_Material_ContainerImage_{
6666
ContainerImage: &api.Attestation_Material_ContainerImage{
6767
Id: i.input.Name, Name: repoName, Digest: remoteRef.DigestStr(), IsSubject: i.input.Output,
68+
Tag: ref.Identifier(),
6869
},
6970
},
7071
}, nil

internal/attestation/renderer/chainloop/chainloop.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -219,6 +219,7 @@ var (
219219
AnnotationMaterialName = prefixed("material.name")
220220
AnnotationMaterialCAS = prefixed("material.cas")
221221
annotationMaterialInlineCAS = prefixed("material.cas.inline")
222+
annotationContainerTag = prefixed("material.image.tag")
222223
)
223224

224225
func prefixed(name string) string {

internal/attestation/renderer/chainloop/testdata/attestation.output-2.v0.2.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "chainloop.workflow.test-new-types",
66
"digest": {
7-
"sha256": "524b370dd444326d8150f5a8176bd4d57bb2052a1b77471d1fcb9fcc0983c958"
7+
"sha256": "f468a33a5a4ae153c1c50949b771b6dd9034f663bf00a5fdfbef73f03886a8e1"
88
}
99
},
1010
{
@@ -31,6 +31,7 @@
3131
"sha256": "fbd9335f55d83d8aaf9ab1a539b0f2a87b444e8c54f34c9a1ca9d7df15605db4"
3232
},
3333
"annotations": {
34+
"chainloop.material.image.tag": "devel",
3435
"chainloop.material.name": "image",
3536
"chainloop.material.type": "CONTAINER_IMAGE"
3637
}
@@ -45,6 +46,7 @@
4546
"materials": [
4647
{
4748
"annotations": {
49+
"chainloop.material.image.tag": "devel",
4850
"chainloop.material.name": "image",
4951
"chainloop.material.type": "CONTAINER_IMAGE"
5052
},

internal/attestation/renderer/chainloop/testdata/attestation.source-2.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"id": "image",
4343
"name": "index.docker.io/bitnami/nginx",
4444
"digest": "sha256:fbd9335f55d83d8aaf9ab1a539b0f2a87b444e8c54f34c9a1ca9d7df15605db4",
45-
"isSubject": true
45+
"isSubject": true,
46+
"tag": "devel"
4647
},
4748
"addedAt": "2023-10-20T12:57:52.459112368Z",
4849
"materialType": "CONTAINER_IMAGE"

internal/attestation/renderer/chainloop/v02.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -213,6 +213,13 @@ func outputMaterials(att *v1.Attestation, onlyOutput bool) ([]*intoto.ResourceDe
213213
AnnotationMaterialName: mdefName,
214214
}
215215

216+
// Set the special annotations for container images
217+
if artifactType == schemaapi.CraftingSchema_Material_CONTAINER_IMAGE {
218+
if tag := mdef.GetContainerImage().GetTag(); tag != "" {
219+
annotationsM[annotationContainerTag] = tag
220+
}
221+
}
222+
216223
// Custom annotations, it does not override the built-in ones
217224
for k, v := range mdef.Annotations {
218225
_, ok := annotationsM[k]

0 commit comments

Comments
 (0)