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

fix: allow suppliers with empty-string names #611

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion cyclonedx/model/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class OrganizationalEntity:
def __init__(self, *, name: Optional[str] = None, urls: Optional[Iterable[XsUri]] = None,
contacts: Optional[Iterable[OrganizationalContact]] = None,
address: Optional[PostalAddress] = None) -> None:
if not name and not urls and not contacts:
if name is None and not urls and not contacts:
raise NoPropertiesProvidedException(
'One of name, urls or contacts must be supplied for an OrganizationalEntity - none supplied.'
)
Expand Down
25 changes: 25 additions & 0 deletions tests/_data/own/json/1.4/empty_supplier.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests/test_deserialize_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ def test_prepared(self, get_bom: Callable[[], Bom], *_: Any, **__: Any) -> None:
self.assertBomDeepEqual(expected, bom,
fuzzy_deps=get_bom in all_get_bom_funct_with_incomplete_deps)

def test_empty_supplier(self) -> None:
"""Regression for issue #600
See: https://github.com/CycloneDX/cyclonedx-python-lib/issues/600
"""
json_file = join(OWN_DATA_DIRECTORY, 'json', '1.4', 'empty_supplier.json')
with open(json_file) as f:
json = json_loads(f.read())
bom = Bom.from_json(json)
self.assertIsInstance(bom, Bom)

@data(SchemaVersion.V1_4, SchemaVersion.V1_3, SchemaVersion.V1_2)
def test_mixed_licenses_before15(self, sv: SchemaVersion) -> None:
# before CDX 1.5 it was allowed to mix `expression` and `license`
Expand Down