Skip to content

Fix an issues with SpdxPackage._verify()#71

Merged
goneall merged 1 commit into
spdx:mainfrom
fviernau:spdx-package-verify-drop-invalid-check
Jun 12, 2026
Merged

Fix an issues with SpdxPackage._verify()#71
goneall merged 1 commit into
spdx:mainfrom
fviernau:spdx-package-verify-drop-invalid-check

Conversation

@fviernau

Copy link
Copy Markdown
Contributor

The specification for SPDX v2.3 seems to not require that for each SpdxPackage all files which in reality correspond to that package have to be included as SpdxFile in case files have been analyzed, namely filesAnalyzed is set to true [1]. This allows the freedom for the creator of on SPDX document to only selectively include certain files. For example, a tool may analyze all files of a package for license texts, but choose to only selectively include certain files containing license texts as SpdxFile entry into the SPDX document, for example to reduce the size of the SPDX document a bit, or to omit information which is less relevant in the given context.

This implies, that it should also be valid to not include any files for a package even though its files have been analyzed. However, _verify() complains if filesAnalyzed && files.size() == 0 which seems incorrect. Drop that check to align with the spec.

[1] https://spdx.github.io/spdx-spec/v2.3/package-information/#78-files-analyzed-field

The specification for SPDX v2.3 seems to not require that for each
`SpdxPackage` all files which in reality correspond to that package
have to be included as `SpdxFile` in case files have been analyzed,
namely `filesAnalyzed` is set to `true` [1]. This allows the freedom
for the creator of on SPDX document to only selectively include certain
files. For example, a tool may analyze all files of a package for
license texts, but choose to only selectively include certain files
containing license texts as `SpdxFile` entry into the SPDX document,
for example to reduce the size of the SPDX document a bit, or to omit
information which is less relevant in the given context.

This implies, that it should also be valid to not include any files for
a package at all, even though its files have been analyzed. However,
`_verify()` complains if `filesAnalyzed && files.size() == 0` which
seems incorrect. Drop that check to align with the spec.

[1] https://spdx.github.io/spdx-spec/v2.3/package-information/#78-files-analyzed-field

Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
@fviernau fviernau force-pushed the spdx-package-verify-drop-invalid-check branch from 4a4c472 to 09f6b3b Compare June 11, 2026 13:45
@tsteenbe tsteenbe requested a review from goneall June 12, 2026 03:16
@goneall

goneall commented Jun 12, 2026

Copy link
Copy Markdown
Member

In reviewing the spec, I tend to agree that it is valid for there to be no files and filesAnalyzed being true.

@goneall goneall merged commit b291d70 into spdx:main Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants