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

[issue-788] fix tag-value parser to allow NONE and NOASSERTION for pa… #816

Merged
merged 4 commits into from
Aug 23, 2024

Conversation

meretp
Copy link
Collaborator

@meretp meretp commented Aug 2, 2024

…ckage source info as they are valid strings

fixes 788

Signed-off-by: Meret Behrens [email protected]

@meretp
Copy link
Collaborator Author

meretp commented Aug 2, 2024

based this PR on #814 to (hopefully) have a successful CI

@meretp meretp marked this pull request as ready for review August 2, 2024 13:53
@@ -180,7 +180,7 @@ def p_current_element_error(self, p):
"file_comment : FILE_COMMENT text_or_line\n "
"file_license_concluded : FILE_LICENSE_CONCLUDED license_or_no_assertion_or_none\n "
"package_name : PKG_NAME LINE\n description : PKG_DESCRIPTION text_or_line\n "
"summary : PKG_SUMMARY text_or_line\n source_info : PKG_SOURCE_INFO text_or_line\n "
"summary : PKG_SUMMARY text_or_line\n source_info : PKG_SOURCE_INFO text_or_line_including_no_assertion\n "
Copy link
Collaborator

Choose a reason for hiding this comment

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

The problem at hand can also occur for other text_or_line fields apart from source_info. Basically all properties that use text_or_line. So I would believe that the whole text_or_line property has to be adapted, not only for the source information case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, the same problem will arise when somebody uses NONE. So best solve this one here, 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.

Right, I changed the behaviour such that text_or_line parses NOASSERTION and NONE as regular strings and for fields that allow NOASSERTION or NONE, like the license fields these strings will be serialized as the corresponding SpdxNoAssertion and SpdxNone objects

@@ -83,6 +83,26 @@ def test_parse_package():
assert package.valid_until_date == datetime(2022, 1, 1, 12)


def test_parse_package_with_no_assertion_as_source_info():
Copy link
Collaborator

@armintaenzertng armintaenzertng Aug 9, 2024

Choose a reason for hiding this comment

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

Ideally, this test should include all fields that can sport text only, all filled with either NONE or NOASSERTION. Might be bit overkill, though.
However, at least a field filled with NONE should be present, I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding all cases would be overkill imho but I added a field that contains NONE and is parsed as text.

@@ -83,6 +83,26 @@ def test_parse_package():
assert package.valid_until_date == datetime(2022, 1, 1, 12)


def test_parse_package_with_no_assertion_as_source_info():
Copy link
Collaborator

Choose a reason for hiding this comment

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

We might want to rename this to test_parse_none_and_no_assertion_as_text or something. Otherwise we emphasize the source info despite it not being a special case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree, I also moved the test to the test_tag_valu_parser.pymodule as it is not specific to packages.

@meretp meretp force-pushed the noassertion-handling branch 2 times, most recently from 43fde85 to 1ab91dd Compare August 16, 2024 06:54
…ckage source info as they are valid strings

Signed-off-by: Meret Behrens <[email protected]>

# fixes 788
…ckage source info as they are valid strings

Signed-off-by: Meret Behrens <[email protected]>
Signed-off-by: Meret Behrens <[email protected]>
@maxhbr
Copy link
Member

maxhbr commented Aug 22, 2024

@meretp & @armintaenzertng : can this be merged?

@armintaenzertng armintaenzertng merged commit 1973ce1 into spdx:main Aug 23, 2024
32 checks 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.

3 participants