Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spdxjson and cyclonedx as supported predicate types #25

Merged
merged 2 commits into from
Jun 11, 2022

Conversation

jdolitsky
Copy link
Contributor

Signed-off-by: Josh Dolitsky <josh@dolit.ski>
@@ -165,7 +165,7 @@ func (a *Attestation) Validate(ctx context.Context) *apis.FieldError {
}
if a.PredicateType == "" {
errs = errs.Also(apis.ErrMissingField("predicateType"))
} else if a.PredicateType != "custom" && a.PredicateType != "slsaprovenance" && a.PredicateType != "spdx" && a.PredicateType != "link" && a.PredicateType != "vuln" {
} else if a.PredicateType != "custom" && a.PredicateType != "slsaprovenance" && a.PredicateType != "spdx" && a.PredicateType != "spdxjson" && a.PredicateType != "cyclonedx" && a.PredicateType != "link" && a.PredicateType != "vuln" {
Copy link
Member

Choose a reason for hiding this comment

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

This is begging to be a validPredicates.Contains(a.PredicateType) using something like https://pkg.go.dev/k8s.io/apimachinery/pkg/util/sets, or just a map[string]struct{}{}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call. it hath been done

Signed-off-by: Josh Dolitsky <josh@dolit.ski>
@@ -165,7 +169,7 @@ func (a *Attestation) Validate(ctx context.Context) *apis.FieldError {
}
if a.PredicateType == "" {
errs = errs.Also(apis.ErrMissingField("predicateType"))
} else if a.PredicateType != "custom" && a.PredicateType != "slsaprovenance" && a.PredicateType != "spdx" && a.PredicateType != "link" && a.PredicateType != "vuln" {
} else if !validPredicateTypes.Has(a.PredicateType) {
// TODO(vaikas): The above should be using something like:
Copy link
Member

Choose a reason for hiding this comment

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

lol I didn't even see this comment before. Is the import loop still a problem? It'd be nice not to have to maintain this list in two places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vaikas Halp!

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like that's https://github.com/sigstore/cosign/blob/main/cmd/cosign/cli/options/predicate.go#L40

The good news is, I don't think that would cause a dependency cycle.

The bad news is, it's a new dependency on cmd/cosign 😭

I think we could probably just maintain two sets for now, and maybe move both into sigstore/sigstore (or into cosign/pkg/something). Doesn't need to block this PR though I think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, +1 for just having a local copy and move it somewhere else. But, yes, agree on not being part of this PR. We should remove this TODO from here though, since its' addressed by the TODO above. But that can be done in a follow on as well, I'll do it 👍

@vaikas vaikas merged commit 5bf901c into sigstore:main Jun 11, 2022
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.

3 participants