fix(build): validate ImageConfiguration in NewOptions - #2465
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
NewOptions returns an ImageConfiguration whose fields (such as Format) were never validated via ic.Validate(), unlike the New constructor. An invalid layer format was accepted and silently defaulted to a tar archive instead of returning an error. Fixes chainguard-dev#2423 Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
Tyagiquamar
force-pushed
the
fix/newoptions-validate-image-config
branch
from
September 6, 2026 05:50
c7c4256 to
73467ae
Compare
coreydaley-cg
approved these changes
Sep 10, 2026
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.
Problem
build.NewOptions()evaluates option overrides but never callsic.Validate(), unlikebuild.New(). As a result, library callers usingNewOptions()receive anImageConfigurationwhose fields (such asFormat) are unvalidated. An invalid layer format (e.g."squashfs") is accepted without error and silently degrades into a tar archive rather than returning a validation error.Root Cause
NewOptions()callsresolveImageConfiguration()but omits thebc.ic.Validate()check thatbuild.New()executes.Fix
Added
bc.ic.Validate()check at the end ofbuild.NewOptions(), ensuring constructor contract consistency betweenNewOptions()andNew(). Added unit testTestNewOptionsValidatesImageConfigurationinoptions_test.go.Fixes #2423