Skip to content

Commit

Permalink
fix: allow suppliers with empty-string names (#611)
Browse files Browse the repository at this point in the history
fixes #600

---------

Signed-off-by: Jan Kowalleck <[email protected]>
  • Loading branch information
jkowalleck authored May 6, 2024
1 parent d081ffe commit b331aeb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
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

0 comments on commit b331aeb

Please sign in to comment.