Fix DiffID computation to use uncompressed layer digest#587
Open
cluster2600 wants to merge 4 commits intoapple:mainfrom
Open
Fix DiffID computation to use uncompressed layer digest#587cluster2600 wants to merge 4 commits intoapple:mainfrom
cluster2600 wants to merge 4 commits intoapple:mainfrom
Conversation
Resolves apple#467. Previously, any arbitrary string could be passed as a nameserver in DNS configuration, which would silently result in an invalid /etc/resolv.conf inside the container. This change adds a DNS.validate() method that ensures every nameserver string is a valid IPv4 or IPv6 address (using the existing ContainerizationExtras parsers). The method is called from Vminitd.configureDNS() before applying the configuration. Tests added to DNSTests.swift covering valid IPv4, IPv6, mixed, empty nameserver lists, and invalid hostname/address rejection. Signed-off-by: Maxime Grenu <maxime.grenu@gmail.com>
The validate() method uses ContainerizationError which lives in its own module and must be explicitly imported. Signed-off-by: Maxime Grenu <maxime.grenu@gmail.com>
The OCI Image Specification requires DiffIDs to be the SHA256 digest of the uncompressed layer content. InitImage.create() was incorrectly using the digest of the compressed gzip layer. Add ContentWriter.diffID(of:) which decompresses the gzip stream and computes SHA256 of the raw content. The implementation parses the gzip header (handling FEXTRA, FNAME, FCOMMENT, FHCRC flags) and feeds the raw deflate stream to Apple's Compression framework. Signed-off-by: Maxime Grenu <maxime@cluster2600.com> Signed-off-by: Maxime Grenu <maxime.grenu@gmail.com>
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.
Summary
InitImage.create()to compute DiffIDs from the uncompressed layer content per the OCI Image SpecificationContentWriter.diffID(of:)which decompresses gzip data and computes SHA256 of the raw contentChanges
ContentWriter.swift: AdddiffID(of:)static method with gzip header parsing and streaming decompression via Apple's Compression frameworkInitImage.swift: Replace compressed digest with uncompressed digest forRootfs.diffIDsDiffIDTests.swift: 6 tests covering correctness, determinism, error handling, large layers, and output formatContext
Resolves the TODO at
InitImage.swift:56:Test plan