Skip to content

Commit 1179b18

Browse files
committed
Add comments and explanation about the documentDescribes changes
Signed-off-by: tdruez <[email protected]>
1 parent 44217a5 commit 1179b18

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

scanpipe/pipes/output.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,20 @@ def to_spdx(project, include_files=False):
744744
for resource in get_queryset(project, "codebaseresource").files()
745745
]
746746

747+
# Use the Project (top-level package) as the root element that the SPDX document
748+
# describes.
749+
# This ensures "documentDescribes" points only to the main subject of the SBOM,
750+
# not to every dependency or file in the project.
751+
# See https://github.com/spdx/spdx-spec/issues/395 and
752+
# https://github.com/aboutcode-org/scancode.io/issues/564#issuecomment-3269296563
753+
# for detailed context.
754+
describes = [project_as_root_package.spdx_id]
755+
747756
document = spdx.Document(
748757
spdx_id=document_spdx_id,
749758
name=f"scancodeio_{project.name}",
750759
namespace=f"https://scancode.io/spdxdocs/{project.uuid}",
751-
describes=[project_as_root_package.spdx_id],
760+
describes=describes,
752761
creation_info=spdx.CreationInfo(tool=f"ScanCode.io-{scancodeio_version}"),
753762
packages=packages_as_spdx,
754763
files=files_as_spdx,

scanpipe/pipes/spdx.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,15 @@ class Document:
552552

553553
name: str
554554
namespace: str
555+
# "documentDescribes" identifies the root element(s) that this SPDX document
556+
# describes.
557+
# In most SBOM cases, this will be a single SPDX ID representing the top-level
558+
# package or project (e.g., the root manifest in a repository or the main
559+
# distribution artifact).
560+
# Although defined as an array, it should NOT list every package, file, or snippet.
561+
# Multiple entries are only expected in special, non-SBOM cases
562+
# (e.g., SPDX license lists).
563+
# See https://github.com/spdx/spdx-spec/issues/395 for discussion and clarification.
555564
describes: list
556565
creation_info: CreationInfo
557566
packages: list[Package]

0 commit comments

Comments
 (0)