Skip to content

Add explicit img disk image support - #184

Merged
popey merged 5 commits into
mainfrom
feature/issue-5-img-support
Aug 6, 2026
Merged

Add explicit img disk image support#184
popey merged 5 commits into
mainfrom
feature/issue-5-img-support

Conversation

@popey

@popey popey commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • recognize .img as an explicit raw disk-image fallback when qemu-img cannot determine a format
  • continue preferring content detection so qcow2 or vmdk images with an .img suffix are handled correctly
  • fall back cleanly when qemu-img is unavailable
  • keep gzip fallback limited to the existing .ami and .raw paths so untrusted .img inputs cannot trigger decompression
  • document .img behavior and the existing partition/filesystem limitations
  • add regression coverage for detected formats, failed and unavailable probes, and gzip-looking .img input

Validation

  • python3 -m unittest discover -s tests -v
  • python3 -m py_compile sbom-vm.py generate-test-images.py tests/test_image_format.py
  • node --test .github/change-review/publish-review.test.mjs
  • git diff --check

Closes #5

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tessl change review:

Reviewed against skills: review-code-legibility, review-test-risk, review-security-risks

review-code-legibility

  • Found 2 issues; overall, the new fallback behavior is understandable but a couple of names/documentation entries blur formats vs suffix fallbacks.

review-test-risk

  • Found 1 issue; coverage is mostly aligned, but one assertion is brittle implementation coupling.

review-security-risks

  • Found 1 issue; .img fallback can now route untrusted input into unbounded decompression.

To trigger a re-review write a comment that says @tessl-change-review.

Comment thread README.md Outdated
Comment thread sbom-vm.py
Comment thread sbom-vm.py Outdated
Comment thread tests/test_image_format.py

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread sbom-vm.py Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread sbom-vm.py

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread sbom-vm.py Outdated
@minnielove2026

Copy link
Copy Markdown
Collaborator

External Linux .img test

Tested this PR end-to-end on Linux with an official Raspberry Pi OS image.

Test input and host

Finding and fix

The first run correctly detected the expanded .img as raw, but qemu-nbd failed because the detected format was not passed to the connection command. A direct connection using --format=raw --read-only succeeded, confirming the cause.

Commit 8494e41 now carries the prepared image's actual format into the NBD connection and makes the NBD export explicitly read-only. This accounts for raw images, gzip inputs prepared as raw, and VMDK/VHD/VPC inputs converted to QCOW2.

Successful rerun

  • Format detection: raw
  • NBD connection: raw, read-only
  • Partitions found: /dev/nbd0p1 (FAT32) and /dev/nbd0p2 (ext4)
  • Selected partition: /dev/nbd0p2, ext4, 2,433 MB
  • Syft: succeeded with version 1.50.0
  • SBOM artifacts: 4,742
  • SBOM relationships: 73,929
  • SBOM size: 48,658,616 bytes
  • Total runtime: 32.852 seconds
  • Cleanup: successful; no remaining mount, NBD attachment, or temporary directory

Local validation

  • 12 Python unit tests pass, including the new qemu-nbd command regression test
  • Python compilation passes
  • Publisher test passes
  • git diff --check passes

@popey
popey merged commit 5c03d06 into main Aug 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add support for img files

2 participants