Skip to content

Commit bc3d48f

Browse files
committed
Linter fixes
Signed-off-by: Zach Steindler <[email protected]>
1 parent 792d80f commit bc3d48f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

cmd/cosign/cli/sign/sign.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import (
6262
"github.com/sigstore/sigstore/pkg/signature/dsse"
6363
signatureoptions "github.com/sigstore/sigstore/pkg/signature/options"
6464
sigPayload "github.com/sigstore/sigstore/pkg/signature/payload"
65+
"google.golang.org/protobuf/encoding/protojson"
6566

6667
// Loads OIDC providers
6768
_ "github.com/sigstore/cosign/v2/pkg/providers/all"
@@ -190,7 +191,7 @@ func SignCmd(ro *options.RootOptions, ko options.KeyOpts, signOpts options.SignO
190191
return fmt.Errorf("accessing image: %w", err)
191192
}
192193
if signOpts.NewBundleFormat {
193-
err = signDigestBundle(ctx, digest, staticPayload, ko, signOpts, annotations, dd, sv, se)
194+
err = signDigestBundle(ctx, digest, ko, signOpts, sv)
194195
} else {
195196
err = signDigest(ctx, digest, staticPayload, ko, signOpts, annotations, dd, sv, se)
196197
}
@@ -213,7 +214,7 @@ func SignCmd(ro *options.RootOptions, ko options.KeyOpts, signOpts options.SignO
213214
}
214215
digest := ref.Context().Digest(d.String())
215216
if signOpts.NewBundleFormat {
216-
err = signDigestBundle(ctx, digest, staticPayload, ko, signOpts, annotations, dd, sv, se)
217+
err = signDigestBundle(ctx, digest, ko, signOpts, sv)
217218
} else {
218219
err = signDigest(ctx, digest, staticPayload, ko, signOpts, annotations, dd, sv, se)
219220
}
@@ -229,10 +230,7 @@ func SignCmd(ro *options.RootOptions, ko options.KeyOpts, signOpts options.SignO
229230
return nil
230231
}
231232

232-
func signDigestBundle(ctx context.Context, digest name.Digest, payload []byte, ko options.KeyOpts, signOpts options.SignOptions,
233-
annotations map[string]interface{},
234-
dd mutate.DupeDetector, sv *SignerVerifier, se oci.SignedEntity) error {
235-
233+
func signDigestBundle(ctx context.Context, digest name.Digest, ko options.KeyOpts, signOpts options.SignOptions, sv *SignerVerifier) error {
236234
digestParts := strings.Split(digest.DigestStr(), ":")
237235
if len(digestParts) != 2 {
238236
return fmt.Errorf("unable to parse digest %s", digest.DigestStr())
@@ -243,13 +241,13 @@ func signDigestBundle(ctx context.Context, digest name.Digest, payload []byte, k
243241
}
244242
predicateType := "https://sigstore.dev/cosign/sign/v1"
245243

246-
statement := intotov1.Statement{
244+
statement := &intotov1.Statement{
247245
Type: intotov1.StatementTypeUri,
248246
Subject: []*intotov1.ResourceDescriptor{&subject},
249247
PredicateType: predicateType,
250248
}
251249

252-
payload, err := json.Marshal(statement)
250+
payload, err := protojson.Marshal(statement)
253251
if err != nil {
254252
return err
255253
}

pkg/cosign/bundle/protobundle.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func MakeNewBundle(pubKey *crypto.PublicKey, rekorEntry *models.LogEntryAnon, pa
8080
var hint string
8181
var rawCert []byte
8282

83-
cert, err := cryptoutils.UnmarshalCertificatesFromPEM(signer)
8483
if pubKey != nil {
8584
pkixPubKey, err := x509.MarshalPKIXPublicKey(*pubKey)
8685
if err != nil {
@@ -89,6 +88,10 @@ func MakeNewBundle(pubKey *crypto.PublicKey, rekorEntry *models.LogEntryAnon, pa
8988
hashedBytes := sha256.Sum256(pkixPubKey)
9089
hint = base64.StdEncoding.EncodeToString(hashedBytes[:])
9190
} else {
91+
cert, err := cryptoutils.UnmarshalCertificatesFromPEM(signer)
92+
if err != nil {
93+
return nil, err
94+
}
9295
rawCert = cert[0].Raw
9396
}
9497

0 commit comments

Comments
 (0)