Skip to content

Commit 3cb14e0

Browse files
authored
Merge pull request #311 from CycloneDX/feat/update-lib-2.0.x
BREAKING CHANGE: update to latest RC of `cyclonedx-python-lib`
2 parents 8379712 + e193521 commit 3cb14e0

17 files changed

+111
-70
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Once installed, you can access the full documentation by running `--help`:
4444
```text
4545
$ cyclonedx-bom --help
4646
usage: cyclonedx-bom [-h] (-c | -cj | -e | -p | -pip | -r) [-i FILE_PATH]
47-
[--format {json,xml}] [--schema-version {1.3,1.2,1.1,1.0}]
47+
[--format {json,xml}] [--schema-version {1.4,1.3,1.2,1.1,1.0}]
4848
[-o FILE_PATH] [-F] [-X]
4949
5050
CycloneDX SBOM Generator
@@ -83,9 +83,9 @@ SBOM Output Configuration:
8383
Choose the output format and schema version
8484
8585
--format {json,xml} The output format for your SBOM (default: xml)
86-
--schema-version {1.3,1.2,1.1,1.0}
86+
--schema-version {1.4,1.3,1.2,1.1,1.0}
8787
The CycloneDX schema version for your SBOM (default:
88-
1.3)
88+
1.4)
8989
-o FILE_PATH, --o FILE_PATH, --output FILE_PATH
9090
Output file path for your SBOM (set to '-' to output
9191
to STDOUT)

cyclonedx_py/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# encoding: utf-8
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.

cyclonedx_py/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_output(self) -> BaseOutput:
8989
from importlib.metadata import version as md_version
9090
else:
9191
from importlib_metadata import version as md_version # type: ignore
92-
bom.metadata.add_tool(tool=Tool(
92+
bom.metadata.tools.add(Tool(
9393
vendor='CycloneDX', name='cyclonedx-bom', version=md_version('cyclonedx-bom')
9494
))
9595

@@ -181,7 +181,7 @@ def get_arg_parser() -> argparse.ArgumentParser:
181181
dest='output_format'
182182
)
183183
output_group.add_argument(
184-
'--schema-version', action='store', choices=['1.4', '1.3', '1.2', '1.1', '1.0'], default='1.3',
184+
'--schema-version', action='store', choices=['1.4', '1.3', '1.2', '1.1', '1.0'], default='1.4',
185185
help='The CycloneDX schema version for your SBOM (default: %(default)s)',
186186
dest='output_schema_version'
187187
)

cyclonedx_py/parser/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.
1617

1718
"""
1819
Set of concrete classes and methods which allow for quick creation of a Bom instance from your environment or Python

cyclonedx_py/parser/conda.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from abc import ABCMeta, abstractmethod
2222
from typing import List
2323

24-
from cyclonedx.model import ExternalReference, ExternalReferenceType
24+
from cyclonedx.model import ExternalReference, ExternalReferenceType, XsUri
2525
from cyclonedx.model.component import Component
2626
from cyclonedx.parser import BaseParser
2727
# See https://github.com/package-url/packageurl-python/issues/65
@@ -65,9 +65,9 @@ def _conda_packages_to_components(self) -> None:
6565
type='pypi', name=conda_package['name'], version=str(conda_package['version'])
6666
)
6767
)
68-
c.add_external_reference(ExternalReference(
68+
c.external_references.add(ExternalReference(
6969
reference_type=ExternalReferenceType.DISTRIBUTION,
70-
url=conda_package['base_url'],
70+
url=XsUri(conda_package['base_url']),
7171
comment=f"Distribution name {conda_package['dist_name']}"
7272
))
7373

cyclonedx_py/parser/environment.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ def __init__(self) -> None:
6868
c.author = i_metadata['Author']
6969

7070
if 'License' in i_metadata and i_metadata['License'] != 'UNKNOWN':
71-
c.licenses.append(
72-
LicenseChoice(license_expression=i_metadata['License'])
73-
)
71+
c.licenses.add(LicenseChoice(license_expression=i_metadata['License']))
7472

7573
if 'Classifier' in i_metadata:
7674
for classifier in i_metadata['Classifier']:
7775
if str(classifier).startswith('License :: OSI Approved :: '):
78-
c.licenses.append(
76+
c.licenses.add(
7977
LicenseChoice(
8078
license_expression=str(classifier).replace('License :: OSI Approved :: ', '').strip()
8179
)

cyclonedx_py/parser/pipenv.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import json
2121
from typing import Any, Dict
2222

23-
from cyclonedx.model import ExternalReference, ExternalReferenceType, HashType
23+
from cyclonedx.model import ExternalReference, ExternalReferenceType, HashType, XsUri
2424
from cyclonedx.model.component import Component
2525
from cyclonedx.parser import BaseParser
2626
# See https://github.com/package-url/packageurl-python/issues/65
@@ -48,11 +48,11 @@ def __init__(self, pipenv_contents: str) -> None:
4848
for pip_hash in package_data['hashes']:
4949
ext_ref = ExternalReference(
5050
reference_type=ExternalReferenceType.DISTRIBUTION,
51-
url=c.get_pypi_url(),
51+
url=XsUri(c.get_pypi_url()),
5252
comment='Distribution available from pypi.org'
5353
)
54-
ext_ref.add_hash(HashType.from_composite_str(pip_hash))
55-
c.add_external_reference(ext_ref)
54+
ext_ref.hashes.add(HashType.from_composite_str(pip_hash))
55+
c.external_references.add(ext_ref)
5656

5757
self._components.append(c)
5858

cyclonedx_py/parser/poetry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Copyright (c) OWASP Foundation. All Rights Reserved.
1919

2020
from cyclonedx.exception.model import UnknownHashTypeException
21-
from cyclonedx.model import ExternalReference, ExternalReferenceType, HashType
21+
from cyclonedx.model import ExternalReference, ExternalReferenceType, HashType, XsUri
2222
from cyclonedx.model.component import Component
2323
from cyclonedx.parser import BaseParser
2424
# See https://github.com/package-url/packageurl-python/issues/65
@@ -41,9 +41,9 @@ def __init__(self, poetry_lock_contents: str) -> None:
4141

4242
for file_metadata in poetry_lock['metadata']['files'][package['name']]:
4343
try:
44-
component.add_external_reference(ExternalReference(
44+
component.external_references.add(ExternalReference(
4545
reference_type=ExternalReferenceType.DISTRIBUTION,
46-
url=component.get_pypi_url(),
46+
url=XsUri(component.get_pypi_url()),
4747
comment=f'Distribution file: {file_metadata["file"]}',
4848
hashes=[HashType.from_composite_str(file_metadata['hash'])]
4949
))

cyclonedx_py/py.typed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Marker file for PEP 561. This package uses inline types.
2+
# This file is needed to allow other packages to type-check their code against this package.

cyclonedx_py/utils/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# encoding: utf-8
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
18+
"""
19+
Set of utility classes.
20+
"""

0 commit comments

Comments
 (0)