Skip to content

feat: support oci-path format for directory input (#280) - #325

Open
yashahuja31 wants to merge 1 commit into
goodwithtech:masterfrom
yashahuja31:feat/oci-path-support
Open

feat: support oci-path format for directory input (#280)#325
yashahuja31 wants to merge 1 commit into
goodwithtech:masterfrom
yashahuja31:feat/oci-path-support

Conversation

@yashahuja31

Copy link
Copy Markdown

Description

Resolves #280.

Adds support for scanning OCI image layout directories (oci-path format), such as images exported by Bazel's rules_oci or skopeo copy docker://... oci:....

Changes Made

  • Added NewOCIDirExtractor in pkg/deckoder/extractor/docker/oci.go using containers/image's oci: transport.
  • Updated pkg/scanner/scan.go to auto-detect if the --input path is a directory (OCI layout) or a file (docker-archive).
  • Added layerReadCloser in pkg/deckoder/extractor/image/image.go to ensure uncompressed layer file handles are properly closed.
  • Normalized extracted path keys to POSIX slashes (/) via filepath.ToSlash for cross-platform compatibility.
  • Added unit tests for OCI layout extraction in pkg/deckoder/extractor/docker/oci_test.go.
  • Updated README.md and 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.gz layer 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 standard docker-archive tarball extraction. (PASS)
  • Full Package Regression Tests:

    • go test ./pkg/assessor/... ./pkg/report/... ./pkg/deckoder/... (PASS)

2. Path Normalization & Cross-Platform Verification

  • Verified that container file keys extracted from OCI and Docker archives remain POSIX-normalized (/) across platforms (including Windows), preventing path delimiter mismatch issues in FileMap lookups and test assertions.

3. CLI Build & Verification

  • Built the binary using go build -o dockle cmd/dockle/main.go.
  • Tested dockle --help to confirm the updated CLI description for --input is properly formatted:

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: add support for oci-path images

1 participant