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

always check remote image #543

Merged
merged 1 commit into from
Aug 15, 2021
Merged
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
20 changes: 5 additions & 15 deletions pkg/cosign/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,12 @@ func Verify(ctx context.Context, signedImgRef name.Reference, co *CheckOpts) ([]
return nil, errors.New("one of verifier or root certs is required")
}

// If the image ref contains the digest, use it.
// Otherwise, look up the digest the tag currently points to.
var h v1.Hash
if d, ok := signedImgRef.(name.Digest); ok {
var err error
h, err = v1.NewHash(d.DigestStr())
if err != nil {
return nil, err
}
} else {
signedImgDesc, err := remote.Get(signedImgRef, co.RegistryClientOpts...)
if err != nil {
return nil, err
}
h = signedImgDesc.Descriptor.Digest
// Always lookup digest from remote to prevent impersonation and zombie verification
signedImgDesc, err := remote.Get(signedImgRef, co.RegistryClientOpts...)
if err != nil {
return nil, err
}
h := signedImgDesc.Descriptor.Digest

// These are all the signatures attached to our image that we know how to parse.
sigRepo := co.SignatureRepo
Expand Down