Skip to content

Commit

Permalink
fix: added digest check on resolve ref (notaryproject#689)
Browse files Browse the repository at this point in the history
This PR adds check on user input digest and resolved digest.

Signed-off-by: Patrick Zheng <[email protected]>
  • Loading branch information
Two-Hearts authored May 26, 2023
1 parent d35d85c commit fcf72c7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/notation/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func resolveReference(ctx context.Context, inputType inputType, reference string
resolvedRef = resolvedRef + "@" + manifestDesc.Digest.String()
if _, err := digest.Parse(tagOrDigestRef); err == nil {
// tagOrDigestRef is a digest reference
if tagOrDigestRef != manifestDesc.Digest.String() {
// tagOrDigestRef does not match the resolved digest
return ocispec.Descriptor{}, "", fmt.Errorf("user input digest %s does not match the resolved digest %s", tagOrDigestRef, manifestDesc.Digest.String())
}
return manifestDesc, resolvedRef, nil
}
// tagOrDigestRef is a tag reference
Expand Down

0 comments on commit fcf72c7

Please sign in to comment.