Skip to content

Fix SBOM: Add missing packages#5961

Merged
eriknordmark merged 5 commits into
lf-edge:masterfrom
shjala:fix.sbom.once.again
May 20, 2026
Merged

Fix SBOM: Add missing packages#5961
eriknordmark merged 5 commits into
lf-edge:masterfrom
shjala:fix.sbom.once.again

Conversation

@shjala
Copy link
Copy Markdown
Member

@shjala shjala commented May 14, 2026

Description

EVE's SBOM was missing every package that was compiled from source rather than installed via apk add. Source-built artifacts (bpftrace, libtpms, swtpm, xen, grub, ipxe, etc.) leave no fingerprint that syft can detect, so the resulting SBOMs were silently incomplete.

This PR closes that gap in four stacked commits:

  1. pkg/alpine: register-sbom-pkg.sh helper that appends a minimal APK DB record (P/V/L/A/T/U fields) to <outdir>/lib/apk/db/installed so syft picks the package up.

  2. tools/check-sbom-coverage.sh + CI workflow: a pre-merge gate that scans every pkg/*/Dockerfile, counts external source fetches (ADD https://..., ADD --keep-git-dir=...) and register-sbom-pkg.sh calls, and fails the PR with a clear remediation message if a Dockerfile pulls external source but never registers it. A small allowlist (tools/sbom-coverage-allowlist.txt) covers legitimate exemptions (cross-compiler toolchain, optee-os cross build).

  3. All affected pkg/*/Dockerfile: 30+ source-built packages registered.

  4. Hash bumps: pinned updated pkg-image hashes.

PR dependencies

None.

How to test and validate this PR

Build-time:

  1. Build EVE end-to-end on amd64 and arm64:

    make pkgs && make eve

    All pkg images that previously built should still build.

  2. Confirm the CI check works:

    ./tools/check-sbom-coverage.sh   # passes on this branch

    Then temporarily inject a new ADD https://example.com/foo.tar.gz /tmp/foo.tgz into any pkg/*/Dockerfile without a register-sbom-pkg.sh call and re-run — the script should exit 1 with the remediation message. Revert after.

SBOM verification (the meat of the test):

  1. Generate the SBOM for the freshly built EVE rootfs:
    make sbom
  2. Confirm the following packages appear (they were absent before this PR):
    • bcc, bpftrace, lshw, hexedit, dnsmasq, zfs, fscrypt, gptfdisk, vboot, grub, guacamole-server, ossp-uuid, edid-decode, ddcutil, tpm2-tss, tpm2-tools, ipxe, makedumpfile, kexec-tools, mkinitfs, optee_client, watchdog, libqrtr-glib, libmbim, libqmi, ModemManager, picocom, lenovo-wwan-unlock, xen, liburing, seabios, libtpms, swtpm, u-boot, raspberrypi-firmware, imx-atf, firmware-imx, uboot-imx, wireless-regdb, linux-firmware, rtw88-firmware, hailo8-firmware, nvidia-l4t-firmware, rpi-firmware-nonfree, rpi-bluez-firmware, intel-ucode, amd-ucode, edk2, VfioIgdPkg, opensbi, etcdctl, virtctl, eve-monitor-rs, jetson-linux, nvidia-container-toolkit, vector.

Changelog notes

N/A

PR Backports

  • 16.0-stable
  • 14.5-stable
  • 13.4-stable

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't check them.

shjala and others added 4 commits May 14, 2026 13:20
Packages built from source are invisible to syft because they bypass
the APK package manager and leave no entry in the APK database. Syft's
apk-db-cataloger reads lib/apk/db/installed to discover packages, so
source-built packages are silently omitted from the SBOM.

Add register-sbom-pkg.sh, a small script that writes a minimal APK
database entry for a source-built package into the output root.

Signed-off-by: Shahriyar Jalayeri <shahriyar@posteo.de>
A heuristic check that scans every pkg/*/Dockerfile for external source
fetches (ADD https://..., ADD --keep-git-dir=...) and fails if the same
Dockerfile does not call register-sbom-pkg.sh, ensuring new
compile-from-source dependencies cannot slip into the rootfs without a
matching SBOM entry. Toolchain Dockerfiles that legitimately never ship
in the final image are listed in tools/sbom-coverage-allowlist.txt with
a justification.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Shahriyar Jalayeri <shahriyar@posteo.de>
For every pkg whose Dockerfile compiles or downloads an external artifact
that ends up in the EVE rootfs, call register-sbom-pkg.sh after the build
step so syft's apk-db-cataloger picks it up. Stages whose final image is
FROM scratch and does not COPY /out/ wholesale also explicitly copy
/lib/apk/db/installed so the entries reach the final image. The pillar
collector concatenates each contributing pkg's apk DB into one merged
installed file to avoid the Docker COPY overwrite that previously kept
only whichever pkg was copied last.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Shahriyar Jalayeri <shahriyar@posteo.de>
Run tools/bump_dockerfiles.pl to propagate the new pkg-image hashes
produced by the SBOM coverage changes. The pillar collector merge logic
relies on lfedge/eve-{uefi,dom0-ztools,fscrypt,dnsmasq,gpt-tools}
shipping /lib/apk/db/installed at the image root, which only happens at
the new hashes; the older pins predate the register-sbom-pkg.sh work.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Shahriyar Jalayeri <shahriyar@posteo.de>
@shjala shjala changed the title Fix.SBOM.once.again Fix SBOM, Add missing packages May 14, 2026
@shjala shjala changed the title Fix SBOM, Add missing packages Fix SBOM: Add missing packages May 14, 2026
@shjala shjala marked this pull request as draft May 14, 2026 12:39
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 20.90%. Comparing base (d093be1) to head (9c02d1a).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5961      +/-   ##
==========================================
+ Coverage   20.50%   20.90%   +0.40%     
==========================================
  Files         487      497      +10     
  Lines       90131    91829    +1698     
==========================================
+ Hits        18482    19201     +719     
- Misses      70095    70888     +793     
- Partials     1554     1740     +186     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shjala shjala marked this pull request as ready for review May 18, 2026 14:39
@shjala
Copy link
Copy Markdown
Member Author

shjala commented May 18, 2026

@rene spdx-check fails because I copied the header from another file and forgot to update the year to 2026, can we make an exception and ignore this one? Otherwise I have to update lots of image hashes again.

Yestus fails on code that I haven't changed, Claude Code fails because of some token issue.

Update eve-debug image hash in pillar.

Signed-off-by: Shahriyar Jalayeri <shahriyar@posteo.de>
@shjala shjala force-pushed the fix.sbom.once.again branch from 9cf284b to 9c02d1a Compare May 18, 2026 14:44
Copy link
Copy Markdown
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM but should we backport this to stable branches to make those SBoM more accurate as well?

@shjala shjala added the stable Should be backported to stable release(s) label May 20, 2026
@shjala
Copy link
Copy Markdown
Member Author

shjala commented May 20, 2026

LGTM but should we backport this to stable branches to make those SBoM more accurate as well?

sure, I've listed the releases under "PR Backports".

@eriknordmark eriknordmark merged commit c73e772 into lf-edge:master May 20, 2026
40 of 50 checks passed
@europaul
Copy link
Copy Markdown
Contributor

@shjala please wait with the backports, I think this PR produces an incomplete apk database which later leads to segfault when somebody tries to apk purge some package that was built from source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable Should be backported to stable release(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants