Skip to content

__hash__ implementation in Component attempts to hash unhashable properties list if present #153

@0t1s1

Description

@0t1s1

The Component class' __hash__ implementation attempts to hash an unhashable list of Property objects if present. This prevents Component objects from being compared, which in turn prevents one from adding Component objects to Bom objects via Bom's add_component method.

Example:

from cyclonedx.model.component import Component
from cyclonedx.model import Property
component1 = Component("component 1", properties=[Property("prop 1", "value 1")])
component2 = Component("component 2")
component1 == component2

Results in

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/python3.8/site-packages/cyclonedx/model/component.py", line 508, in __eq__
    return hash(other) == hash(self)
  File "/lib/python3.8/site-packages/cyclonedx/model/component.py", line 512, in __hash__
    return hash((
TypeError: unhashable type: 'list'

Library version: 1.3.0
OS: CentOS 8

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions