Skip to content

feat(chainloop): add EVIDENCE material type - #702

Merged
migmartri merged 7 commits into
chainloop-dev:mainfrom
jiparis:feat-566
Apr 26, 2024
Merged

feat(chainloop): add EVIDENCE material type#702
migmartri merged 7 commits into
chainloop-dev:mainfrom
jiparis:feat-566

Conversation

@jiparis

@jiparis jiparis commented Apr 26, 2024

Copy link
Copy Markdown
Member

This PR adds a new material type called EVIDENCE which inherits from ARTIFACT, but it's not meant to represent a main software artifact, but a secondary, stored in CAS, piece of material. A test report, or a generated custom bill of materials are good examples for this new type.

Closes #698

jiparis added 2 commits April 26, 2024 08:18
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
@javirln

javirln commented Apr 26, 2024

Copy link
Copy Markdown
Member

Since the EVIDENCE type cannot be set or should be set as output: true on the contract level, we could inform the operator by raising an error. On the crafting_schema_validation.go:

// ValidateEvidenceNotOutput validates that materials with type EVIDENCE are not marked as output
func (schema *CraftingSchema) ValidateEvidenceNotOutput() error {
	for _, m := range schema.Materials {
		if m.GetType() != CraftingSchema_Material_EVIDENCE {
			continue
		}

		if m.GetOutput() {
			return fmt.Errorf("material with name=%s and type EVIDENCE cannot be marked as output: true", m.Name)
		}
	}

	return nil
}

And then run the validation on the crafter.go.

Wdyt @jiparis @migmartri ??

@jiparis
jiparis marked this pull request as draft April 26, 2024 06:56
@jiparis
jiparis requested review from javirln and migmartri April 26, 2024 06:56
@migmartri

Copy link
Copy Markdown
Member

Since the EVIDENCE type cannot be set or should be set as output: true on the contract level, we could inform the operator by raising an error. On the crafting_schema_validation.go:

// ValidateEvidenceNotOutput validates that materials with type EVIDENCE are not marked as output
func (schema *CraftingSchema) ValidateEvidenceNotOutput() error {
	for _, m := range schema.Materials {
		if m.GetType() != CraftingSchema_Material_EVIDENCE {
			continue
		}

		if m.GetOutput() {
			return fmt.Errorf("material with name=%s and type EVIDENCE cannot be marked as output: true", m.Name)
		}
	}

	return nil
}

And then run the validation on the crafter.go.

Wdyt @jiparis @migmartri ??

I do not think that in crafter.go would be enough since we might have other clients creating contracts. because of that, it might make sense to implement it server side, either with custom code as you showed or built-in using a custom protovalidate rule.

@migmartri

Copy link
Copy Markdown
Member

in any case, I am ok doing the validation in another patch, because note that we can not enable until this is in place #703

@javirln javirln left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread app/controlplane/api/workflowcontract/v1/crafting_schema.proto Outdated
Comment thread internal/attestation/crafter/materials/evidence.go
Comment thread internal/attestation/crafter/materials/evidence_test.go
jiparis added 3 commits April 26, 2024 10:04
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
@migmartri
migmartri marked this pull request as ready for review April 26, 2024 09:00
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>

@migmartri migmartri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update also the readme file with the info about the new material type, it seems we only added it to the docs page

Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
@migmartri

Copy link
Copy Markdown
Member

Let's update also the readme file with the info about the new material type, it seems we only added it to the docs page

I've updated it :)

@migmartri
migmartri merged commit daaa968 into chainloop-dev:main Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add EVIDENCE material type

3 participants