Skip to content

Commit 5853636

Browse files
committed
Merge branch 'main' into 9.0.0-dev
2 parents 5630f68 + 845b8d5 commit 5853636

File tree

9 files changed

+24
-87
lines changed

9 files changed

+24
-87
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Contributing
22

3-
Pull requests are welcome.
4-
But please read the
5-
[CycloneDX contributing guidelines](https://github.com/CycloneDX/.github/blob/master/CONTRIBUTING.md)
6-
first.
3+
Any contribution is welcome.
4+
Please read the [CycloneDX contributing guidelines](https://github.com/CycloneDX/.github/blob/master/CONTRIBUTING.md) first.
5+
6+
Pull-requests from forks are welcome.
7+
We love to see your purposed changes, but we also like to discuss things first. Please open a ticket and explain your intended changes to the community. And don't forget to mention that discussion in your pull-request later.
8+
Find the needed basics here:
9+
* [how to fork a repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)
10+
* [how create a pull request from a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
711

812
## Setup
913

cyclonedx/model/__init__.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@
3737
from sortedcontainers import SortedSet
3838

3939
from .._internal.compare import ComparableTuple as _ComparableTuple
40-
from ..exception.model import (
41-
InvalidLocaleTypeException,
42-
InvalidUriException,
43-
NoPropertiesProvidedException,
44-
UnknownHashTypeException,
45-
)
40+
from ..exception.model import InvalidLocaleTypeException, InvalidUriException, UnknownHashTypeException
4641
from ..exception.serialization import CycloneDxDeserializationException, SerializationOfUnexpectedValueException
4742
from ..schema.schema import (
4843
SchemaVersion1Dot0,
@@ -1185,11 +1180,6 @@ def __init__(
11851180
name: Optional[str] = None,
11861181
email: Optional[str] = None,
11871182
) -> None:
1188-
if not timestamp and not name and not email:
1189-
raise NoPropertiesProvidedException(
1190-
'At least one of `timestamp`, `name` or `email` must be provided for an `IdentifiableAction`.'
1191-
)
1192-
11931183
self.timestamp = timestamp
11941184
self.name = name
11951185
self.email = email

cyclonedx/model/component.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from .._internal.bom_ref import bom_ref_from_str as _bom_ref_from_str
3030
from .._internal.compare import ComparablePackageURL as _ComparablePackageURL, ComparableTuple as _ComparableTuple
3131
from .._internal.hash import file_sha1sum as _file_sha1sum
32-
from ..exception.model import InvalidOmniBorIdException, InvalidSwhidException, NoPropertiesProvidedException
32+
from ..exception.model import InvalidOmniBorIdException, InvalidSwhidException
3333
from ..exception.serialization import (
3434
CycloneDxDeserializationException,
3535
SerializationOfUnexpectedValueException,
@@ -82,11 +82,6 @@ def __init__(
8282
committer: Optional[IdentifiableAction] = None,
8383
message: Optional[str] = None,
8484
) -> None:
85-
if not uid and not url and not author and not committer and not message:
86-
raise NoPropertiesProvidedException(
87-
'At least one of `uid`, `url`, `author`, `committer` or `message` must be provided for a `Commit`.'
88-
)
89-
9085
self.uid = uid
9186
self.url = url
9287
self.author = author
@@ -211,11 +206,6 @@ def __init__(
211206
licenses: Optional[Iterable[License]] = None,
212207
copyright: Optional[Iterable[Copyright]] = None,
213208
) -> None:
214-
if not licenses and not copyright:
215-
raise NoPropertiesProvidedException(
216-
'At least one of `licenses` or `copyright` must be supplied for a `ComponentEvidence`.'
217-
)
218-
219209
self.licenses = licenses or [] # type:ignore[assignment]
220210
self.copyright = copyright or [] # type:ignore[assignment]
221211

@@ -451,11 +441,6 @@ def __init__(
451441
text: Optional[AttachedText] = None,
452442
url: Optional[XsUri] = None,
453443
) -> None:
454-
if not text and not url:
455-
raise NoPropertiesProvidedException(
456-
'At least one of `text` or `url` must be provided for a `Diff`.'
457-
)
458-
459444
self.text = text
460445
self.url = url
461446

@@ -637,12 +622,6 @@ def __init__(
637622
patches: Optional[Iterable[Patch]] = None,
638623
notes: Optional[str] = None,
639624
) -> None:
640-
if not ancestors and not descendants and not variants and not commits and not patches and not notes:
641-
raise NoPropertiesProvidedException(
642-
'At least one of `ancestors`, `descendants`, `variants`, `commits`, `patches` or `notes` must be '
643-
'provided for `Pedigree`'
644-
)
645-
646625
self.ancestors = ancestors or [] # type:ignore[assignment]
647626
self.descendants = descendants or [] # type:ignore[assignment]
648627
self.variants = variants or [] # type:ignore[assignment]

cyclonedx/model/issue.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from sortedcontainers import SortedSet
2323

2424
from .._internal.compare import ComparableTuple as _ComparableTuple
25-
from ..exception.model import NoPropertiesProvidedException
2625
from . import XsUri
2726

2827

@@ -54,10 +53,6 @@ def __init__(
5453
name: Optional[str] = None,
5554
url: Optional[XsUri] = None,
5655
) -> None:
57-
if not name and not url:
58-
raise NoPropertiesProvidedException(
59-
'Neither `name` nor `url` were provided - at least one must be provided.'
60-
)
6156
self.name = name
6257
self.url = url
6358

cyclonedx/model/vulnerability.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class BomTargetVersionRange:
6262
`version` and `version_range` are mutually exclusive.
6363
6464
.. note::
65-
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilityType
65+
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilityType
6666
"""
6767

6868
def __init__(
@@ -226,7 +226,7 @@ class VulnerabilityAnalysis:
226226
Class that models the `analysis` sub-element of the `vulnerabilityType` complex type.
227227
228228
.. note::
229-
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilityType
229+
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilityType
230230
"""
231231

232232
def __init__(
@@ -236,11 +236,6 @@ def __init__(
236236
responses: Optional[Iterable[ImpactAnalysisResponse]] = None,
237237
detail: Optional[str] = None,
238238
) -> None:
239-
if not state and not justification and not responses and not detail:
240-
raise NoPropertiesProvidedException(
241-
'At least one of state, justification, responses or detail must be provided for VulnerabilityAnalysis '
242-
'- none supplied'
243-
)
244239
self.state = state
245240
self.justification = justification
246241
self.responses = responses or [] # type:ignore[assignment]
@@ -421,18 +416,14 @@ class VulnerabilitySource:
421416
This type is used for multiple purposes in the CycloneDX schema.
422417
423418
.. note::
424-
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilitySourceType
419+
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilitySourceType
425420
"""
426421

427422
def __init__(
428423
self, *,
429424
name: Optional[str] = None,
430425
url: Optional[XsUri] = None,
431426
) -> None:
432-
if not name and not url:
433-
raise NoPropertiesProvidedException(
434-
'Either name or url must be provided for a VulnerabilitySource - neither provided'
435-
)
436427
self.name = name
437428
self.url = url
438429

@@ -494,7 +485,7 @@ class VulnerabilityReference:
494485
intelligence.
495486
496487
.. note::
497-
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilityType
488+
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilityType
498489
"""
499490

500491
def __init__(
@@ -738,7 +729,7 @@ class VulnerabilityRating:
738729
1.4 - see https://github.com/CycloneDX/specification/blob/master/schema/ext/vulnerability-1.0.xsd.
739730
740731
.. note::
741-
See `ratingType` in https://cyclonedx.org/docs/1.6/#ratingType
732+
See `ratingType` in https://cyclonedx.org/docs/1.6/xml/#ratingType
742733
743734
.. warning::
744735
As part of implementing support for CycloneDX schema version 1.4, the three score types defined in the schema
@@ -756,11 +747,6 @@ def __init__(
756747
vector: Optional[str] = None,
757748
justification: Optional[str] = None,
758749
) -> None:
759-
if not source and not score and not severity and not method and not vector and not justification:
760-
raise NoPropertiesProvidedException(
761-
'At least one property must be provided when creating a VulnerabilityRating - none supplied.'
762-
)
763-
764750
self.source = source
765751
self.score = score
766752
self.severity = severity
@@ -881,18 +867,14 @@ class VulnerabilityCredits:
881867
extension (in XML only).
882868
883869
.. note::
884-
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilityType
870+
See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilityType
885871
"""
886872

887873
def __init__(
888874
self, *,
889875
organizations: Optional[Iterable[OrganizationalEntity]] = None,
890876
individuals: Optional[Iterable[OrganizationalContact]] = None,
891877
) -> None:
892-
if not organizations and not individuals:
893-
raise NoPropertiesProvidedException(
894-
'One of `organizations` or `individuals` must be populated - neither were'
895-
)
896878
self.organizations = organizations or [] # type:ignore[assignment]
897879
self.individuals = individuals or [] # type:ignore[assignment]
898880

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ xml-validation = ["lxml"]
8484
[tool.poetry.group.dev.dependencies]
8585
ddt = "1.7.2"
8686
coverage = "7.6.1"
87-
flake8 = { version="7.1.1", python=">=3.8.1" }
87+
flake8 = { version="7.1.2", python=">=3.8.1" }
8888
flake8-annotations = { version="3.1.1", python=">=3.8.1" }
8989
flake8-bugbear = { version="24.12.12", python=">=3.8.1" }
9090
flake8-copyright-validator = "0.0.1"

tests/test_model.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@
2424
from ddt import ddt, named_data
2525

2626
from cyclonedx._internal.compare import ComparableTuple
27-
from cyclonedx.exception.model import (
28-
InvalidLocaleTypeException,
29-
InvalidUriException,
30-
NoPropertiesProvidedException,
31-
UnknownHashTypeException,
32-
)
27+
from cyclonedx.exception.model import InvalidLocaleTypeException, InvalidUriException, UnknownHashTypeException
3328
from cyclonedx.model import (
3429
Copyright,
3530
Encoding,
@@ -309,8 +304,7 @@ def test_sort(self) -> None:
309304
class TestModelIdentifiableAction(TestCase):
310305

311306
def test_no_params(self) -> None:
312-
with self.assertRaises(NoPropertiesProvidedException):
313-
IdentifiableAction()
307+
IdentifiableAction() # Does not raise `NoPropertiesProvidedException`
314308

315309
def test_same(self) -> None:
316310
ts = datetime.datetime.utcnow()

tests/test_model_component.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from typing import List
2020
from unittest import TestCase
2121

22-
from cyclonedx.exception.model import NoPropertiesProvidedException
2322
from cyclonedx.model import (
2423
AttachedText,
2524
Copyright,
@@ -57,8 +56,7 @@
5756
class TestModelCommit(TestCase):
5857

5958
def test_no_parameters(self) -> None:
60-
with self.assertRaises(NoPropertiesProvidedException):
61-
Commit()
59+
Commit() # Does not raise `NoPropertiesProvidedException`
6260

6361
def test_same(self) -> None:
6462
ia_comitter = IdentifiableAction(timestamp=datetime.datetime.utcnow(), name='The Committer')
@@ -291,8 +289,7 @@ def test_nested_components_2(self) -> None:
291289
class TestModelComponentEvidence(TestCase):
292290

293291
def test_no_params(self) -> None:
294-
with self.assertRaises(NoPropertiesProvidedException):
295-
ComponentEvidence()
292+
ComponentEvidence() # Does not raise `NoPropertiesProvidedException`
296293

297294
def test_same_1(self) -> None:
298295
ce_1 = ComponentEvidence(copyright=[Copyright(text='Commercial')])
@@ -316,8 +313,7 @@ def test_not_same_1(self) -> None:
316313
class TestModelDiff(TestCase):
317314

318315
def test_no_params(self) -> None:
319-
with self.assertRaises(NoPropertiesProvidedException):
320-
Diff()
316+
Diff() # Does not raise `NoPropertiesProvidedException`
321317

322318
def test_same(self) -> None:
323319
at = AttachedText(content='A very long diff')
@@ -441,8 +437,7 @@ def test_sort(self) -> None:
441437
class TestModelPedigree(TestCase):
442438

443439
def test_no_params(self) -> None:
444-
with self.assertRaises(NoPropertiesProvidedException):
445-
Pedigree()
440+
Pedigree() # does not raise `NoPropertiesProvidedException`
446441

447442
def test_same_1(self) -> None:
448443
p1 = get_pedigree_1()

tests/test_model_issue.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from unittest import TestCase
1919

20-
from cyclonedx.exception.model import NoPropertiesProvidedException
2120
from cyclonedx.model import XsUri
2221
from cyclonedx.model.issue import IssueClassification, IssueType, IssueTypeSource
2322
from tests import reorder
@@ -63,8 +62,7 @@ def test_sort(self) -> None:
6362
class TestModelIssueTypeSource(TestCase):
6463

6564
def test_no_params(self) -> None:
66-
with self.assertRaises(NoPropertiesProvidedException):
67-
IssueTypeSource()
65+
IssueTypeSource() # Does not raise `NoPropertiesProvidedException`
6866

6967
def test_same(self) -> None:
7068
its_1 = IssueTypeSource(name='The Source', url=XsUri('https://cyclonedx.org'))

0 commit comments

Comments
 (0)