-
-
Notifications
You must be signed in to change notification settings - Fork 128
SPDX 2.2 support and documentDescribes update to reference root element only #1856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
79bf654
Set documentDescribes to reference the root SPDX element(s) only
tdruez 45e54ab
Rework the implementation of documentDescribes in SPDX module
tdruez 5f985e2
Fix unit tests following the documentDescribes refactoring
tdruez 44217a5
Handle licenses with empty license test in SPDX library
tdruez 1179b18
Add comments and explanation about the documentDescribes changes
tdruez 80c090f
Use Project inputs as root elements that the SPDX document describes
tdruez 9746835
Fallback to the Project as the SPDX root element when needed
tdruez 3752d1e
Add full support for SPDX 2.2 spec version
tdruez 25c02b5
Fix code format
tdruez c401144
Adapt the documentDescribes behavior if multiple Project inputs
tdruez 6791179
Merge branch 'main' into 1727-sca-integration-ort-spdx
tdruez 13d508c
Fix the SPDX download button rendering
tdruez 5e333ac
Merge branch 'main' into 1727-sca-integration-ort-spdx
tdruez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,10 @@ def setUp(self): | |
| "https://license1.homepage", | ||
| ], | ||
| } | ||
| self.project_as_root_package_data = { | ||
| "spdx_id": "SPDXRef-project", | ||
| "name": "Project", | ||
| } | ||
| self.package_data = { | ||
| "spdx_id": "SPDXRef-package1", | ||
| "name": "lxml", | ||
|
|
@@ -170,7 +174,9 @@ def setUp(self): | |
| "name": "Document name", | ||
| "namespace": "https://[CreatorWebsite]/[DocumentName]-[UUID]", | ||
| "creation_info": spdx.CreationInfo(**self.creation_info_data), | ||
| "describes": [self.project_as_root_package_data["spdx_id"]], | ||
| "packages": [ | ||
| spdx.Package(**self.project_as_root_package_data), | ||
| spdx.Package(**self.package_data), | ||
| ], | ||
| "extracted_licenses": [ | ||
|
|
@@ -190,6 +196,7 @@ def setUp(self): | |
| "SPDXID": "SPDXRef-DOCUMENT", | ||
| "name": "document_name", | ||
| "documentNamespace": "https://[CreatorWebsite]/[DocumentName]-[UUID]", | ||
| "documentDescribes": ["SPDXRef-project"], | ||
| "creationInfo": { | ||
| "created": "2022-09-21T13:50:20Z", | ||
| "creators": [ | ||
|
|
@@ -201,6 +208,15 @@ def setUp(self): | |
| "comment": "Generated with SPDXCode", | ||
| }, | ||
| "packages": [ | ||
| { | ||
| "name": "Project", | ||
| "SPDXID": "SPDXRef-project", | ||
| "downloadLocation": "NOASSERTION", | ||
| "licenseConcluded": "NOASSERTION", | ||
| "copyrightText": "NOASSERTION", | ||
| "filesAnalyzed": False, | ||
| "licenseDeclared": "NOASSERTION", | ||
| }, | ||
| { | ||
| "name": "lxml", | ||
| "SPDXID": "SPDXRef-package1", | ||
|
|
@@ -228,7 +244,7 @@ def setUp(self): | |
| "referenceLocator": "pkg:pypi/[email protected]", | ||
| } | ||
| ], | ||
| } | ||
| }, | ||
| ], | ||
| "files": [ | ||
| { | ||
|
|
@@ -247,7 +263,6 @@ def setUp(self): | |
| "licenseComments": "license_comments", | ||
| } | ||
| ], | ||
| "documentDescribes": ["SPDXRef-package1"], | ||
| "hasExtractedLicensingInfos": [ | ||
| { | ||
| "licenseId": "LicenseRef-1", | ||
|
|
@@ -303,6 +318,15 @@ def test_spdx_extracted_licensing_info_as_dict(self): | |
| licensing_info = spdx.ExtractedLicensingInfo(**self.licensing_info_data) | ||
| assert self.licensing_info_spdx_data == licensing_info.as_dict() | ||
|
|
||
| def test_spdx_extracted_licensing_info_empty_extracted_text(self): | ||
| licensing_info = spdx.ExtractedLicensingInfo( | ||
| **{ | ||
| "license_id": "LicenseRef-1", | ||
| "extracted_text": " ", | ||
| } | ||
| ) | ||
| assert "NOASSERTION" == licensing_info.as_dict()["extractedText"] | ||
|
|
||
| def test_spdx_extracted_licensing_info_from_data(self): | ||
| assert spdx.ExtractedLicensingInfo.from_data({}) | ||
| licensing_info = spdx.ExtractedLicensingInfo.from_data( | ||
|
|
@@ -353,7 +377,7 @@ def test_spdx_relationship_from_data(self): | |
|
|
||
| def test_spdx_document_as_dict(self): | ||
| document = spdx.Document(**self.document_data) | ||
| assert self.document_spdx_data == document.as_dict() | ||
| assert self.document_spdx_data == document.as_dict(), document.as_dict() | ||
|
|
||
| def test_spdx_relationship_is_dependency_relationship_property(self): | ||
| relationship = spdx.Relationship.from_data(self.relationship_spdx_data) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tdruez Using
project_as_root_packageis incorrect imo as it's possible in ScanCode.io to upload multiple archives as such there would be multiple root packages so variable should beprojects_as_root_packagesasdocumentDescribesshould be array of SPDX packages (one for each archive). E.g upload 5 archives to ScanCode.io in a project than there should be 5 SPDX root elements indocumentDescribesof the resulting SPDX file.In case ScanCode.io is given a single PURL for code repository as it's project input such as
pkg:github/package-url/purl-spec@244fd47e07d1004f0aed9cthendocumentDescribesis still an array but should only contain a single package for the code repository that was scanned, see the comment of SPDX maintainer Rose spdx/spdx-spec#395 (comment).If a single SPDX of Cyclone SBOM was provided as ScanCode.io input for a project then
documentDescribesshould point to the SPDX package for provided SBOM imo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsteenbe The code was adjusted to use the Project's input as the root package, addressing those 2 points.
The following forms of input are supported:
download_url,purl,docker,git, ...)Now, for the multiple inputs case, this will require additional design work and likely some changes in the SCIO architecture to properly track
CodebaseResourceandDiscoveredPackageobjects back to theirinputorigin.This will be handled in a separate PR, since it first requires further discussion.
Also, note that projects with multiple inputs (e.g. when using the
deploy_to_developpipeline) are not expected to fetch SPDX documents.