diff --git a/cyclonedx/model/contact.py b/cyclonedx/model/contact.py index 91f612f9..8407f7d8 100644 --- a/cyclonedx/model/contact.py +++ b/cyclonedx/model/contact.py @@ -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.' ) diff --git a/tests/_data/own/json/1.4/empty_supplier.json b/tests/_data/own/json/1.4/empty_supplier.json new file mode 100644 index 00000000..cbcfc02a --- /dev/null +++ b/tests/_data/own/json/1.4/empty_supplier.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://cyclonedx.org/schema/bom-1.4.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.4", + "serialNumber": "urn:uuid:fa1bcbf6-686e-44d7-b9e0-df9baeef5715", + "version": 1337, + "metadata": { + "supplier": { + "name": "" + }, + "component": { + "type": "file", + "name": "regression issue #600", + "supplier": { + "name": "" + }, + "externalReferences": [ + { + "type": "other", + "url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues/600" + } + ] + } + } +} diff --git a/tests/test_deserialize_json.py b/tests/test_deserialize_json.py index c85664b0..9c5ad40e 100644 --- a/tests/test_deserialize_json.py +++ b/tests/test_deserialize_json.py @@ -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`