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

VerificationResult now has a proper mediaType field. #14

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/sigstore-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,21 @@ func run() error {
return err
}

if *artifactDigest != "" {
if *artifactDigest != "" { //nolint:gocritic
artifactDigestBytes, err := hex.DecodeString(*artifactDigest)
if err != nil {
return err
}
artifactPolicy = verify.WithArtifactDigest(*artifactDigestAlgorithm, artifactDigestBytes)
}
if *artifact != "" {
} else if *artifact != "" {
file, err := os.Open(*artifact)
if err != nil {
return err
}
artifactPolicy = verify.WithArtifact(file)
} else {
artifactPolicy = verify.WithoutArtifactUnsafe()
fmt.Fprintf(os.Stderr, "No artifact provided, skipping artifact verification. This is unsafe!\n")
}

res, err := sev.Verify(b, verify.NewPolicy(artifactPolicy, identityPolicies...))
Expand Down
12 changes: 9 additions & 3 deletions pkg/verify/signed_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"github.com/sigstore/sigstore-go/pkg/root"
)

const (
VerificationResultMediaType01 = "application/vnd.dev.sigstore.verificationresult+json;version=0.1"
)

type SignedEntityVerifier struct {
trustedMaterial root.TrustedMaterial
config VerifierConfig
Expand Down Expand Up @@ -154,7 +158,7 @@ func (c *VerifierConfig) Validate() error {
}

type VerificationResult struct {
Version int `json:"version"`
MediaType string `json:"mediaType"`
Statement *in_toto.Statement `json:"statement,omitempty"`
Signature *SignatureVerificationResult `json:"signature,omitempty"`
VerifiedTimestamps []TimestampVerificationResult `json:"verifiedTimestamps"`
Expand All @@ -174,7 +178,7 @@ type TimestampVerificationResult struct {

func NewVerificationResult() *VerificationResult {
return &VerificationResult{
Version: 20230823,
MediaType: VerificationResultMediaType01,
}
}

Expand All @@ -193,9 +197,11 @@ func (pc PolicyBuilder) Options() []PolicyOption {
}

func (pc PolicyBuilder) BuildConfig() (*PolicyConfig, error) {
var err error

policy := &PolicyConfig{}
for _, applyOption := range pc.Options() {
err := applyOption(policy)
err = applyOption(policy)
if err != nil {
return nil, err
}
Expand Down
Loading