Skip to content

Commit

Permalink
nil check
Browse files Browse the repository at this point in the history
Signed-off-by: Asra Ali <asraa@google.com>
  • Loading branch information
asraa committed Nov 1, 2022
1 parent a7e0bcb commit 912089f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/cosign/tlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ func VerifyTLogEntry(e *models.LogEntryAnon, rekorPubKeys *TrustedRekorPubKeys)
return errors.New("inclusion proof not provided")
}

if rekorPubKeys == nil || rekorPubKeys.Keys == nil {
return errors.New("no trusted rekor public keys provided")
}

hashes := [][]byte{}
for _, h := range e.Verification.InclusionProof.Hashes {
hb, _ := hex.DecodeString(h)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cosign/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ func TestVerifyImageSignatureWithNoChain(t *testing.T) {
opts := []static.Option{static.WithCertChain(pemLeaf, []byte{}), static.WithBundle(rekorBundle)}
ociSig, _ := static.NewSignature(payload, base64.StdEncoding.EncodeToString(signature), opts...)

logId, _ := getLogID(sv.Public)
logID, _ := getLogID(sv.Public)
ecdsaKey, _ := sv.PublicKey()

// TODO(asraa): Re-enable passing test when Rekor public keys can be set in CheckOpts,
// instead of relying on the singleton TUF instance.
verified, err := VerifyImageSignature(context.TODO(), ociSig, v1.Hash{}, &CheckOpts{
RootCerts: rootPool,
RekorPubKeys: &TrustedRekorPubKeys{
Keys: map[string]RekorPubKey{logId: {PubKey: ecdsaKey.(*ecdsa.PublicKey), Status: tuf.Active}},
Keys: map[string]RekorPubKey{logID: {PubKey: ecdsaKey.(*ecdsa.PublicKey), Status: tuf.Active}},
},
})
if err == nil {
Expand Down

0 comments on commit 912089f

Please sign in to comment.