Skip to content

Make VerificationResult an interface #462

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

Closed
codysoyland opened this issue Apr 18, 2025 · 1 comment
Closed

Make VerificationResult an interface #462

codysoyland opened this issue Apr 18, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@codysoyland
Copy link
Member

Description

There have been a lot of discussions about the future of verification results:

What if we make the verification result type an interface, so that we have more flexibility to make changes in the future without breaking callers.

Currently we have:

type VerificationResult struct {
	MediaType           string                        `json:"mediaType"`
	Statement          *in_toto.Statement            `json:"statement,omitempty"`
	Signature          *SignatureVerificationResult  `json:"signature,omitempty"`
	VerifiedTimestamps []TimestampVerificationResult `json:"verifiedTimestamps"`
	VerifiedIdentity   *CertificateIdentity          `json:"verifiedIdentity,omitempty"`

We could instead return a type like:

type VerificationResult interface {
	Statement() *in_toto.Statement
	Signature() *SignatureVerificationResult
	VerifiedTimestamps() []TimestampVerificationResult
	VerifiedIdentity() *CertificateIdentity
	MarshalJSON() ([]byte, error)
}
@codysoyland codysoyland added the enhancement New feature or request label Apr 18, 2025
@codysoyland
Copy link
Member Author

I spent some time looking into how feasible this is, and I changed my opinion on it.

  • The result is expected to marshal/unmarshal JSON, so we can't easily unexport the field names (would require custom marshal/unmarshal)
  • The interface names would conflict with the field names.
  • This will be disruptive now, and it "may" prevent disruption in the future.
  • We can add methods to the result struct later and deprecate fields if we would like to.

@codysoyland codysoyland closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant