-
Notifications
You must be signed in to change notification settings - Fork 48
image/manifest: Add DigestWithAlgorithm function
#499
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
base: main
Are you sure you want to change the base?
Conversation
When storing blobs with non-canonical digest algorithms (e.g., sha512), store the blob under the provided digest algorithm with an algorithm prefix (e.g., "sha512-abc" instead of just "abc"). SHA256 (canonical) digests continue to be stored without a prefix for backward compatibility. Signed-off-by: Lokesh Mandvekar <[email protected]>
Introduce version 1.2 and dynamically assign versions based on the digest algorithms used: - Version 1.1 for sha256-only images (backward compatibility) - Version 1.2 for images using non-sha256 digest algorithms (e.g., sha512) Add validation in both ImageDestination and ImageSource to: - Assume 1.1 if no version file found in dir transport images - Accept both version 1.1 and 1.2 - Refuse unsupported future versions Signed-off-by: Lokesh Mandvekar <[email protected]>
Add a new `manifest.DigestWithAlgorithm` function that allows computing the digest of a manifest using a specified algorithm (e.g., SHA256, SHA512) while properly handling v2s1 signed manifest signature stripping. This addresses the need for skopeo's `--manifest-digest` flag to support different digest algorithms while correctly handling all manifest types, particularly Docker v2s1 signed manifests that require signature stripping before digest computation. Signed-off-by: Lokesh Mandvekar <[email protected]>
e1149c9 to
bdbac34
Compare
DigestWithAlgorithm functionDigestWithAlgorithm function
|
Packit jobs failed. @containers/packit-build please check. |
|
✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6541 |
|
|
||
| // Digest returns the a digest of a docker manifest, with any necessary implied transformations like stripping v1s1 signatures. | ||
| // This is publicly visible as c/image/manifest.Digest. | ||
| func Digest(manifest []byte) (digest.Digest, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With Digest just a { return DigestWithAlgorithm(manifest, digest.Canonical } it would be 100% clear what the correspondence between the two functions is, and we would decrease the risk of divergence.
| sha256Digest, err := DigestWithAlgorithm(manifest, digest.SHA256) | ||
| require.NoError(t, err) | ||
| assert.NotEqual(t, sha256Digest, actualDigest, c.path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
| require.NoError(t, err) | ||
| actualDigest, err := DigestWithAlgorithm(manifest, digest.SHA512) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, digest.SHA512, actualDigest.Algorithm()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not particularly precise…
I think
- The empty input can be reasonably included in the test case table
- The test case table can contain exact sha256 and sha512 digests
Then TestDigest and TestDigestWithAlgorithm can work from a shared table, differing only in whether they process 1 / 2 values.
Alternatively, if Digest became just a wrapper over DigestWithAlgorithm, it would be acceptable to have comprehensive tests only for …WithAlgorithm (more precise than the current ones), and a ~smoke-test for Digest. (I weakly prefer the shared table and thorough testing of both.)
Add a new
manifest.DigestWithAlgorithmfunction thatallows computing the digest of a manifest using a specified algorithm
(e.g., SHA256, SHA512) while properly handling v2s1 signed manifest
signature stripping.
This addresses the need for skopeo's
--manifest-digestflag to supportdifferent digest algorithms while correctly handling all manifest types,
particularly Docker v2s1 signed manifests that require signature
stripping before digest computation.
Note: Currently rebased on #475 .