Skip to content

Commit 676c941

Browse files
madpahhakandilek
andauthored
feat: support for deserialization from JSON and XML (#290)
BREAKING CHANGE: * feat: drop Python 3.6 support Signed-off-by: Hakan Dilek <hakandilek@gmail.com> Signed-off-by: Paul Horton <paul.horton@owasp.org> Co-authored-by: Hakan Dilek <hakandilek@gmail.com> Co-authored-by: Hakan Dilek <hakandilek@users.noreply.github.com>
1 parent 695afe9 commit 676c941

File tree

139 files changed

+5094
-2878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+5094
-2878
lines changed

.github/workflows/poetry.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ jobs:
5656
python-version: '3.10'
5757
toxenv-factor: 'locked'
5858
- # test with the lowest dependencies
59-
os: ubuntu-20.04
60-
python-version: '3.6'
59+
os: ubuntu-latest
60+
python-version: '3.7'
6161
toxenv-factor: 'lowest'
6262
steps:
6363
- name: Checkout
@@ -93,22 +93,13 @@ jobs:
9393
- "3.10" # highest supported
9494
- "3.9"
9595
- "3.8"
96-
- "3.7"
97-
- "3.6" # lowest supported
96+
- "3.7" # lowest supported
9897
toxenv-factor: ['locked']
9998
include:
100-
- # test with py36 ubuntu20
101-
os: ubuntu-20.04
102-
python-version: '3.6'
103-
toxenv-factor: 'locked'
10499
- # test with the lowest dependencies
105-
os: ubuntu-20.04
106-
python-version: '3.6'
107-
toxenv-factor: 'lowest'
108-
exclude:
109-
- # no py36 with latest ubuntu - see https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
110100
os: ubuntu-latest
111-
python-version: '3.6'
101+
python-version: '3.7'
102+
toxenv-factor: 'lowest'
112103
steps:
113104
- name: Disabled Git auto EOL CRLF transforms
114105
run: |

cyclonedx/exception/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121

2222

2323
class CycloneDxException(Exception):
24+
"""
25+
Root exception thrown by this library.
26+
"""
2427
pass

cyclonedx/exception/factory.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,28 @@ class CycloneDxFactoryException(CycloneDxException):
3030

3131

3232
class LicenseChoiceFactoryException(CycloneDxFactoryException):
33+
"""
34+
Base exception that covers all LicenseChoiceFactory exceptions.
35+
"""
3336
pass
3437

3538

3639
class InvalidSpdxLicenseException(LicenseChoiceFactoryException):
40+
"""
41+
Thrown when an invalid SPDX License is provided.
42+
"""
3743
pass
3844

3945

4046
class LicenseFactoryException(CycloneDxFactoryException):
47+
"""
48+
Base exception that covers all LicenseFactory exceptions.
49+
"""
4150
pass
4251

4352

4453
class InvalidLicenseExpressionException(LicenseFactoryException):
54+
"""
55+
Thrown when an invalid License expressions is provided.
56+
"""
4557
pass

cyclonedx/exception/output.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
from . import CycloneDxException
2323

2424

25+
class BomGenerationErrorException(CycloneDxException):
26+
"""
27+
Raised if there is an unknown error.
28+
"""
29+
pass
30+
31+
2532
class FormatNotSupportedException(CycloneDxException):
2633
"""
2734
Exception raised when attempting to output a BOM to a format not supported in the requested version.

cyclonedx/factory/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
18+
"""
19+
Factories used in this library.
20+
"""

cyclonedx/factory/license.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,24 @@ def make_from_string(self, name_or_spdx: str, *,
3030
license_url: Optional[XsUri] = None) -> License:
3131
"""Make a :class:`cyclonedx.model.License` from a string."""
3232
try:
33-
return self.make_with_id(name_or_spdx, license_text=license_text, license_url=license_url)
33+
return self.make_with_id(name_or_spdx, text=license_text, url=license_url)
3434
except InvalidSpdxLicenseException:
35-
return self.make_with_name(name_or_spdx, license_text=license_text, license_url=license_url)
35+
return self.make_with_name(name_or_spdx, text=license_text, url=license_url)
3636

37-
def make_with_id(self, spdx_id: str, *,
38-
license_text: Optional[AttachedText] = None,
39-
license_url: Optional[XsUri] = None) -> License:
37+
def make_with_id(self, spdx_id: str, *, text: Optional[AttachedText] = None,
38+
url: Optional[XsUri] = None) -> License:
4039
"""Make a :class:`cyclonedx.model.License` from an SPDX-ID.
4140
4241
:raises InvalidSpdxLicenseException: if `spdx_id` was not known/supported SPDX-ID
4342
"""
4443
spdx_license_id = spdx_fixup(spdx_id)
4544
if spdx_license_id is None:
4645
raise InvalidSpdxLicenseException(spdx_id)
47-
return License(spdx_license_id=spdx_license_id, license_text=license_text, license_url=license_url)
46+
return License(id=spdx_license_id, text=text, url=url)
4847

49-
def make_with_name(self, name: str, *,
50-
license_text: Optional[AttachedText] = None,
51-
license_url: Optional[XsUri] = None) -> License:
48+
def make_with_name(self, name: str, *, text: Optional[AttachedText] = None, url: Optional[XsUri] = None) -> License:
5249
"""Make a :class:`cyclonedx.model.License` with a name."""
53-
return License(license_name=name, license_text=license_text, license_url=license_url)
50+
return License(name=name, text=text, url=url)
5451

5552

5653
class LicenseChoiceFactory:
@@ -74,12 +71,12 @@ def make_with_compound_expression(self, compound_expression: str) -> LicenseChoi
7471
:raises InvalidLicenseExpressionException: if `expression` is not known/supported license expression
7572
"""
7673
if is_spdx_compound_expression(compound_expression):
77-
return LicenseChoice(license_expression=compound_expression)
74+
return LicenseChoice(expression=compound_expression)
7875
raise InvalidLicenseExpressionException(compound_expression)
7976

8077
def make_with_license(self, name_or_spdx: str, *,
8178
license_text: Optional[AttachedText] = None,
8279
license_url: Optional[XsUri] = None) -> LicenseChoice:
8380
"""Make a :class:`cyclonedx.model.LicenseChoice` with a license (name or SPDX-ID)."""
84-
return LicenseChoice(license_=self.license_factory.make_from_string(
81+
return LicenseChoice(license=self.license_factory.make_from_string(
8582
name_or_spdx, license_text=license_text, license_url=license_url))

0 commit comments

Comments
 (0)