fix: validate caller-supplied config descriptor in Pack/PackManifest#1237
Open
TerryHowe wants to merge 3 commits into
Open
fix: validate caller-supplied config descriptor in Pack/PackManifest#1237TerryHowe wants to merge 3 commits into
TerryHowe wants to merge 3 commits into
Conversation
When a ConfigDescriptor is provided to Pack or PackManifest, the caller is responsible for pushing the config blob and populating the descriptor's Digest and Size. Previously the descriptor was used verbatim, so a partially-populated descriptor (e.g. only MediaType and Annotations set, with an empty Digest and zero Size) produced a manifest referencing a non-existent config blob. Some registries accept such manifests while silently dropping the config descriptor's annotations, which is confusing to debug. Validate that a supplied config descriptor has a valid digest and return an error wrapping errdef.ErrInvalidDigest otherwise, failing fast instead of producing a malformed manifest. Also clarify the ConfigDescriptor godoc. Fixes oras-project#1236 Signed-off-by: Terry Howe <terrylhowe@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1237 +/- ##
==========================================
+ Coverage 83.09% 83.12% +0.02%
==========================================
Files 82 82
Lines 5834 5842 +8
==========================================
+ Hits 4848 4856 +8
Misses 605 605
Partials 381 381 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TerryHowe
marked this pull request as ready for review
July 8, 2026 13:54
TerryHowe
requested review from
Wwwsylvia,
sabre1041 and
shizhMSFT
as code owners
July 8, 2026 13:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
When a
ConfigDescriptoris supplied toPack/PackManifest, the caller is responsible for pushing the config blob and populating the descriptor'sDigestandSize. The library uses the descriptor verbatim and does not push the config blob in that path.Previously, a partially-populated descriptor (e.g. only
MediaTypeandAnnotationsset, with an emptyDigestand zeroSize) was accepted and produced a manifest referencing a non-existent config blob:Some registries (e.g. GHCR) accept such manifests while silently dropping the config descriptor's annotations, which is confusing to debug.
Change
validateConfigDescriptor, which validates both the media type format and the digest of a caller-supplied config descriptor.packManifestV1_0,packManifestV1_1, and the deprecatedpackManifestV1_1_RC2paths. Callers now get an error wrappingerrdef.ErrInvalidDigestinstead of a silently-malformed manifest.ConfigDescriptorgodoc to state that the caller must push the config blob and populateDigest/Size.Because this only rejects manifests that were already malformed, and oras-go v3 has not been released yet, this is not a breaking change.
Tests
Added
Test_PackManifest_ImageV1_0_InvalidConfigDigest,Test_PackManifest_ImageV1_1_InvalidConfigDigest, andTest_Pack_ImageV1_1_RC2_InvalidConfigDigest. Full suite (go test ./...) passes.Fixes #1236
🤖 Generated with Claude Code