Skip to content

T8542: refactor SBOM generation - run after ISO build - #1198

Merged
c-po merged 8 commits into
vyos:rollingfrom
c-po:spdx-refactoring
Jun 2, 2026
Merged

T8542: refactor SBOM generation - run after ISO build#1198
c-po merged 8 commits into
vyos:rollingfrom
c-po:spdx-refactoring

Conversation

@c-po

@c-po c-po commented May 24, 2026

Copy link
Copy Markdown
Member

Change summary

Revert current SBOM generation commits and replace them with a simplified approach where the SBOM is directly generated after the VyOS ISO assembly step. This saves a lot of code, time (no need to spawn a QEMU VM), and also code which must be maintained.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

How to test / Smoketest result

Just buiid a VyOS ISO image

(12:24) vyos_bld a13d26bb2070:/vyos/vyos-build [spdx-refactoring] # ll build/*.iso build/*.json
-rw-r--r-- 1 root root   5276819 May 24 11:55 build/2026.05.24-1144-rolling.cdx.json
-rw-r--r-- 1 root root   8502198 May 24 11:55 build/2026.05.24-1144-rolling.spdx.json
-rw-r--r-- 1 root root 729808896 May 24 11:44 build/live-image-amd64.hybrid.iso
-rw-r--r-- 1 root root      7078 May 24 11:55 build/manifest.json
-rw-r--r-- 1 root root 729808896 May 24 11:54 build/vyos-2026.05.24-1144-rolling-generic-amd64.iso

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

@github-actions

github-actions Bot commented May 24, 2026

Copy link
Copy Markdown


PR title does not match the required format

@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: d671c30b-5c3d-43cd-85a4-5ecde5ad2b0b

📥 Commits

Reviewing files that changed from the base of the PR and between d7cb6d0 and 75a495b.

📒 Files selected for processing (4)
  • Makefile
  • docker/Dockerfile
  • scripts/check-qemu-install
  • scripts/image-build/build-vyos-image
💤 Files with no reviewable changes (1)
  • Makefile
🚧 Files skipped from review as they are similar to previous changes (2)
  • docker/Dockerfile
  • scripts/image-build/build-vyos-image
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build_iso
  • GitHub Check: codeql-analysis-call / Analyze (python)
  • GitHub Check: Mergify Merge Queue
🧰 Additional context used
🔍 Remote MCP Context7

Additional factual context relevant to this PR

  • Official Context7 library ID for Syft: /anchore/syft.

  • Syft supports generating multiple SBOM outputs in one run using repeated -o flags and accepts per-format file targets. Example:

    • syft -o syft-json=sbom.syft.json -o spdx-json=sbom.spdx.json -o cyclonedx-json=sbom.cdx.json
    • It also supports format names such as cyclonedx-json, spdx-json, spdx-tag-value, syft-json, etc.
  • Syft can be configured via environment variables; notably SYFT_PLATFORM (e.g., "linux/amd64") to control target platform for the scan. This may be relevant when scanning ISO filesystems or platform-specific artifacts.

Sources:

  • Syft library resolution: Context7 library entry for Syft — /anchore/syft.
  • Syft usage, multiple outputs, and environment variables.
🔇 Additional comments (1)
scripts/check-qemu-install (1)

193-193: LGTM!

Also applies to: 399-399, 650-650, 1307-1307


📝 Walkthrough

Summary by CodeRabbit

  • Chores

    • SBOM generation has been integrated into the image build: SBOMs are produced automatically as part of the build.
    • Removed the separate "make sbom" target; SBOMs no longer produced via a standalone make step.
    • Build images now include the SBOM generation tool so SBOMs are created during image builds.
  • Bug Fixes

    • Install/check flow no longer provisions a temporary transfer disk for SBOM extraction and now completes without triggering a non-zero exit on earlier recorded exceptions.

Walkthrough

Moves SBOM generation from a VM transfer-disk workflow to host-side syft usage: removes Makefile make_sbom and check-qemu-install SBOM CLI/transfer-disk/guest logic; adds syft installation in docker/Dockerfile and invokes syft from scripts/image-build/build-vyos-image.

