Skip to content

Commit 27fa9fe

Browse files
committed
Include bom-ref value within Component hash calculation
Addresses CycloneDX#540
1 parent 7c7b8d3 commit 27fa9fe

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cyclonedx/model/component.py

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

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()

0 commit comments

Comments
 (0)