From e103df62baabd4edff63d5d85fe80db6bd3924ee Mon Sep 17 00:00:00 2001 From: "Jose I. Paris" Date: Thu, 19 Dec 2024 00:39:34 +0100 Subject: [PATCH] chore(attestations): store contract name and version in attestation and referrer API (#1679) Signed-off-by: Jose I. Paris --- app/cli/internal/action/attestation_init.go | 1 + .../frontend/attestation/v1/crafting_state.ts | 16 ++++ ...tation.v1.WorkflowMetadata.jsonschema.json | 8 ++ ...ttestation.v1.WorkflowMetadata.schema.json | 8 ++ app/controlplane/internal/service/workflow.go | 1 + app/controlplane/pkg/biz/referrer.go | 10 +- .../pkg/biz/referrer_integration_test.go | 1 + app/controlplane/pkg/biz/referrer_test.go | 40 ++++---- .../api/attestation/v1/crafting_state.pb.go | 92 +++++++++++-------- .../api/attestation/v1/crafting_state.proto | 2 + .../renderer/chainloop/chainloop.go | 36 ++++---- .../testdata/attestation.output-2.v0.2.json | 2 + .../testdata/attestation.output.v0.2.json | 2 + 13 files changed, 143 insertions(+), 76 deletions(-) diff --git a/app/cli/internal/action/attestation_init.go b/app/cli/internal/action/attestation_init.go index c65addfeb..f771f8937 100644 --- a/app/cli/internal/action/attestation_init.go +++ b/app/cli/internal/action/attestation_init.go @@ -126,6 +126,7 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun Project: workflow.GetProject(), Team: workflow.GetTeam(), SchemaRevision: strconv.Itoa(int(contractVersion.GetRevision())), + ContractName: workflow.ContractName, } if opts.ProjectVersion != "" { diff --git a/app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts b/app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts index df099bed9..c264f28e7 100644 --- a/app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts +++ b/app/controlplane/api/gen/frontend/attestation/v1/crafting_state.ts @@ -238,6 +238,8 @@ export interface WorkflowMetadata { /** Not required since we might be doing a dry-run */ workflowRunId: string; schemaRevision: string; + /** contract name (contract version is "schema_revision") */ + contractName: string; /** organization name */ organization: string; } @@ -2514,6 +2516,7 @@ function createBaseWorkflowMetadata(): WorkflowMetadata { workflowId: "", workflowRunId: "", schemaRevision: "", + contractName: "", organization: "", }; } @@ -2544,6 +2547,9 @@ export const WorkflowMetadata = { if (message.schemaRevision !== "") { writer.uint32(58).string(message.schemaRevision); } + if (message.contractName !== "") { + writer.uint32(90).string(message.contractName); + } if (message.organization !== "") { writer.uint32(66).string(message.organization); } @@ -2613,6 +2619,13 @@ export const WorkflowMetadata = { message.schemaRevision = reader.string(); continue; + case 11: + if (tag !== 90) { + break; + } + + message.contractName = reader.string(); + continue; case 8: if (tag !== 66) { break; @@ -2639,6 +2652,7 @@ export const WorkflowMetadata = { workflowId: isSet(object.workflowId) ? String(object.workflowId) : "", workflowRunId: isSet(object.workflowRunId) ? String(object.workflowRunId) : "", schemaRevision: isSet(object.schemaRevision) ? String(object.schemaRevision) : "", + contractName: isSet(object.contractName) ? String(object.contractName) : "", organization: isSet(object.organization) ? String(object.organization) : "", }; }, @@ -2654,6 +2668,7 @@ export const WorkflowMetadata = { message.workflowId !== undefined && (obj.workflowId = message.workflowId); message.workflowRunId !== undefined && (obj.workflowRunId = message.workflowRunId); message.schemaRevision !== undefined && (obj.schemaRevision = message.schemaRevision); + message.contractName !== undefined && (obj.contractName = message.contractName); message.organization !== undefined && (obj.organization = message.organization); return obj; }, @@ -2674,6 +2689,7 @@ export const WorkflowMetadata = { message.workflowId = object.workflowId ?? ""; message.workflowRunId = object.workflowRunId ?? ""; message.schemaRevision = object.schemaRevision ?? ""; + message.contractName = object.contractName ?? ""; message.organization = object.organization ?? ""; return message; }, diff --git a/app/controlplane/api/gen/jsonschema/attestation.v1.WorkflowMetadata.jsonschema.json b/app/controlplane/api/gen/jsonschema/attestation.v1.WorkflowMetadata.jsonschema.json index ab4473f20..de73e4fb9 100644 --- a/app/controlplane/api/gen/jsonschema/attestation.v1.WorkflowMetadata.jsonschema.json +++ b/app/controlplane/api/gen/jsonschema/attestation.v1.WorkflowMetadata.jsonschema.json @@ -3,6 +3,10 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": false, "patternProperties": { + "^(contract_name)$": { + "description": "contract name (contract version is \"schema_revision\")", + "type": "string" + }, "^(project_version)$": { "description": "kept for backwards compatibility with remote state storage", "type": "string" @@ -18,6 +22,10 @@ } }, "properties": { + "contractName": { + "description": "contract name (contract version is \"schema_revision\")", + "type": "string" + }, "name": { "type": "string" }, diff --git a/app/controlplane/api/gen/jsonschema/attestation.v1.WorkflowMetadata.schema.json b/app/controlplane/api/gen/jsonschema/attestation.v1.WorkflowMetadata.schema.json index cddb5abca..14244e5a7 100644 --- a/app/controlplane/api/gen/jsonschema/attestation.v1.WorkflowMetadata.schema.json +++ b/app/controlplane/api/gen/jsonschema/attestation.v1.WorkflowMetadata.schema.json @@ -3,6 +3,10 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": false, "patternProperties": { + "^(contractName)$": { + "description": "contract name (contract version is \"schema_revision\")", + "type": "string" + }, "^(projectVersion)$": { "description": "kept for backwards compatibility with remote state storage", "type": "string" @@ -18,6 +22,10 @@ } }, "properties": { + "contract_name": { + "description": "contract name (contract version is \"schema_revision\")", + "type": "string" + }, "name": { "type": "string" }, diff --git a/app/controlplane/internal/service/workflow.go b/app/controlplane/internal/service/workflow.go index 50123321a..9048303ee 100644 --- a/app/controlplane/internal/service/workflow.go +++ b/app/controlplane/internal/service/workflow.go @@ -239,6 +239,7 @@ func bizWorkflowToPb(wf *biz.Workflow) *pb.WorkflowItem { Id: wf.ID.String(), Name: wf.Name, CreatedAt: timestamppb.New(*wf.CreatedAt), Project: wf.Project, Team: wf.Team, RunsCount: int32(wf.RunsCounter), Public: wf.Public, Description: wf.Description, ContractRevisionLatest: int32(wf.ContractRevisionLatest), + ContractName: wf.ContractName, } if wf.ContractID != uuid.Nil { diff --git a/app/controlplane/pkg/biz/referrer.go b/app/controlplane/pkg/biz/referrer.go index 3d1524273..d1a965079 100644 --- a/app/controlplane/pkg/biz/referrer.go +++ b/app/controlplane/pkg/biz/referrer.go @@ -280,10 +280,12 @@ func extractReferrers(att *dsse.Envelope, repo ReferrerRepo) ([]*Referrer, error attestationReferrer.Annotations = predicate.GetAnnotations() attestationReferrer.Metadata = map[string]string{ // workflow name, team and project - "name": predicate.GetMetadata().Name, - "team": predicate.GetMetadata().Team, - "project": predicate.GetMetadata().Project, - "organization": predicate.GetMetadata().Organization, + "name": predicate.GetMetadata().Name, + "team": predicate.GetMetadata().Team, + "project": predicate.GetMetadata().Project, + "organization": predicate.GetMetadata().Organization, + "contractName": predicate.GetMetadata().ContractName, + "contractVersion": predicate.GetMetadata().ContractVersion, } // Create new referrers for each material diff --git a/app/controlplane/pkg/biz/referrer_integration_test.go b/app/controlplane/pkg/biz/referrer_integration_test.go index a212a4827..f799e8588 100644 --- a/app/controlplane/pkg/biz/referrer_integration_test.go +++ b/app/controlplane/pkg/biz/referrer_integration_test.go @@ -243,6 +243,7 @@ func (s *referrerIntegrationTestSuite) TestExtractAndPersists() { s.Equal(wantReferrerAtt.Kind, got.Kind) // It has metadata s.Equal(map[string]string{ + "contractName": "", "contractVersion": "", "name": "test-new-types", "project": "test", "team": "my-team", diff --git a/app/controlplane/pkg/biz/referrer_test.go b/app/controlplane/pkg/biz/referrer_test.go index 5c28538c2..1e7dbf641 100644 --- a/app/controlplane/pkg/biz/referrer_test.go +++ b/app/controlplane/pkg/biz/referrer_test.go @@ -109,10 +109,12 @@ func (s *referrerTestSuite) TestExtractReferrers() { Kind: "ATTESTATION", Downloadable: true, Metadata: map[string]string{ - "name": "only-sbom", - "organization": "", - "team": "", - "project": "foo", + "contractName": "", + "contractVersion": "", + "name": "only-sbom", + "organization": "", + "team": "", + "project": "foo", }, Annotations: map[string]string{ "branch": "stable", @@ -158,10 +160,12 @@ func (s *referrerTestSuite) TestExtractReferrers() { }, }, Metadata: map[string]string{ - "name": "test", - "organization": "", - "team": "", - "project": "bar", + "contractName": "", + "contractVersion": "", + "name": "test", + "organization": "", + "team": "", + "project": "bar", }, Annotations: map[string]string{ "version": "oss", @@ -189,10 +193,12 @@ func (s *referrerTestSuite) TestExtractReferrers() { Kind: "ATTESTATION", Downloadable: true, Metadata: map[string]string{ - "name": "only-sbom", - "organization": "", - "team": "", - "project": "foo", + "contractName": "", + "contractVersion": "", + "name": "only-sbom", + "organization": "", + "team": "", + "project": "foo", }, Annotations: map[string]string{ "branch": "stable", @@ -248,10 +254,12 @@ func (s *referrerTestSuite) TestExtractReferrers() { Kind: "ATTESTATION", Downloadable: true, Metadata: map[string]string{ - "name": "test-new-types", - "organization": "my-org", - "team": "my-team", - "project": "test", + "contractName": "", + "contractVersion": "", + "name": "test-new-types", + "organization": "my-org", + "team": "my-team", + "project": "test", }, References: []*Referrer{ { diff --git a/pkg/attestation/crafter/api/attestation/v1/crafting_state.pb.go b/pkg/attestation/crafter/api/attestation/v1/crafting_state.pb.go index cd03187bf..44972427f 100644 --- a/pkg/attestation/crafter/api/attestation/v1/crafting_state.pb.go +++ b/pkg/attestation/crafter/api/attestation/v1/crafting_state.pb.go @@ -533,6 +533,8 @@ type WorkflowMetadata struct { WorkflowId string `protobuf:"bytes,5,opt,name=workflow_id,json=workflowId,proto3" json:"workflow_id,omitempty"` WorkflowRunId string `protobuf:"bytes,6,opt,name=workflow_run_id,json=workflowRunId,proto3" json:"workflow_run_id,omitempty"` // Not required since we might be doing a dry-run SchemaRevision string `protobuf:"bytes,7,opt,name=schema_revision,json=schemaRevision,proto3" json:"schema_revision,omitempty"` + // contract name (contract version is "schema_revision") + ContractName string `protobuf:"bytes,11,opt,name=contract_name,json=contractName,proto3" json:"contract_name,omitempty"` // organization name Organization string `protobuf:"bytes,8,opt,name=organization,proto3" json:"organization,omitempty"` } @@ -626,6 +628,13 @@ func (x *WorkflowMetadata) GetSchemaRevision() string { return "" } +func (x *WorkflowMetadata) GetContractName() string { + if x != nil { + return x.ContractName + } + return "" +} + func (x *WorkflowMetadata) GetOrganization() string { if x != nil { return x.Organization @@ -1812,7 +1821,7 @@ var file_attestation_v1_crafting_state_proto_rawDesc = []byte{ 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, - 0x64, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x22, 0xf5, 0x02, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6b, 0x66, + 0x64, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x22, 0xa3, 0x03, 0x0a, 0x10, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, @@ -1833,45 +1842,48 @@ var file_attestation_v1_crafting_state_proto_rawDesc = []byte{ 0x30, 0x0a, 0x0f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x2b, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, - 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x7d, - 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x21, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x72, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x6d, 0x61, 0x72, 0x6b, 0x5f, 0x61, 0x73, 0x5f, 0x72, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x6d, - 0x61, 0x72, 0x6b, 0x41, 0x73, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x22, 0xde, 0x02, - 0x0a, 0x12, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x46, 0x0a, 0x06, 0x64, 0x69, - 0x67, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x61, 0x74, 0x74, - 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x44, - 0x69, 0x67, 0x65, 0x73, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, - 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x11, - 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, - 0x64, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x64, - 0x69, 0x61, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, - 0x65, 0x64, 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x4f, - 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, - 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, - 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x63, 0x72, 0x61, 0x66, 0x74, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x12, 0x2c, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, + 0x01, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x2b, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0c, + 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x7d, 0x0a, 0x0e, + 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x12, 0x28, 0x0a, 0x10, 0x6d, 0x61, 0x72, 0x6b, 0x5f, 0x61, 0x73, 0x5f, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x6d, 0x61, 0x72, + 0x6b, 0x41, 0x73, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x64, 0x22, 0xde, 0x02, 0x0a, 0x12, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x46, 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, + 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x61, 0x74, 0x74, 0x65, 0x73, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x44, 0x69, 0x67, + 0x65, 0x73, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, + 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x6f, + 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x4c, + 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x64, 0x69, 0x61, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x64, + 0x69, 0x61, 0x54, 0x79, 0x70, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, + 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x4f, 0x5a, 0x4d, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, + 0x6f, 0x70, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2f, 0x63, 0x72, 0x61, 0x66, 0x74, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, + 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/attestation/crafter/api/attestation/v1/crafting_state.proto b/pkg/attestation/crafter/api/attestation/v1/crafting_state.proto index 25ced19d0..5cd53d2c0 100644 --- a/pkg/attestation/crafter/api/attestation/v1/crafting_state.proto +++ b/pkg/attestation/crafter/api/attestation/v1/crafting_state.proto @@ -230,6 +230,8 @@ message WorkflowMetadata { string workflow_id = 5 [(buf.validate.field).string.min_len = 1]; string workflow_run_id = 6; // Not required since we might be doing a dry-run string schema_revision = 7 [(buf.validate.field).string.min_len = 1]; + // contract name (contract version is "schema_revision") + string contract_name = 11 [(buf.validate.field).string.min_len = 1]; // organization name string organization = 8 [(buf.validate.field).string.min_len = 1]; } diff --git a/pkg/attestation/renderer/chainloop/chainloop.go b/pkg/attestation/renderer/chainloop/chainloop.go index 833b4ffaa..bd468b375 100644 --- a/pkg/attestation/renderer/chainloop/chainloop.go +++ b/pkg/attestation/renderer/chainloop/chainloop.go @@ -77,14 +77,16 @@ type ProvenancePredicateCommon struct { } type Metadata struct { - Name string `json:"name"` - Project string `json:"project"` - Team string `json:"team"` - InitializedAt *time.Time `json:"initializedAt"` - FinishedAt *time.Time `json:"finishedAt"` - WorkflowRunID string `json:"workflowRunID"` - WorkflowID string `json:"workflowID"` - Organization string `json:"organization"` + Name string `json:"name"` + Project string `json:"project"` + Team string `json:"team"` + InitializedAt *time.Time `json:"initializedAt"` + FinishedAt *time.Time `json:"finishedAt"` + WorkflowRunID string `json:"workflowRunID"` + WorkflowID string `json:"workflowID"` + Organization string `json:"organization"` + ContractName string `json:"contractName"` + ContractVersion string `json:"contractVersion"` } type Maintainer struct { @@ -124,14 +126,16 @@ func getChainloopMeta(att *v1.Attestation) *Metadata { wfMeta := att.GetWorkflow() return &Metadata{ - InitializedAt: &initializedAt, - FinishedAt: &finishedAt, - Name: wfMeta.GetName(), - Team: wfMeta.GetTeam(), - Project: wfMeta.GetProject(), - WorkflowRunID: wfMeta.GetWorkflowRunId(), - WorkflowID: wfMeta.GetWorkflowId(), - Organization: wfMeta.GetOrganization(), + InitializedAt: &initializedAt, + FinishedAt: &finishedAt, + Name: wfMeta.GetName(), + Team: wfMeta.GetTeam(), + Project: wfMeta.GetProject(), + WorkflowRunID: wfMeta.GetWorkflowRunId(), + WorkflowID: wfMeta.GetWorkflowId(), + Organization: wfMeta.GetOrganization(), + ContractName: wfMeta.GetContractName(), + ContractVersion: wfMeta.GetSchemaRevision(), } } diff --git a/pkg/attestation/renderer/chainloop/testdata/attestation.output-2.v0.2.json b/pkg/attestation/renderer/chainloop/testdata/attestation.output-2.v0.2.json index e26049bee..82d93b555 100644 --- a/pkg/attestation/renderer/chainloop/testdata/attestation.output-2.v0.2.json +++ b/pkg/attestation/renderer/chainloop/testdata/attestation.output-2.v0.2.json @@ -104,6 +104,8 @@ } ], "metadata": { + "contractName": "", + "contractVersion": "4", "finishedAt": "2023-10-20T12:58:10.562093962Z", "initializedAt": "2023-10-20T12:57:10.562093962Z", "name": "test-new-types", diff --git a/pkg/attestation/renderer/chainloop/testdata/attestation.output.v0.2.json b/pkg/attestation/renderer/chainloop/testdata/attestation.output.v0.2.json index 33fd82299..e8551b328 100644 --- a/pkg/attestation/renderer/chainloop/testdata/attestation.output.v0.2.json +++ b/pkg/attestation/renderer/chainloop/testdata/attestation.output.v0.2.json @@ -66,6 +66,8 @@ } ], "metadata": { + "contractName": "", + "contractVersion": "1", "finishedAt": "2023-05-03T17:25:12.743426076Z", "initializedAt": "2023-05-03T17:22:12.743426076Z", "name": "foo",