Changes

SBOM generation migration from VM to host-side

Layer / File(s) Summary
Remove VM-based SBOM infrastructure
Makefile (lines 90-94), scripts/check-qemu-install (lines 127-130, 193, 278-279, 396-399, 650, 1250-1255, 1260-1261, 1296-1297, 1307)
Removed make_sbom target (Makefile 90-94). scripts/check-qemu-install deletes --sbom / --sbom-output-dir parsing (127-130), removes transfer_disk parameter from get_qemu_cmd() (193) and QEMU transfer-disk augmentation (278-279), removes host transfer-disk creation and syft setup (396-399), updates install-time call to omit transfer_disk (650), removes guest SBOM branch (1250-1255), removes host extraction (1260-1261), removes transfer-disk cleanup (1296-1297), and makes termination always sys.exit(0) (1307).
Add host-side SBOM generation via syft
docker/Dockerfile (lines 351-355), scripts/image-build/build-vyos-image (lines 3, 19-20, 33-37, 724-749)
docker/Dockerfile installs syft v1.44.0 (351-355). build-vyos-image updates header/imports and adds subprocess import (lines 3, 19-20, 33-37) and invokes syft via subprocess.Popen() after ISO creation to emit CycloneDX and SPDX JSON SBOMs, applies sed fixups, streams process output, and appends the ISO to manifest['artifacts'] (724-749).
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main refactoring objective: moving SBOM generation from a VM-based approach to post-ISO-build execution.
Description check ✅ Passed The description directly relates to the changeset, explaining the rationale for the refactoring and providing testing evidence with concrete output artifacts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the current VyOS rolling release label May 24, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docker/Dockerfile`:
- Around line 351-354: The Dockerfile currently downloads
syft_1.44.0_linux_$(dpkg-architecture -qDEB_HOST_ARCH).tar.gz to /tmp as
syft.tar.gz and extracts the syft binary to /usr/local/bin/syft without
integrity checks; update the RUN step to also download the matching release
checksum (or signature) artifact for that same ${arch} (e.g.,
syft_1.44.0_SHA256SUMS or a .sig), verify syft.tar.gz against the checksum (or
verify the checksum file signature with gpg) and fail the build if verification
fails, then proceed to tar --extract and mv syft /usr/local/bin/ only after
successful verification so the symbols syft.tar.gz,
syft_1.44.0_linux_$(dpkg-architecture -qDEB_HOST_ARCH).tar.gz, and
/usr/local/bin/syft are protected by integrity checks.

In `@scripts/image-build/build-vyos-image`:
- Around line 729-741: The SBOM is being generated from the current BUILD_DIR
contents because the code calls syft with '.' (variable cmd uses 'syft', '.')
after switching into defaults.BUILD_DIR; change this to mount the iso_file to a
temporary mount directory and run syft against that mountpoint instead of '.'.
Concretely: create a temp dir, loop-mount iso_file (the variable iso_file
referenced earlier) into it, update the cmd array used for subprocess.Popen
(currently contains 'syft' and '.') to use the mount dir path, run the same
stdout/stderr handling, then unmount and remove the temp dir in a
finally/cleanup block to ensure proper cleanup and error handling. Ensure
subprocess.CalledProcessError is still raised on non-zero rc.
- Around line 729-741: The function-scope variable name cmd is being shadowed by
later assignment, causing UnboundLocalError for earlier uses like cmd("lb
clean"), cmd(lb_config_command) and cmd("lb build 2>&1"); rename the local list
to a unique identifier (e.g., syft_cmd or sbom_cmd) inside the SBOM creation
block where cmd = ['syft', ...] is defined (and update the subprocess.Popen call
to use that new name) so the existing cmd() helper calls remain referring to the
intended function; ensure only the list and its Popen invocation are changed
(keep subprocess.PIPE, stderr, text, bufsize and error handling the same).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: b7b22d6b-7883-4dde-b617-64402574cfd0

📥 Commits

Reviewing files that changed from the base of the PR and between 5ff863c and 590e6be.

📒 Files selected for processing (4)
  • Makefile
  • docker/Dockerfile
  • scripts/check-qemu-install
  • scripts/image-build/build-vyos-image
💤 Files with no reviewable changes (1)
  • Makefile
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build_iso
  • GitHub Check: codeql-analysis-call / Analyze (python)
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Summary
🧰 Additional context used
🔍 Remote MCP Context7

The specific task T8542 details are not publicly accessible. Let me search for more information about the architectural implications and potential concerns with this refactoring:Based on my research, I have gathered sufficient context to provide a comprehensive review summary. Let me compile the findings:

Summary of Additional Context Found

Tool Information: Syft

Syft version 1.44.0 was released on May 1, 2026, making it very recent and likely stable. Syft is a CLI tool for generating SBOMs for container images, filesystems, and archives that supports dozens of packaging ecosystems and multiple output formats (CycloneDX, SPDX, Syft JSON, and more) [::Context7_resolve-library-id::] [::Context7_query-docs::].

The PR's implementation aligns with standard syft usage patterns. Syft supports multiple simultaneous SBOM outputs using the format -o spdx-json=./spdx.json -o cyclonedx-json=./cdx.json [::Context7_query-docs::], which matches the approach taken in scripts/image-build/build-vyos-image where the code invokes syft to generate both CycloneDX JSON and SPDX JSON formats.

Architectural Refactoring Implications

Key Change: Moving SBOM generation from inside QEMU (guest VM) to the build host post-ISO assembly represents a significant architectural shift:

  1. Guest-to-Host Migration: The original approach created a "transfer disk" within QEMU to extract SBOMs from the guest environment. This PR removes that complexity by generating SBOMs from the final ISO directly on the build host.

  2. Simplified Build Process: Syft runs entirely offline with no cloud dependencies, making it safe to run during the Docker build stage without external network calls.

  3. Error Handling Change: The script now exits successfully (sys.exit(0)) even if exceptions were recorded, which differs from the previous behavior. This is a notable behavioral change that should be validated against the PR requirements.

Review Considerations

Critical Points for Review:

  1. Version Pinning: The Dockerfile pins syft to version 1.44.0 from cdn.vyos.io. This provides reproducibility but should be verified for:

    • Architecture compatibility across target platforms
    • Security/vulnerability status of this version
  2. Error Handling: The change from sys.exit(1) on exception to sys.exit(0) could mask build failures. Verify this aligns with T8542 requirements and doesn't suppress legitimate error conditions.

  3. No Functional Changes Claim: The PR is marked as a "refactoring (no functional changes)," but the exit behavior change is functional. This should be clarified or justified.

  4. Integration Points: The removal of the transfer-disk mechanism and related QEMU parameters represents a significant reduction in code (-137 lines) and eliminates a potential point of failure in the VM-based build process. [web_search::]

🔇 Additional comments (2)
scripts/check-qemu-install (1)

193-193: LGTM!

Also applies to: 650-650, 1307-1307

scripts/image-build/build-vyos-image (1)

3-3: LGTM!

Also applies to: 33-33, 724-727

Comment thread docker/Dockerfile
Comment on lines +351 to +354
# Install syft binary required for SBOM generation
RUN cd /tmp && curl -sSfL -o syft.tar.gz \
https://cdn.vyos.io/tools/syft_1.44.0_linux_$(dpkg-architecture -qDEB_HOST_ARCH).tar.gz; \
tar --extract --file=syft.tar.gz syft; mv syft /usr/local/bin/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
# Print the relevant section around the provided line numbers.
nl -ba docker/Dockerfile | sed -n '320,390p'

Repository: vyos/vyos-build

Length of output: 102


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "syft|SBOM|cdn\.vyos\.io/tools" docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 335


🏁 Script executed:

#!/bin/bash
set -euo pipefail
# Look for checksum or signature verification patterns in the Dockerfile
rg -n "(sha256sum|sha512sum|gpg|cosign|verify|checksums|SIGNATURE|sum -c|-c -)" docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 41


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "syft[_-]|/usr/local/bin/syft|SBOM generation" -S .

Repository: vyos/vyos-build

Length of output: 255


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "SYFT_VERSION" docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 41


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '330,370p' docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 1667


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "(sha256sum|sha512sum|sha1sum|gpg|gpgv|cosign|sigstore|verify|gpg --|--check|checksums)" docker/Dockerfile || true

Repository: vyos/vyos-build

Length of output: 41


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "curl .*tools/|cdn\.vyos\.io/tools/|tar --extract" docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 233


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '330,370p' docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 1667


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "(sha256sum|sha512sum|sha1sum|gpg|gpgv|cosign|sigstore|verify|gpg --|--check|checksums)" docker/Dockerfile || true

Repository: vyos/vyos-build

Length of output: 41


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "curl .*tools/|cdn\.vyos\.io/tools/|tar --extract" docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 233


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '330,370p' docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 1667


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "(sha256sum|sha512sum|sha1sum|gpg|gpgv|cosign|sigstore|verify|gpg --|--check|checksums)" docker/Dockerfile || true

Repository: vyos/vyos-build

Length of output: 41


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "curl .*tools/|cdn\.vyos\.io/tools/|tar --extract" docker/Dockerfile

Repository: vyos/vyos-build

Length of output: 233


Add integrity verification for downloaded syft (docker/Dockerfile 351-354).
The Dockerfile downloads the syft_1.44.0_linux_${arch}.tar.gz tarball and immediately extracts/moves the syft binary without checksum/signature verification; add verification using syft’s official release checksum (or signature) artifacts for the matching ${arch} before extracting/installing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker/Dockerfile` around lines 351 - 354, The Dockerfile currently downloads
syft_1.44.0_linux_$(dpkg-architecture -qDEB_HOST_ARCH).tar.gz to /tmp as
syft.tar.gz and extracts the syft binary to /usr/local/bin/syft without
integrity checks; update the RUN step to also download the matching release
checksum (or signature) artifact for that same ${arch} (e.g.,
syft_1.44.0_SHA256SUMS or a .sig), verify syft.tar.gz against the checksum (or
verify the checksum file signature with gpg) and fail the build if verification
fails, then proceed to tar --extract and mv syft /usr/local/bin/ only after
successful verification so the symbols syft.tar.gz,
syft_1.44.0_linux_$(dpkg-architecture -qDEB_HOST_ARCH).tar.gz, and
/usr/local/bin/syft are protected by integrity checks.

