Skip to content

Commit

Permalink
fix: multiple hashes being created for an externalRefernce which is n…
Browse files Browse the repository at this point in the history
…ot as required

Signed-off-by: Paul Horton <phorton@sonatype.com>
  • Loading branch information
madpah committed Oct 12, 2021
1 parent 7a49f9d commit 970d192
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cyclonedx/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_parser_pipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 970d192

Please sign in to comment.