Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0546677
feat: add basic support for CDX 1.5 (#488)
Churro Nov 27, 2023
cb0d5b6
tests: remove unused test snapshots
jkowalleck Nov 28, 2023
e9cc5ee
Remove deprecated 6.0.0 (#493)
jkowalleck Nov 28, 2023
b10dc83
bc: remove const `output.LATEST_SUPPORTED_SCHEMA_VERSION` (#494)
jkowalleck Nov 28, 2023
ac1f48a
bc: remove parser API (#495)
jkowalleck Nov 28, 2023
6c204f7
Feat: prevent unknwon enums from rendering (#496)
jkowalleck Nov 30, 2023
dada5d7
feat!: v6.0.0 RC1
jkowalleck Nov 30, 2023
db54c95
chore(release): 6.0.0-rc.1
Nov 30, 2023
9b9edcd
revert RC chaneglog
jkowalleck Nov 30, 2023
1627280
style: comments/reformat
jkowalleck Dec 1, 2023
a82d88e
Merge branch 'main' into 6.0.0-dev
jkowalleck Dec 2, 2023
d1dc14b
tests: add test snapshots
jkowalleck Dec 2, 2023
ef76c49
Merge remote-tracking branch 'origin/main' into 6.0.0-dev
jkowalleck Dec 3, 2023
b9193a2
`BomRef.value` default `None` (#505)
jkowalleck Dec 4, 2023
7c669be
BC: Helpes internal (#506)
jkowalleck Dec 5, 2023
8eb7786
docs
jkowalleck Dec 5, 2023
1fe7cae
revisit `BomRef`
jkowalleck Dec 5, 2023
690646c
refactor: revisit `type:ignore` (#507)
jkowalleck Dec 5, 2023
3c3ebd7
feat!: v6.0.0 RC2
jkowalleck Dec 5, 2023
0001429
chore(release): 6.0.0-rc.2
Dec 5, 2023
1a8740a
chore: revert history
jkowalleck Dec 5, 2023
3e08420
docs
jkowalleck Dec 5, 2023
e29b825
Merge branch 'main' into 6.0.0-dev
jkowalleck Dec 10, 2023
146f558
chore: bump bugbearer & fix some findings
jkowalleck Dec 10, 2023
b37f859
Merge remote-tracking branch 'origin/main' into 6.0.0-dev
jkowalleck Dec 10, 2023
6729398
build: use poetry v1.7.1
jkowalleck Dec 10, 2023
57b1b6f
feat!: v6.0.0 RC3
jkowalleck Dec 10, 2023
33cf0c5
chore(release): 6.0.0-rc.3
Dec 10, 2023
393f92f
chore: revert history
jkowalleck Dec 10, 2023
3f84b44
docs
jkowalleck Dec 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:
env:
REPORTS_DIR: CI_reports
PYTHON_VERSION_DEFAULT: "3.11"
POETRY_VERSION: "1.4.1"
POETRY_VERSION: "1.7.1"
TESTS_REPORTS_ARTIFACT: tests-reports

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ concurrency:

env:
PYTHON_VERSION_DEFAULT: "3.11"
POETRY_VERSION: "1.4.1"
POETRY_VERSION: "1.7.1"

jobs:
quicktest:
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

----

This Python package can render and read valid [CycloneDX][link_website] documents.
CycloneDX is a lightweight BOM specification that is easily created, human-readable, and simple to parse.
OWASP [CycloneDX][link_website] is a full-stack Bill of Materials (BOM) standard
that provides advanced supply chain capabilities for cyber risk reduction.

**This module is not designed for standalone use.**
This Python package provides data models, validators and more,
to help you create/render/read CycloneDX documents.

**This package is not designed for standalone use. It is a library.**

As of version `3.0.0`, the internal data model was adjusted to allow CycloneDX VEX documents to be produced as per
[official examples](https://cyclonedx.org/capabilities/bomlink/#linking-external-vex-to-bom-inventory) linking a VEX
Expand All @@ -27,6 +30,8 @@ If you're looking for a CycloneDX tool to run to generate (SBOM) software bill-o

Alternatively, you can use this module yourself in your application to programmatically generate CycloneDX BOMs.

## Documentation

View the documentation [here](https://cyclonedx-python-library.readthedocs.io/).

## Python Support
Expand Down
2 changes: 1 addition & 1 deletion cyclonedx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
# !! version is managed by semantic_release
# do not use typing here, or else `semantic_release` might have issues finding the variable
# flake8: noqa
__version__ = "5.2.0"
__version__ = "6.0.0-rc.3"
20 changes: 20 additions & 0 deletions cyclonedx/_internal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) OWASP Foundation. All Rights Reserved.


"""
!!! ALL SYMBOLS IN HERE ARE INTERNAL.
Everything might change without any notice.
"""
54 changes: 54 additions & 0 deletions cyclonedx/_internal/compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) OWASP Foundation. All Rights Reserved.


"""
!!! ALL SYMBOLS IN HERE ARE INTERNAL.
Everything might change without any notice.
"""


from itertools import zip_longest
from typing import Any, Optional, Tuple


class ComparableTuple(Tuple[Optional[Any], ...]):
"""
Allows comparison of tuples, allowing for None values.
"""

def __lt__(self, other: Any) -> bool:
for s, o in zip_longest(self, other):
if s == o:
continue
# the idea is to have any consistent order, not necessarily "natural" order.
if s is None:
return False
if o is None:
return True
return True if s < o else False
return False

def __gt__(self, other: Any) -> bool:
for s, o in zip_longest(self, other):
if s == o:
continue
# the idea is to have any consistent order, not necessarily "natural" order.
if s is None:
return True
if o is None:
return False
return True if s > o else False
return False
41 changes: 41 additions & 0 deletions cyclonedx/_internal/hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) OWASP Foundation. All Rights Reserved.


"""
!!! ALL SYMBOLS IN HERE ARE INTERNAL.
Everything might change without any notice.
"""


from hashlib import sha1


def file_sha1sum(filename: str) -> str:
"""
Generate a SHA1 hash of the provided file.

Args:
filename:
Absolute path to file to hash as `str`

Returns:
SHA-1 hash
"""
h = sha1() # nosec B303, B324
with open(filename, 'rb') as f:
for byte_block in iter(lambda: f.read(4096), b''):
h.update(byte_block)
return h.hexdigest()
27 changes: 27 additions & 0 deletions cyclonedx/_internal/time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) OWASP Foundation. All Rights Reserved.


"""
!!! ALL SYMBOLS IN HERE ARE INTERNAL.
Everything might change without any notice.
"""


from datetime import datetime, timezone


def get_now_utc() -> datetime:
return datetime.now(tz=timezone.utc)
1 change: 0 additions & 1 deletion cyclonedx/exception/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class NoPropertiesProvidedException(CycloneDxModelException):
"""
Raised when attempting to construct a model class and providing NO values (where all properites are defined as
Optional, but at least one is required).

"""
pass

Expand Down
50 changes: 50 additions & 0 deletions cyclonedx/exception/serialization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) OWASP Foundation. All Rights Reserved.


"""
Exceptions relating to specific conditions that occur when (de)serializing/(de)normalizing CycloneDX BOM.
"""

from . import CycloneDxException


class CycloneDxSerializationException(CycloneDxException):
"""
Base exception that covers all exceptions that may be thrown during model serializing/normalizing.
"""
pass


class CycloneDxDeserializationException(CycloneDxException):
"""
Base exception that covers all exceptions that may be thrown during model deserializing/denormalizing.
"""
pass


class SerializationOfUnsupportedComponentTypeException(CycloneDxSerializationException):
"""
Raised when attempting serializing/normalizing a :py:class:`cyclonedx.model.component.Component`
to a :py:class:`cyclonedx.schema.schema.BaseSchemaVersion`
which does not support that :py:class:`cyclonedx.model.component.ComponentType`
.
"""


class SerializationOfUnexpectedValueException(CycloneDxSerializationException, ValueError):
"""
Raised when attempting serializing/normalizing a type that is not expected there.
"""
Loading