8000 SPDX-2.2 validation by armintaenzertng · Pull Request #490 · spdx/tools-python · GitHub
[go: up one dir, main page]

Skip to content

SPDX-2.2 validation #490

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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[issue-463] restrict possible SPDX versions to supported versions
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
  • Loading branch information
armintaenzertng committed Feb 22, 2023
commit 5bc9ac900d808097a21b5b62ab4b8a239c8a105e
4 changes: 2 additions & 2 deletions src/spdx/validation/document_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def validate_full_spdx_document(document: Document, spdx_version: str = None) ->
if not spdx_version:
spdx_version = document_version

if not re.match(r"^SPDX-\d+.\d+$", document_version):
if document_version not in ["SPDX-2.2", "SPDX-2.3"]:
validation_messages.append(
ValidationMessage(
f'the document\'s spdx_version must be of the form "SPDX-[major].[minor]" but is: {document_version}',
f'only SPDX versions "SPDX-2.2" and "SPDX-2.3" are supported, but the document\'s spdx_version is: {document_version}',
context
)
)
Expand Down
6 changes: 3 additions & 3 deletions tests/spdx/validation/test_document_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def test_valid_document():
(creation_info_fixture(spdx_version="SPDX-2.3"), "SPDX2.3",
"provided SPDX version SPDX2.3 does not match the document's SPDX version SPDX-2.3"),
(creation_info_fixture(spdx_version="SPDX2.3"), "SPDX-2.3",
'the document\'s spdx_version must be of the form "SPDX-[major].[minor]" but is: SPDX2.3'),
'only SPDX versions "SPDX-2.2" and "SPDX-2.3" are supported, but the document\'s spdx_version is: SPDX2.3'),
(creation_info_fixture(spdx_version="SPDX2.3"), None,
'the document\'s spdx_version must be of the form "SPDX-[major].[minor]" but is: SPDX2.3'),
'only SPDX versions "SPDX-2.2" and "SPDX-2.3" are supported, but the document\'s spdx_version is: SPDX2.3'),
(creation_info_fixture(spdx_version="SPDX2.3"), "SPDX2.3",
'the document\'s spdx_version must be of the form "SPDX-[major].[minor]" but is: SPDX2.3'),
'only SPDX versions "SPDX-2.2" and "SPDX-2.3" are supported, but the document\'s spdx_version is: SPDX2.3'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add one more testcase for a document with version "SPDX-2.1"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

])
def test_spdx_version_handling(creation_info: CreationInfo, version_input: str, expected_message: Optional[str]):
document: Document = document_fixture(creation_info=creation_info)
Expand Down
0