feat: support oci-path format for directory input (#280) - #325
Open
yashahuja31 wants to merge 1 commit into
Open
feat: support oci-path format for directory input (#280)#325yashahuja31 wants to merge 1 commit into
yashahuja31 wants to merge 1 commit into
Conversation
Add support for scanning OCI image layout directories (oci-path format, such as output from Bazel rules_oci or skopeo copy). - Introduce NewOCIDirExtractor in pkg/deckoder/extractor/docker using containers/image oci: transport - Add layerReadCloser in pkg/deckoder/extractor/image to prevent file descriptor leaks for uncompressed layers - Auto-detect directory vs file in scanner for --input flag - Normalize tar extraction paths using filepath.ToSlash for cross-platform path compatibility - Add unit tests for OCI layout extraction and update CLI documentation
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.
Description
Resolves #280.
Adds support for scanning OCI image layout directories (
oci-pathformat), such as images exported by Bazel'srules_ociorskopeo copy docker://... oci:....Changes Made
NewOCIDirExtractorinpkg/deckoder/extractor/docker/oci.gousingcontainers/image'soci:transport.pkg/scanner/scan.goto auto-detect if the--inputpath is a directory (OCI layout) or a file (docker-archive).layerReadCloserinpkg/deckoder/extractor/image/image.goto ensure uncompressed layer file handles are properly closed./) viafilepath.ToSlashfor cross-platform compatibility.pkg/deckoder/extractor/docker/oci_test.go.README.mdand CLI documentation with OCI layout usage details and examples.Testing Done
1. Unit Tests Added & Executed
Ran unit tests using Go 1.25 via
go test -v ./...:pkg/deckoder/extractor/docker/oci_test.go:TestNewOCIDirExtractor_ExtractLayerFiles/uncompressed_layer: Verified that an OCI layout directory containing an uncompressed tar layer is properly parsed, extracted, and cleaned up without file descriptor leaks. (PASS)TestNewOCIDirExtractor_ExtractLayerFiles/gzipped_layer: Verified that an OCI layout containing a.tar.gzlayer is correctly decompressed and extracted. (PASS)TestNewOCIDirExtractor_NotALayout: Verified that attempting to read a non-OCI directory returns a clear error rather than failing silently. (PASS)pkg/deckoder/extractor/docker/docker_test.go:TestExtractor_ExtractLayerFiles: Re-verified standarddocker-archivetarball extraction. (PASS)Full Package Regression Tests:
go test ./pkg/assessor/... ./pkg/report/... ./pkg/deckoder/...(PASS)2. Path Normalization & Cross-Platform Verification
/) across platforms (including Windows), preventing path delimiter mismatch issues inFileMaplookups and test assertions.3. CLI Build & Verification
go build -o dockle cmd/dockle/main.go.dockle --helpto confirm the updated CLI description for--inputis properly formatted: