Skip to content

Issue 503 allow list with noassertion #505

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

Conversation

meretp
Copy link
Collaborator

@meretp meretp commented Mar 3, 2023

fixes #503

@meretp meretp force-pushed the issue-503-allow-list-with-noassertion branch 3 times, most recently from 47b7081 to b0c73a0 Compare March 9, 2023 16:07
Copy link
Collaborator

@armintaenzertng armintaenzertng 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 this!
I found a few places that still can be adapted. Also, we can simplify the file_converter, package_converter and snippet_converter files in the jsonschema package.

@@ -19,12 +19,11 @@
from spdx.validation.validation_message import ValidationMessage, ValidationContext, SpdxElementType


def validate_license_expressions(license_expressions: Optional[
Union[List[LicenseExpression], SpdxNoAssertion, SpdxNone]], document: Document, parent_id: str) -> List[ValidationMessage]:
if license_expressions in [SpdxNoAssertion(), SpdxNone(), None]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

The None case is missing now in the new code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is no None case, only an empty list, I fixed the type hint.

@@ -53,7 +54,7 @@ def parse_file(self, file_dict: Dict) -> Optional[File]:
lambda x: parse_field_or_no_assertion_or_none(x, self.license_expression_parser.parse_license_expression))

license_info_in_files: Optional[
Union[List[LicenseExpression], SpdxNoAssertion, SpdxNone]] = parse_field_or_log_error(
List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]]] = parse_field_or_log_error(
logger, file_dict.get("licenseInfoInFiles"),
lambda x: parse_field_or_no_assertion_or_none(x, self.license_expression_parser.parse_license_expressions))
Copy link
Collaborator

Choose a reason for hiding this comment

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

We still use parse_field_or_no_assertion_or_none here; I don't think that is needed anymore, as parse_license_expressions only returns lists now. Use field_is_list=True instead?

See also the package and snippet parser.

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

@@ -85,7 +87,7 @@ def package_fixture(spdx_id="SPDXRef-Package", name="packageName", download_loca
valid_until_date=datetime(2022, 12, 3)) -> Package:
checksums = [checksum_fixture()] if checksums is None else checksums
license_info_from_files = [get_spdx_licensing().parse("MIT"), get_spdx_licensing().parse(
"GPL-2.0")] if license_info_from_files is None else license_info_from_files
"GPL-2.0"), SpdxNoAssertion()] if license_info_from_files is None else license_info_from_files
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like to have one of these SpdxNoAssertion()s be SpdxNone(), just to have that covered in the tests, too.

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

@@ -138,48 +140,7 @@
</spdx:Package>
<spdx:Package rdf:about="https://some.namespace#SPDXRef-Package2">
<spdx:name>packageName</spdx:name>
<spdx:releaseDate>2022-12-01T00:00:00Z</spdx:releaseDate>
<spdx:supplier>Person: supplierName (some@mail.com)</spdx:supplier>
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason to delete almost everything from this package in the first place but then not deleting it fully?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We use the second package to test different values in ExternalPackageRef (see test_package_parser.py). While working on this I decided that we don't need all these other fields in the second package and deleted it. I admit that this is not really related to the issue...

Copy link
Collaborator

@armintaenzertng armintaenzertng left a comment

Choose a reason for hiding this comment

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

Thanks, only a small remark.

Comment on lines 75 to 76
license_concluded = parse_field_or_log_error(
logger, package_dict.get("licenseConcluded"),
lambda x: parse_field_or_no_assertion_or_none(x, self.license_expression_parser.parse_license_expression),
None)
logger, package_dict.get("licenseConcluded"), self.license_expression_parser.parse_license_expression, None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The None value is default anyway and license_concluded has not type hint

@meretp meretp force-pushed the issue-503-allow-list-with-noassertion branch from d107739 to b5df9e1 Compare March 10, 2023 15:42
meretp added 5 commits March 10, 2023 16:52
…ression, SpdxNone or SpdxNoAssertion

Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
… cases for LicenseInfoFromFiles, LicenseInfoInFile and LicenseInfoInSnippet

Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
@meretp meretp force-pushed the issue-503-allow-list-with-noassertion branch from b5df9e1 to e8aa932 Compare March 10, 2023 15:53
@meretp meretp merged commit 8d2f497 into spdx:refactor-python-tools Mar 10, 2023
@meretp meretp deleted the issue-503-allow-list-with-noassertion branch March 13, 2023 14:34
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.

Allow List with NOASSERTION/ NONE for PackageLicenseInfoFromFiles, LicenseInfoInSnippet and LicenseInfoInFile
2 participants