Skip to content

fix(output): CycloneDX reports omit OS packages and their vulnerabilities #3218

Open

Description

@coygeek

Summary

--format cyclonedx-* leaves every OS-ecosystem package out of the report, along with the vulnerabilities attached to those packages. A scan of a Debian-based image finds 88 Debian packages and 85 vulnerability IDs, but its CycloneDX output lists one component (pip) and an empty vulnerabilities array. The only other signal is one stderr warning per package and, when vulnerabilities exist, exit code 1.

Runtime or environment

  • OSV-Scanner v2.7.0 from Homebrew (osv-scalibr 0.5.3), and main at dcbda879b9129945362b1513c08ed5c0282c374e built with go build ./cmd/osv-scanner
  • macOS arm64, scanning linux/arm64 image variants saved with crane pull
  • Run on 2026-11-04. Vulnerability counts depend on OSV data at that time.

Steps to reproduce

crane pull --platform linux/arm64 python@sha256:e2dc9a4f015cd2409b9ce7d9b1d258f608851daa73ccf8d3f06ac6b80fc4a6c3 python.tar

osv-scanner scan image --archive --all-packages --format cyclonedx-1-5 python.tar > cdx.json 2> cdx.err; echo "exit $?"
jq -c '{components: [.components[].purl], vulnerabilities: (.vulnerabilities | length)}' cdx.json
grep -c 'Failed to parse package URL' cdx.err

osv-scanner scan image --archive --all-packages --format json python.tar > scan.json
jq -c '{debian_packages: ([.results[].packages[] | select(.package.ecosystem | startswith("Debian"))] | length), with_purl: ([.results[].packages[] | select(.package.ecosystem | startswith("Debian")) | select(.package.purl)] | length), vulnerability_ids: ([.results[].packages[].vulnerabilities[]?.id] | unique | length)}' scan.json

osv-scanner scan image --archive --all-packages --format spdx-2-3 python.tar > spdx.json
jq '[.packages[].externalRefs[]? | select(.referenceType == "purl")] | length' spdx.json

The digest pins a Python 3.15.2 slim image on Debian 13. The case has not been minimized.

Expected behavior

The CycloneDX report lists the OS packages the scan found and the vulnerabilities matched to them. docs/scan-image.md says output-format flags apply to scan image and that it scans for OS packages. The CycloneDX section of docs/output.md documents --format cyclonedx-1-5 --all-packages with no stated exclusion, and its sample includes components and vulnerabilities. The SPDX section states its own limit, that it omits vulnerability information.

Actual behavior

Both tested builds give the same result for the commands above:

exit 1
{"components":["pkg:pypi/pip@26.2.2"],"vulnerabilities":0}
88
{"debian_packages":88,"with_purl":88,"vulnerability_ids":85}
90

cdx.err has 88 lines of this form:

Failed to parse package URL: unable to determine purl type of adduser@3.152 (Debian:13)

The same scan's JSON output gives that package the purl pkg:deb/debian/adduser@3.152?arch=all&distro=trixie.

Without --all-packages, the CycloneDX report has 0 components and 0 vulnerabilities and the command still exits 1. cyclonedx-1-6 gives the same result as cyclonedx-1-5 on both tested builds. cyclonedx-1-4 and cyclonedx-1-7 give the same result on v2.7.0, the only build where I ran them.

Other images on v2.7.0, by index digest:

Image OS packages in JSON Vulnerability IDs in JSON CycloneDX components CycloneDX vulnerabilities Warnings
alpine:3.22 (sha256:2e0b81d60597f449baa56dc25d355367869d2dca4cd57e866f1e2b52af3eb55f) 16 0 0 0 16
ubuntu:24.04 (sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852) 92 42 0 0 92
almalinux:9 (sha256:245f8aab832fe800aa42bdab5fad75ebbd8e0b4c9f24820a83c638b177857ae2) 159 24 9 (all PyPI) 23 159

As a control, scan source --all-packages on a directory holding a requirements.txt with jinja2==2.4.1 gives 1 CycloneDX component, 18 vulnerabilities and no warnings on v2.7.0, so the format reports vulnerabilities for an ecosystem it can map.

Evidence

  • Expected source: the docs/scan-image.md and docs/output.md sections linked above.
  • Failure source: the executed runs above, with FromPackage as the source of the warning text. It returns that error for any ecosystem missing from EcosystemToPURLMapper, which lists only language ecosystems. Group then skips the package, and cycloneDXReporter.PrintResult logs the error and returns nil. I read this path and did not test a patched build.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Restoration check

Today the steps above give 1 CycloneDX component and 0 vulnerabilities for this image. After restoration, the report should list the 88 Debian packages as components alongside pkg:pypi/pip@26.2.2, and every vulnerability ID from the JSON output should appear in vulnerabilities. As a control, the jinja2==2.4.1 source scan should keep its component and vulnerabilities, and an Alpine or Ubuntu image should also list its OS packages.

Additional context

The test suite already records this. internal/output/cyclonedx_test.go says "some packages cannot currently be represented (such as those from OS ecosystems which we cannot determine a PURL for), which is reported as an error after the rest of the output has been written", and its snapshots hold those errors. I found no statement of this limit in docs/output.md, docs/scan-image.md or docs/usage.md, which is why I am reporting it as a bug. The stated reason also no longer seems to apply to image scans, since the JSON output has a purl for all 88 Debian packages and the SPDX output has 90 purls including those packages. If the omission is meant to stay, users would still need it documented and a warning that names it, because "Failed to parse package URL" does not say the package was left out of the report.

References

Triage assessment

  • Impact level: P1
  • Assessment status: supported
  • Impact basis: For the four OS ecosystems tested, a CycloneDX report omits every OS package and its vulnerabilities, so a consumer that reads only the report sees 0 of the 85 vulnerability IDs on the Debian image. It affects CycloneDX output from scans containing OS packages; JSON and SPDX output kept those packages. Exit code 1 and stderr warnings remain, but neither is part of the report.
  • Workaround status: none
  • Workaround basis: --format json keeps the packages and vulnerabilities and --format spdx-2-3 keeps the packages, but neither gives a CycloneDX consumer a CycloneDX document, and the code path above has no option that keeps these packages.

Activity

  1. G-Rath commented on Nov 4, 2026

    @G-Rath
    Collaborator

    yeah this format is broken in a few ways - I'm working on an internal task around putting together a plan for addressing that

  2. self-assigned this
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions