diff --git a/cyclonedx/model/__init__.py b/cyclonedx/model/__init__.py index 2c62ac56..282cdd91 100644 --- a/cyclonedx/model/__init__.py +++ b/cyclonedx/model/__init__.py @@ -150,11 +150,14 @@ class ExternalReference: _hashes: List[HashType] = [] def __init__(self, reference_type: ExternalReferenceType, url: str, comment: str = None, - hashes: List[HashType] = []): + hashes: List[HashType] = None): self._reference_type = reference_type self._url = url self._comment = comment - self._hashes = hashes + if not hashes: + self._hashes.clear() + else: + self._hashes = hashes def add_hash(self, our_hash: HashType): """ diff --git a/tests/test_parser_pipenv.py b/tests/test_parser_pipenv.py index be139718..fb4904c3 100644 --- a/tests/test_parser_pipenv.py +++ b/tests/test_parser_pipenv.py @@ -34,3 +34,4 @@ def test_simple(self): self.assertEqual('toml', components[0].get_name()) self.assertEqual('0.10.2', components[0].get_version()) self.assertEqual(len(components[0].get_external_references()), 2) + self.assertEqual(len(components[0].get_external_references()[0].get_hashes()), 1)