Skip to content

Commit f92dcc5

Browse files
authored
Merge branch 'main' into main
2 parents 849c7a4 + ab2e91e commit f92dcc5

File tree

8 files changed

+73
-8
lines changed

8 files changed

+73
-8
lines changed

.github/workflows/python.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ concurrency:
1717
group: ${{ github.workflow }}-${{ github.ref }}
1818
cancel-in-progress: true
1919

20+
permissions: {}
21+
2022
env:
2123
REPORTS_DIR: CI_reports
2224
PYTHON_VERSION_DEFAULT: "3.11"

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ concurrency:
3535
group: deploy
3636
cancel-in-progress: false # prevent hickups with semantic-release
3737

38+
permissions: {}
39+
3840
env:
3941
PYTHON_VERSION_DEFAULT: "3.11"
4042
POETRY_VERSION: "1.8.1"
@@ -106,7 +108,7 @@ jobs:
106108
id: release
107109
# see https://python-semantic-release.readthedocs.io/en/latest/automatic-releases/github-actions.html
108110
# see https://github.com/python-semantic-release/python-semantic-release
109-
uses: python-semantic-release/[email protected].0
111+
uses: python-semantic-release/[email protected].1
110112
with:
111113
github_token: ${{ secrets.GITHUB_TOKEN }}
112114
force: ${{ github.event.inputs.release_force }}

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
# CHANGELOG
22

33

4+
## v10.0.1 (2025-05-10)
5+
6+
### Bug Fixes
7+
8+
- Add missing comparator for VulnerabilityAnalysis
9+
([#812](https://github.com/CycloneDX/cyclonedx-python-lib/pull/812),
10+
[`0df2982`](https://github.com/CycloneDX/cyclonedx-python-lib/commit/0df2982151a99ce6e21336e6904afc0a8058f9af))
11+
12+
When trying to generate a CycloneDX BOM that has two vulnerabilities that only differ in their
13+
analysis, you get ``` TypeError: '<' not supported between instances of 'VulnerabilityAnalysis'
14+
and 'VulnerabilityAnalysis' ```
15+
16+
This PR adds the `__lt__` method for the VulnerabilityAnalysis model to fix sorting and also
17+
includes a test case to verify the fix.
18+
19+
---------
20+
21+
Signed-off-by: Riku Häkli <[email protected]>
22+
23+
Co-authored-by: Riku Häkli <[email protected]>
24+
25+
### Documentation
26+
27+
- **fix**: Mdformat
28+
([`acf5c45`](https://github.com/CycloneDX/cyclonedx-python-lib/commit/acf5c45874808b831c33344f08ea21df20c727bb))
29+
30+
Signed-off-by: Jan Kowalleck <[email protected]>
31+
32+
433
## v10.0.0 (2025-04-23)
534

635
### Features

cyclonedx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
# !! version is managed by semantic_release
2424
# do not use typing here, or else `semantic_release` might have issues finding the variable
25-
__version__ = "10.0.0" # noqa:Q000
25+
__version__ = "10.0.1" # noqa:Q000

cyclonedx/model/vulnerability.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ def __eq__(self, other: object) -> bool:
349349
return self.__comparable_tuple() == other.__comparable_tuple()
350350
return False
351351

352+
def __lt__(self, other: Any) -> bool:
353+
if isinstance(other, VulnerabilityAnalysis):
354+
return self.__comparable_tuple() < other.__comparable_tuple()
355+
return NotImplemented
356+
352357
def __hash__(self) -> int:
353358
return hash(self.__comparable_tuple())
354359

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# The full version, including alpha/beta/rc tags
2525
# !! version is managed by semantic_release
26-
release = '10.0.0'
26+
release = '10.0.1'
2727

2828
# -- General configuration ---------------------------------------------------
2929

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
55
[tool.poetry]
66
name = "cyclonedx-python-lib"
77
# !! version is managed by semantic_release
8-
version = "10.0.0"
8+
version = "10.0.1"
99
description = "Python library for CycloneDX"
1010
authors = [
1111
"Paul Horton <[email protected]>",
@@ -82,20 +82,20 @@ xml-validation = ["lxml"]
8282

8383
[tool.poetry.group.dev.dependencies]
8484
ddt = "1.7.2"
85-
coverage = "7.8.0"
85+
coverage = "7.8.2"
8686
flake8 = "7.2.0"
8787
flake8-annotations = "3.1.1"
8888
flake8-bugbear = "24.12.12"
8989
flake8-copyright-validator = "0.0.1"
9090
flake8-isort = "6.1.2"
9191
flake8-quotes = "3.4.0"
9292
flake8-use-fstring = "1.4"
93-
pep8-naming = "0.14.1"
93+
pep8-naming = "0.15.1"
9494
isort = "6.0.1"
9595
autopep8 = "2.3.2"
9696
mypy = "1.15.0"
9797
tomli = { version = "2.2.1", python = "<3.11" }
98-
tox = "4.25.0"
98+
tox = "4.26.0"
9999
xmldiff = "2.7.0"
100100
bandit = "1.8.3"
101101

tests/test_model_vulnerability.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@
2020
from unittest import TestCase
2121

2222
from cyclonedx.model import XsUri
23-
from cyclonedx.model.impact_analysis import ImpactAnalysisAffectedStatus
23+
from cyclonedx.model.impact_analysis import (
24+
ImpactAnalysisAffectedStatus,
25+
ImpactAnalysisJustification,
26+
ImpactAnalysisResponse,
27+
ImpactAnalysisState,
28+
)
2429
from cyclonedx.model.vulnerability import (
2530
BomTarget,
2631
BomTargetVersionRange,
2732
Vulnerability,
2833
VulnerabilityAdvisory,
34+
VulnerabilityAnalysis,
2935
VulnerabilityRating,
3036
VulnerabilityReference,
3137
VulnerabilityScoreSource,
@@ -334,3 +340,24 @@ def test_sort(self) -> None:
334340
sorted_targets = sorted(targets)
335341
expected_targets = reorder(targets, expected_order)
336342
self.assertListEqual(sorted_targets, expected_targets)
343+
344+
345+
class TestModelVulnerabilityAnalysis(TestCase):
346+
347+
def test_sort(self) -> None:
348+
# expected sort order: ([state], [justification], [responses], [detail], [first_issued], [last_updated])
349+
expected_order = [3, 1, 0, 2, 5, 4]
350+
analyses = [
351+
VulnerabilityAnalysis(state=ImpactAnalysisState.EXPLOITABLE),
352+
VulnerabilityAnalysis(state=ImpactAnalysisState.EXPLOITABLE,
353+
responses=[ImpactAnalysisResponse.CAN_NOT_FIX]),
354+
VulnerabilityAnalysis(state=ImpactAnalysisState.NOT_AFFECTED,
355+
justification=ImpactAnalysisJustification.CODE_NOT_PRESENT),
356+
VulnerabilityAnalysis(state=ImpactAnalysisState.EXPLOITABLE,
357+
justification=ImpactAnalysisJustification.REQUIRES_ENVIRONMENT),
358+
VulnerabilityAnalysis(first_issued=datetime(2024, 4, 4), last_updated=datetime(2025, 5, 5)),
359+
VulnerabilityAnalysis(first_issued=datetime(2023, 3, 3), last_updated=datetime(2023, 3, 3)),
360+
]
361+
sorted_analyses = sorted(analyses)
362+
expected_analyses = reorder(analyses, expected_order)
363+
self.assertListEqual(sorted_analyses, expected_analyses)

0 commit comments

Comments
 (0)