Comment thread scripts/image-build/build-vyos-image Outdated

@asklymenko asklymenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perform SBOM scan during the build process.

@sarthurdev sarthurdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Refactors SBOM generation. Not tested locally, trust Christian's testing.

@c-po
c-po force-pushed the spdx-refactoring branch from 590e6be to d7cb6d0 Compare May 28, 2026 20:14
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

@mergify mergify Bot added rolling and removed current VyOS rolling release labels Jun 1, 2026
@mergify

mergify Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 invalid-title label must be absent to merge

Waiting for

  • label != invalid-title
This rule is failing.

Block merge while the invalid-title label is present. The label is auto-toggled by the Flag T-ID format violation in PR title or commit messages rule when the PR title or any commit's first line does not match [scope: ]T<digits>: <text>. Must be cleared by amending the offending title/commit headline.

  • label != invalid-title

@c-po
c-po force-pushed the spdx-refactoring branch from d7cb6d0 to 75a495b Compare June 1, 2026 19:11
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

CI integration 👍 passed!

Details

CI logs

  • Config tests 👍 passed

@c-po c-po removed the invalid-title label Jun 2, 2026
@c-po
c-po merged commit 8669f15 into vyos:rolling Jun 2, 2026
12 of 14 checks passed
@vyos-bot vyos-bot Bot added mirror-initiated This PR initiated for mirror sync workflow mirror-completed and removed mirror-initiated This PR initiated for mirror sync workflow labels Jun 2, 2026
@c-po
c-po deleted the spdx-refactoring branch June 2, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants