diff --git a/cyclonedx/model/__init__.py b/cyclonedx/model/__init__.py index a0e6e58c..3a041b20 100644 --- a/cyclonedx/model/__init__.py +++ b/cyclonedx/model/__init__.py @@ -37,12 +37,7 @@ from sortedcontainers import SortedSet from .._internal.compare import ComparableTuple as _ComparableTuple -from ..exception.model import ( - InvalidLocaleTypeException, - InvalidUriException, - NoPropertiesProvidedException, - UnknownHashTypeException, -) +from ..exception.model import InvalidLocaleTypeException, InvalidUriException, UnknownHashTypeException from ..exception.serialization import CycloneDxDeserializationException, SerializationOfUnexpectedValueException from ..schema.schema import ( SchemaVersion1Dot0, @@ -1180,11 +1175,6 @@ def __init__( name: Optional[str] = None, email: Optional[str] = None, ) -> None: - if not timestamp and not name and not email: - raise NoPropertiesProvidedException( - 'At least one of `timestamp`, `name` or `email` must be provided for an `IdentifiableAction`.' - ) - self.timestamp = timestamp self.name = name self.email = email diff --git a/cyclonedx/model/component.py b/cyclonedx/model/component.py index 6356afd0..df072597 100644 --- a/cyclonedx/model/component.py +++ b/cyclonedx/model/component.py @@ -29,7 +29,7 @@ from .._internal.bom_ref import bom_ref_from_str as _bom_ref_from_str from .._internal.compare import ComparablePackageURL as _ComparablePackageURL, ComparableTuple as _ComparableTuple from .._internal.hash import file_sha1sum as _file_sha1sum -from ..exception.model import InvalidOmniBorIdException, InvalidSwhidException, NoPropertiesProvidedException +from ..exception.model import InvalidOmniBorIdException, InvalidSwhidException from ..exception.serialization import ( CycloneDxDeserializationException, SerializationOfUnexpectedValueException, @@ -82,11 +82,6 @@ def __init__( committer: Optional[IdentifiableAction] = None, message: Optional[str] = None, ) -> None: - if not uid and not url and not author and not committer and not message: - raise NoPropertiesProvidedException( - 'At least one of `uid`, `url`, `author`, `committer` or `message` must be provided for a `Commit`.' - ) - self.uid = uid self.url = url self.author = author @@ -208,11 +203,6 @@ def __init__( licenses: Optional[Iterable[License]] = None, copyright: Optional[Iterable[Copyright]] = None, ) -> None: - if not licenses and not copyright: - raise NoPropertiesProvidedException( - 'At least one of `licenses` or `copyright` must be supplied for a `ComponentEvidence`.' - ) - self.licenses = licenses or [] # type:ignore[assignment] self.copyright = copyright or [] # type:ignore[assignment] @@ -442,11 +432,6 @@ def __init__( text: Optional[AttachedText] = None, url: Optional[XsUri] = None, ) -> None: - if not text and not url: - raise NoPropertiesProvidedException( - 'At least one of `text` or `url` must be provided for a `Diff`.' - ) - self.text = text self.url = url @@ -624,12 +609,6 @@ def __init__( patches: Optional[Iterable[Patch]] = None, notes: Optional[str] = None, ) -> None: - if not ancestors and not descendants and not variants and not commits and not patches and not notes: - raise NoPropertiesProvidedException( - 'At least one of `ancestors`, `descendants`, `variants`, `commits`, `patches` or `notes` must be ' - 'provided for `Pedigree`' - ) - self.ancestors = ancestors or [] # type:ignore[assignment] self.descendants = descendants or [] # type:ignore[assignment] self.variants = variants or [] # type:ignore[assignment] diff --git a/cyclonedx/model/issue.py b/cyclonedx/model/issue.py index 14b35581..b0886d63 100644 --- a/cyclonedx/model/issue.py +++ b/cyclonedx/model/issue.py @@ -22,7 +22,6 @@ from sortedcontainers import SortedSet from .._internal.compare import ComparableTuple as _ComparableTuple -from ..exception.model import NoPropertiesProvidedException from . import XsUri @@ -54,10 +53,6 @@ def __init__( name: Optional[str] = None, url: Optional[XsUri] = None, ) -> None: - if not name and not url: - raise NoPropertiesProvidedException( - 'Neither `name` nor `url` were provided - at least one must be provided.' - ) self.name = name self.url = url diff --git a/cyclonedx/model/vulnerability.py b/cyclonedx/model/vulnerability.py index 9b0e8a90..2e110073 100644 --- a/cyclonedx/model/vulnerability.py +++ b/cyclonedx/model/vulnerability.py @@ -62,7 +62,7 @@ class BomTargetVersionRange: `version` and `version_range` are mutually exclusive. .. note:: - See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilityType + See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilityType """ def __init__( @@ -219,7 +219,7 @@ class VulnerabilityAnalysis: Class that models the `analysis` sub-element of the `vulnerabilityType` complex type. .. note:: - See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilityType + See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilityType """ def __init__( @@ -229,11 +229,6 @@ def __init__( responses: Optional[Iterable[ImpactAnalysisResponse]] = None, detail: Optional[str] = None, ) -> None: - if not state and not justification and not responses and not detail: - raise NoPropertiesProvidedException( - 'At least one of state, justification, responses or detail must be provided for VulnerabilityAnalysis ' - '- none supplied' - ) self.state = state self.justification = justification self.responses = responses or [] # type:ignore[assignment] @@ -408,7 +403,7 @@ class VulnerabilitySource: This type is used for multiple purposes in the CycloneDX schema. .. note:: - See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilitySourceType + See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilitySourceType """ def __init__( @@ -416,10 +411,6 @@ def __init__( name: Optional[str] = None, url: Optional[XsUri] = None, ) -> None: - if not name and not url: - raise NoPropertiesProvidedException( - 'Either name or url must be provided for a VulnerabilitySource - neither provided' - ) self.name = name self.url = url @@ -480,7 +471,7 @@ class VulnerabilityReference: intelligence. .. note:: - See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilityType + See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilityType """ def __init__( @@ -723,7 +714,7 @@ class VulnerabilityRating: 1.4 - see https://github.com/CycloneDX/specification/blob/master/schema/ext/vulnerability-1.0.xsd. .. note:: - See `ratingType` in https://cyclonedx.org/docs/1.6/#ratingType + See `ratingType` in https://cyclonedx.org/docs/1.6/xml/#ratingType .. warning:: As part of implementing support for CycloneDX schema version 1.4, the three score types defined in the schema @@ -741,11 +732,6 @@ def __init__( vector: Optional[str] = None, justification: Optional[str] = None, ) -> None: - if not source and not score and not severity and not method and not vector and not justification: - raise NoPropertiesProvidedException( - 'At least one property must be provided when creating a VulnerabilityRating - none supplied.' - ) - self.source = source self.score = score self.severity = severity @@ -861,7 +847,7 @@ class VulnerabilityCredits: extension (in XML only). .. note:: - See the CycloneDX schema: https://cyclonedx.org/docs/1.6/#type_vulnerabilityType + See the CycloneDX schema: https://cyclonedx.org/docs/1.6/xml/#type_vulnerabilityType """ def __init__( @@ -869,10 +855,6 @@ def __init__( organizations: Optional[Iterable[OrganizationalEntity]] = None, individuals: Optional[Iterable[OrganizationalContact]] = None, ) -> None: - if not organizations and not individuals: - raise NoPropertiesProvidedException( - 'One of `organizations` or `individuals` must be populated - neither were' - ) self.organizations = organizations or [] # type:ignore[assignment] self.individuals = individuals or [] # type:ignore[assignment] diff --git a/tests/test_model.py b/tests/test_model.py index 46232611..58c017e9 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -24,12 +24,7 @@ from ddt import ddt, named_data from cyclonedx._internal.compare import ComparableTuple -from cyclonedx.exception.model import ( - InvalidLocaleTypeException, - InvalidUriException, - NoPropertiesProvidedException, - UnknownHashTypeException, -) +from cyclonedx.exception.model import InvalidLocaleTypeException, InvalidUriException, UnknownHashTypeException from cyclonedx.model import ( Copyright, Encoding, @@ -309,8 +304,7 @@ def test_sort(self) -> None: class TestModelIdentifiableAction(TestCase): def test_no_params(self) -> None: - with self.assertRaises(NoPropertiesProvidedException): - IdentifiableAction() + IdentifiableAction() # Does not raise `NoPropertiesProvidedException` def test_same(self) -> None: ts = datetime.datetime.utcnow() diff --git a/tests/test_model_component.py b/tests/test_model_component.py index c25fdc91..54d3cfe6 100644 --- a/tests/test_model_component.py +++ b/tests/test_model_component.py @@ -19,7 +19,6 @@ from typing import List from unittest import TestCase -from cyclonedx.exception.model import NoPropertiesProvidedException from cyclonedx.model import ( AttachedText, Copyright, @@ -57,8 +56,7 @@ class TestModelCommit(TestCase): def test_no_parameters(self) -> None: - with self.assertRaises(NoPropertiesProvidedException): - Commit() + Commit() # Does not raise `NoPropertiesProvidedException` def test_same(self) -> None: ia_comitter = IdentifiableAction(timestamp=datetime.datetime.utcnow(), name='The Committer') @@ -287,8 +285,7 @@ def test_nested_components_2(self) -> None: class TestModelComponentEvidence(TestCase): def test_no_params(self) -> None: - with self.assertRaises(NoPropertiesProvidedException): - ComponentEvidence() + ComponentEvidence() # Does not raise `NoPropertiesProvidedException` def test_same_1(self) -> None: ce_1 = ComponentEvidence(copyright=[Copyright(text='Commercial')]) @@ -312,8 +309,7 @@ def test_not_same_1(self) -> None: class TestModelDiff(TestCase): def test_no_params(self) -> None: - with self.assertRaises(NoPropertiesProvidedException): - Diff() + Diff() # Does not raise `NoPropertiesProvidedException` def test_same(self) -> None: at = AttachedText(content='A very long diff') @@ -437,8 +433,7 @@ def test_sort(self) -> None: class TestModelPedigree(TestCase): def test_no_params(self) -> None: - with self.assertRaises(NoPropertiesProvidedException): - Pedigree() + Pedigree() # does not raise `NoPropertiesProvidedException` def test_same_1(self) -> None: p1 = get_pedigree_1() diff --git a/tests/test_model_issue.py b/tests/test_model_issue.py index 2ae4a666..33cc0b36 100644 --- a/tests/test_model_issue.py +++ b/tests/test_model_issue.py @@ -17,7 +17,6 @@ from unittest import TestCase -from cyclonedx.exception.model import NoPropertiesProvidedException from cyclonedx.model import XsUri from cyclonedx.model.issue import IssueClassification, IssueType, IssueTypeSource from tests import reorder @@ -63,8 +62,7 @@ def test_sort(self) -> None: class TestModelIssueTypeSource(TestCase): def test_no_params(self) -> None: - with self.assertRaises(NoPropertiesProvidedException): - IssueTypeSource() + IssueTypeSource() # Does not raise `NoPropertiesProvidedException` def test_same(self) -> None: its_1 = IssueTypeSource(name='The Source', url=XsUri('https://cyclonedx.org'))