Skip to content

Commit 4778a11

Browse files
committed
Merge branch 'contrib/wkoot/wkoot-patch-1' into contrib/wkoot/wkoot-patch-1_ff
2 parents 8c14a87 + efcca53 commit 4778a11

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

cyclonedx/model/component.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ def __hash__(self) -> int:
17791779
self.mime_type, self.supplier, self.author, self.publisher,
17801780
self.description, self.scope, tuple(self.hashes),
17811781
tuple(self.licenses), self.copyright, self.cpe,
1782-
self.purl,
1782+
self.purl, self.bom_ref.value,
17831783
self.swid, self.pedigree,
17841784
tuple(self.external_references), tuple(self.properties),
17851785
tuple(self.components), self.evidence, self.release_notes, self.modified,

tests/_data/own/json/1.5/duplicate_components.json

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_model_component.py

+10
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ def test_component_equal_3(self) -> None:
219219

220220
self.assertNotEqual(c, c2)
221221

222+
def test_component_equal_4(self) -> None:
223+
c = Component(
224+
name='test-component', version='1.2.3', bom_ref='ref1'
225+
)
226+
c2 = Component(
227+
name='test-component', version='1.2.3', bom_ref='ref2'
228+
)
229+
230+
self.assertNotEqual(c, c2)
231+
222232
def test_same_1(self) -> None:
223233
c1 = get_component_setuptools_simple()
224234
c2 = get_component_setuptools_simple()

tests/test_real_world_examples.py

+9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import unittest
1919
from datetime import datetime
20+
from json import loads as json_loads
2021
from os.path import join
2122
from typing import Any
2223
from unittest.mock import patch
@@ -36,3 +37,11 @@ def test_webgoat_6_1(self, *_: Any, **__: Any) -> None:
3637
def test_regression_issue_630(self, *_: Any, **__: Any) -> None:
3738
with open(join(OWN_DATA_DIRECTORY, 'xml', '1.6', 'regression_issue630.xml')) as input_xml:
3839
Bom.from_xml(input_xml)
40+
41+
def test_merged_bom_duplicate_component(self, *_: Any, **__: Any) -> None:
42+
with open(join(OWN_DATA_DIRECTORY, 'json', '1.5', 'duplicate_components.json')) as input_json:
43+
json = json_loads(input_json.read())
44+
45+
bom = Bom.from_json(json)
46+
self.assertEqual(4, len(bom.components)) # tests https://github.com/CycloneDX/cyclonedx-python-lib/issues/540
47+
bom.validate() # tests https://github.com/CycloneDX/cyclonedx-python-lib/issues/677

0 commit comments

Comments
 (0)