Add script to check SBOM file coverage of an installed Qt


Audits the SBOM documents under <prefix>/sbom against the files an
installed Qt actually ships, in both directions: every shipped binary
should be recorded in some document, and every recorded file should
exist on disk as a plain, non-empty, exactly named file. A third check
verifies that each module ships the full set of SBOM formats, since a
module without a *.cdx.json has no CycloneDX coverage at all.

Coverage is computed from the *.spdx.json documents rather than the
*.cdx.json ones, because only the SPDX documents carry file-level data:
Qt's CycloneDX output describes packages only and does not populate
evidence.occurrences. Both formats are emitted from the same component
set, so a file missing from the SPDX documents is missing from the
CycloneDX ones too. The CycloneDX occurrence count is reported anyway,
so that a change there stays visible.

Files are classified by magic bytes instead of by extension, because
macOS framework binaries and Qt's universal static libraries have no
recognizable suffix - a universal .a is a fat Mach-O, not '!<arch>'.
Symlinks are skipped so that frameworks and versioned dylibs are not
counted several times, and recorded paths are also compared against the
real directory entries, since os.path.exists ignores case on APFS and
NTFS.

The forward check defaults to bin, lib, libexec, plugins, qml and
translations, the directories the SPDX documents record into; walking
the whole prefix instead turns up no further binaries. The reverse
check always covers the whole prefix.

Exits non-zero if a binary is unrecorded or a recorded file is missing.
Unrecorded scripts and data files, and incomplete document sets, are
reported only. --verify-sha1 additionally compares recorded checksums
with disk, where mismatches on code-signed Mach-O binaries are expected
in an installed tree: installers re-sign and relocate those after the
SBOM checksums are written, while static libraries and data files
should always match.

Task-number: QTBUG-149812
Task-number: QTBUG-149805
Change-Id: I4bad30a5aa7aac2ecd934339b484b40cda5ccd5a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
commit2a45c94bcacc6b9b44042129d2965319a6dfc690
parent6644c3b3132981e04ef7de966b7f242635aa578c
authorKai Köhne <kai.koehne@qt.io>
committerKai Köhne <kai.koehne@qt.io>
commit timeThu, 3 Sep 2026 14:28:15 +0000