Skip to content
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

SPDX-2.2 validation #490

Merged

Conversation

armintaenzertng
Copy link
Collaborator

fixes #463

Copy link
Collaborator

@meretp meretp left a comment

Choose a reason for hiding this comment

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

Thanks for the additions! I have only four small remarks and two more general:
With the version-specific validation I think it would make sense to think about a class-based implementation again. With that you could instantiate a Validator class with a specific version instead of passing the version every time as an argument. With more different versions, one could then further think about a base Validator and version-specific Validators as child classes. However, since there is not much more to add here and the argument of the additional parameter passing is also not that strong for now, this change is not really necessary. Maybe in a future refactoring.
Another remark concerning the cli-tool: I don't like the fact that a document with version "SPDX-2.1" is marked as invalid. I would prefer to catch the not supported versions earlier in that case. It makes sense to also have this validation in validate_full_spdx_document for library users but for the cli we should add some additional logic.

Comment on lines 63 to 66
ValidationMessage(
f"{checksum.algorithm.name} is not supported in SPDX-2.2", context)
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should return here as the algorithm is not valid.

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

@@ -48,6 +48,6 @@ def validate_creation_info(creation_info: CreationInfo) -> List[ValidationMessag

validation_messages.extend(validate_actors(creation_info.creators, creation_info.spdx_id))

validation_messages.extend(validate_external_document_refs(creation_info.external_document_refs, creation_info.spdx_id))
validation_messages.extend(validate_external_document_refs(creation_info.external_document_refs, creation_info.spdx_id, spdx_version))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Auto formatting inserts a line break here.

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

Comment on lines 87 to 91
if spdx_version == "SPDX-2.2" and reference_type in ["advisory", "fix", "url", "swid"]:
validation_messages.append(
ValidationMessage(f'externalPackageRef type "{reference_type}" is not supported in SPDX-2.2', context)
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would move this validation to the beginning and return. I don't think that it makes sense to first validate references on a lower level and afterwards check if they are valid in general.

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

(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

Copy link
Collaborator

@meretp meretp left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing my remarks!

@armintaenzertng armintaenzertng merged commit c8fd2d7 into spdx:refactor-python-tools Feb 22, 2023
@armintaenzertng armintaenzertng deleted the spdx2-2Validation branch February 22, 2023 15:31
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