Skip to content

Commit b331aeb

Browse files
authored
fix: allow suppliers with empty-string names (#611)
fixes #600 --------- Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent d081ffe commit b331aeb

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

cyclonedx/model/contact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class OrganizationalEntity:
279279
def __init__(self, *, name: Optional[str] = None, urls: Optional[Iterable[XsUri]] = None,
280280
contacts: Optional[Iterable[OrganizationalContact]] = None,
281281
address: Optional[PostalAddress] = None) -> None:
282-
if not name and not urls and not contacts:
282+
if name is None and not urls and not contacts:
283283
raise NoPropertiesProvidedException(
284284
'One of name, urls or contacts must be supplied for an OrganizationalEntity - none supplied.'
285285
)

tests/_data/own/json/1.4/empty_supplier.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_deserialize_json.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ def test_prepared(self, get_bom: Callable[[], Bom], *_: Any, **__: Any) -> None:
4545
self.assertBomDeepEqual(expected, bom,
4646
fuzzy_deps=get_bom in all_get_bom_funct_with_incomplete_deps)
4747

48+
def test_empty_supplier(self) -> None:
49+
"""Regression for issue #600
50+
See: https://github.com/CycloneDX/cyclonedx-python-lib/issues/600
51+
"""
52+
json_file = join(OWN_DATA_DIRECTORY, 'json', '1.4', 'empty_supplier.json')
53+
with open(json_file) as f:
54+
json = json_loads(f.read())
55+
bom = Bom.from_json(json)
56+
self.assertIsInstance(bom, Bom)
57+
4858
@data(SchemaVersion.V1_4, SchemaVersion.V1_3, SchemaVersion.V1_2)
4959
def test_mixed_licenses_before15(self, sv: SchemaVersion) -> None:
5060
# before CDX 1.5 it was allowed to mix `expression` and `license`

0 commit comments

Comments
 (0)