|
14 | 14 | #
|
15 | 15 | # SPDX-License-Identifier: Apache-2.0
|
16 | 16 | # Copyright (c) OWASP Foundation. All Rights Reserved.
|
| 17 | + |
17 | 18 | import re
|
18 | 19 | from enum import Enum
|
19 | 20 | from os.path import exists
|
|
25 | 26 | from packageurl import PackageURL
|
26 | 27 | from sortedcontainers import SortedSet
|
27 | 28 |
|
28 |
| -from .._internal.compare import ComparableTuple as _ComparableTuple |
| 29 | +from .._internal.compare import ComparablePackageURL as _ComparablePackageURL, ComparableTuple as _ComparableTuple |
29 | 30 | from .._internal.hash import file_sha1sum as _file_sha1sum
|
30 | 31 | from ..exception.model import InvalidOmniBorIdException, InvalidSwhidException, NoPropertiesProvidedException
|
31 | 32 | from ..exception.serialization import (
|
|
42 | 43 | SchemaVersion1Dot5,
|
43 | 44 | SchemaVersion1Dot6,
|
44 | 45 | )
|
45 |
| -from ..serialization import BomRefHelper, LicenseRepositoryHelper, PackageUrl |
| 46 | +from ..serialization import BomRefHelper, LicenseRepositoryHelper, PackageUrl as PackageUrlSH |
46 | 47 | from . import (
|
47 | 48 | AttachedText,
|
48 | 49 | Copyright,
|
@@ -1406,7 +1407,7 @@ def cpe(self, cpe: Optional[str]) -> None:
|
1406 | 1407 | self._cpe = cpe
|
1407 | 1408 |
|
1408 | 1409 | @property
|
1409 |
| - @serializable.type_mapping(PackageUrl) |
| 1410 | + @serializable.type_mapping(PackageUrlSH) |
1410 | 1411 | @serializable.xml_sequence(15)
|
1411 | 1412 | def purl(self) -> Optional[PackageURL]:
|
1412 | 1413 | """
|
@@ -1699,29 +1700,42 @@ def __eq__(self, other: object) -> bool:
|
1699 | 1700 | def __lt__(self, other: Any) -> bool:
|
1700 | 1701 | if isinstance(other, Component):
|
1701 | 1702 | return _ComparableTuple((
|
1702 |
| - self.type, self.mime_type, self.supplier, self.author, self.publisher, self.group, self.name, |
1703 |
| - self.version, self.description, self.scope, _ComparableTuple(self.hashes), |
1704 |
| - _ComparableTuple(self.licenses), self.copyright, self.cpe, self.purl, self.swid, self.pedigree, |
| 1703 | + self.type, self.group, self.name, self.version, |
| 1704 | + self.mime_type, self.supplier, self.author, self.publisher, |
| 1705 | + self.description, self.scope, _ComparableTuple(self.hashes), |
| 1706 | + _ComparableTuple(self.licenses), self.copyright, self.cpe, |
| 1707 | + None if self.purl is None else _ComparablePackageURL(self.purl), |
| 1708 | + self.swid, self.pedigree, |
1705 | 1709 | _ComparableTuple(self.external_references), _ComparableTuple(self.properties),
|
1706 | 1710 | _ComparableTuple(self.components), self.evidence, self.release_notes, self.modified,
|
1707 |
| - _ComparableTuple(self.authors), _ComparableTuple(self.omnibor_ids), |
| 1711 | + _ComparableTuple(self.authors), _ComparableTuple(self.omnibor_ids), self.manufacturer, |
| 1712 | + _ComparableTuple(self.swhids), self.crypto_properties, _ComparableTuple(self.tags) |
1708 | 1713 | )) < _ComparableTuple((
|
1709 |
| - other.type, other.mime_type, other.supplier, other.author, other.publisher, other.group, other.name, |
1710 |
| - other.version, other.description, other.scope, _ComparableTuple(other.hashes), |
1711 |
| - _ComparableTuple(other.licenses), other.copyright, other.cpe, other.purl, other.swid, other.pedigree, |
| 1714 | + other.type, other.group, other.name, other.version, |
| 1715 | + other.mime_type, other.supplier, other.author, other.publisher, |
| 1716 | + other.description, other.scope, _ComparableTuple(other.hashes), |
| 1717 | + _ComparableTuple(other.licenses), other.copyright, other.cpe, |
| 1718 | + None if other.purl is None else _ComparablePackageURL(other.purl), |
| 1719 | + other.swid, other.pedigree, |
1712 | 1720 | _ComparableTuple(other.external_references), _ComparableTuple(other.properties),
|
1713 | 1721 | _ComparableTuple(other.components), other.evidence, other.release_notes, other.modified,
|
1714 |
| - _ComparableTuple(other.authors), _ComparableTuple(other.omnibor_ids), |
| 1722 | + _ComparableTuple(other.authors), _ComparableTuple(other.omnibor_ids), other.manufacturer, |
| 1723 | + _ComparableTuple(other.swhids), other.crypto_properties, _ComparableTuple(other.tags) |
1715 | 1724 | ))
|
1716 | 1725 | return NotImplemented
|
1717 | 1726 |
|
1718 | 1727 | def __hash__(self) -> int:
|
1719 | 1728 | return hash((
|
1720 |
| - self.type, self.mime_type, self.supplier, self.author, self.publisher, self.group, self.name, |
1721 |
| - self.version, self.description, self.scope, tuple(self.hashes), tuple(self.licenses), self.copyright, |
1722 |
| - self.cpe, self.purl, self.swid, self.pedigree, tuple(self.external_references), tuple(self.properties), |
1723 |
| - tuple(self.components), self.evidence, self.release_notes, self.modified, tuple(self.authors), |
1724 |
| - tuple(self.omnibor_ids), |
| 1729 | + self.type, self.group, self.name, self.version, |
| 1730 | + self.mime_type, self.supplier, self.author, self.publisher, |
| 1731 | + self.description, self.scope, tuple(self.hashes), |
| 1732 | + tuple(self.licenses), self.copyright, self.cpe, |
| 1733 | + self.purl, |
| 1734 | + self.swid, self.pedigree, |
| 1735 | + tuple(self.external_references), tuple(self.properties), |
| 1736 | + tuple(self.components), self.evidence, self.release_notes, self.modified, |
| 1737 | + tuple(self.authors), tuple(self.omnibor_ids), self.manufacturer, |
| 1738 | + tuple(self.swhids), self.crypto_properties, tuple(self.tags) |
1725 | 1739 | ))
|
1726 | 1740 |
|
1727 | 1741 | def __repr__(self) -> str:
|
|
0 commit comments