Per-package SBOMs in `/var/lib/db/sbom` contain two apk components for the same package: which one should consumers use?

Aperta
#78,757 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
shell
Ambito
devtools

Direzione di ricerca

Start by examining the example SPDX document structure described in the issue, especially the DESCRIBES and nested CONTAINS relationships, and trace how the per-package SBOM is generated. The issue asks maintainers to clarify why both apk components appear and which represents the package; no source files or tests are identified. Done means answering those questions and determining whether the nested component should be retained or removed.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement needs-triage

Description

Each Wolfi package ships an SPDX document in /var/lib/db/sbom/<package>-<version>.spdx.json. In the documents we
looked at, the same package appears twice as an apk component, with two different purls. Example with
libgcc-16.2.0-r1.spdx.json from cgr.dev/chainguard/wolfi-base (created by Tool: chainguard-build (v0.59.0)):

SPDX element purl sourceInfo supplier
SPDXRef-Package-apk-libgcc-16.2.0-r1 pkg:apk/wolfi/[email protected]?arch=x86_64&distro=wolfi – Organization: Wolfi
SPDXRef-Package-apk-libgcc-bc08e9c4c69fba15 pkg:apk/wolfi/[email protected]?arch=x86_64&origin=gcc acquired package info from APK DB: /.PKGINFO Organization: chainguard

Relationships:

SPDXRef-DOCUMENT                     DESCRIBES  SPDXRef-Package-apk-libgcc-16.2.0-r1
SPDXRef-Package-apk-libgcc-16.2.0-r1 CONTAINS   SPDXRef-DocumentRoot-Directory-libgcc
SPDXRef-DocumentRoot-Directory-libgcc CONTAINS  SPDXRef-Package-apk-libgcc-bc08e9c4c69fba15
SPDXRef-Package-apk-libgcc-16.2.0-r1 DESCRIBED_BY   SPDXRef-Package-Melange-gcc.yaml-…
SPDXRef-Package-apk-libgcc-16.2.0-r1 GENERATED_FROM SPDXRef-Package-Source-gitlab.com-gnutools-gcc.git-…

The first component is the package the document describes, linked to its recipe and sources. The second one is
nested under a DocumentRoot-Directory element and looks like the result of scanning the package's own contents,
which finds the package's own .PKGINFO. 18 of the 19 documents in wolfi-base have this structure; the exception is
wolfi-base-1-r7.spdx.json (single apk component).

Why it matters

Scanners that read these documents see two components for one package.
Trivy keeps one of them at random, so the same image yields different purls from one
scan to the next (aquasecurity/trivy#11362). Downstream
tools that match components by purl (e.g. carrying vulnerability analysis decisions over between versions in
Dependency-Track) then see the same package change identity.

Before changing how Trivy reads these documents, its maintainers asked us to check with you why the second component
is there and which of the two is meant to describe the package.

Questions
  1. Why does a single document contain two apk components for the same package? Is the nested one an intended part
    of the format, or a side effect of scanning the package contents?
  2. Which component should SBOM consumers treat as the description of the package? Our reading is the one targeted
    by SPDXRef-DOCUMENT DESCRIBES (distro=wolfi).
  3. If the nested component is useful (e.g. the origin= qualifier as a link to the source package), could it be
    kept in a form that consumers can tell apart; otherwise, could it be dropped from the generated documents?
Related
  • wolfi-dev/wolfictl#1409 / wolfi-dev/wolfictl#1420: wolfictl scan found two APK packages in one .apk once its contents were
    scanned (ELF package notes); the elf-package cataloger was removed from that scan. Similar effect, here from the
    package's own .PKGINFO.
  • chainguard-dev/melange#2061 (not merged): Syft scan of package contents to enrich the SBOM, which would produce
    this kind of nested component.
  • anchore/syft#3662 / #3983: other non-package components of these documents (GENERATED_FROM upstream source,
    DESCRIBED_BY recipe) imported as packages by Syft.
  • aquasecurity/trivy#9865 and #10751 (fixed): non-determinism between the apk database and these documents; this
    report is about the duplicate inside a single document.

We'll report the answer back to the Trivy discussion. Thanks!

Lingua principale
Shell
Stelle
1.3k
Fork
453
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wolfi-dev/os

Tutte le issue di wolfi-dev/os

Issue simili

Altre issue su Shell/Bash

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.