Skip to content

Commit ff9b6a1

Browse files
Merge branch 'main' into bugfix_dependency_warning_617
2 parents 3b17a57 + 5860b67 commit ff9b6a1

Some content is hidden

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

43 files changed

+683
-42
lines changed

.github/workflows/python.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ name: Python CI
44

55
on:
66
push:
7-
branches: ["main"]
7+
branches: ["main", "next"]
8+
tags: [ 'v*' ]
89
pull_request:
9-
branches-ignore: ['dependabot/**']
1010
workflow_dispatch:
1111
schedule:
12-
# schedule weekly tests, since some dependencies are not intended to be pinned
13-
# this means: at 23:42 on Fridays
14-
- cron: '42 23 * * 5'
12+
# schedule daily tests, since some dependencies are not intended to be pinned
13+
# this means: at 23:42 every day
14+
- cron: '42 23 * * *'
1515

1616
concurrency:
1717
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Release
22

33
on:
4-
push:
5-
branches: [ 'main', 'master' ]
64
workflow_dispatch:
75
inputs:
86
release_force:

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22

33

44

5+
## v8.3.0 (2024-10-26)
6+
7+
### Documentation
8+
9+
* docs: revisit examples readme (#725)
10+
11+
Signed-off-by: Jan Kowalleck <[email protected]> ([`e9020f0`](https://github.com/CycloneDX/cyclonedx-python-lib/commit/e9020f0b709a5245d1749d2811b8568f892869bb))
12+
13+
### Feature
14+
15+
* feat: add basic support for Definitions (#701)
16+
17+
18+
19+
---------
20+
21+
Signed-off-by: Hakan Dilek <[email protected]> ([`a1573e5`](https://github.com/CycloneDX/cyclonedx-python-lib/commit/a1573e5af12bb54c7328c73971dc2c2f8d820c0a))
22+
23+
24+
## v8.2.1 (2024-10-24)
25+
26+
### Fix
27+
28+
* fix: encode quotation mark in URL (#724)
29+
30+
Signed-off-by: Jan Kowalleck <[email protected]> ([`a7c7c97`](https://github.com/CycloneDX/cyclonedx-python-lib/commit/a7c7c97c37ee1c7988c028aa779f74893f858c7b))
31+
32+
533
## v8.2.0 (2024-10-22)
634

735
### Feature

cyclonedx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
# !! version is managed by semantic_release
2424
# do not use typing here, or else `semantic_release` might have issues finding the variable
25-
__version__ = "8.2.0" # noqa:Q000
25+
__version__ = "8.3.0" # noqa:Q000

cyclonedx/_internal/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020
!!! ALL SYMBOLS IN HERE ARE INTERNAL.
2121
Everything might change without any notice.
2222
"""
23+
24+
# THIS FILE IS INTENDED TO BE EMPTY.
25+
# Put symbols in own modules/packages, not in this file!

cyclonedx/_internal/bom_ref.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This file is part of CycloneDX Python Library
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+
"""
20+
!!! ALL SYMBOLS IN HERE ARE INTERNAL.
21+
Everything might change without any notice.
22+
"""
23+
24+
from typing import Literal, Optional, Union, overload
25+
26+
from ..model.bom_ref import BomRef
27+
28+
29+
@overload
30+
def bom_ref_from_str(bom_ref: BomRef, optional: bool = ...) -> BomRef:
31+
... # pragma: no cover
32+
33+
34+
@overload
35+
def bom_ref_from_str(bom_ref: Optional[str], optional: Literal[False] = False) -> BomRef:
36+
... # pragma: no cover
37+
38+
39+
@overload
40+
def bom_ref_from_str(bom_ref: Optional[str], optional: Literal[True] = ...) -> Optional[BomRef]:
41+
... # pragma: no cover
42+
43+
44+
def bom_ref_from_str(bom_ref: Optional[Union[str, BomRef]], optional: bool = False) -> Optional[BomRef]:
45+
if isinstance(bom_ref, BomRef):
46+
return bom_ref
47+
if bom_ref:
48+
return BomRef(value=str(bom_ref))
49+
return None \
50+
if optional \
51+
else BomRef()

cyclonedx/model/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ class XsUri(serializable.helpers.BaseHelper):
689689

690690
__SPEC_REPLACEMENTS = (
691691
(' ', '%20'),
692+
('"', '%22'),
693+
("'", '%27'),
692694
('[', '%5B'),
693695
(']', '%5D'),
694696
('<', '%3C'),

cyclonedx/model/bom.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from .bom_ref import BomRef
4242
from .component import Component
4343
from .contact import OrganizationalContact, OrganizationalEntity
44+
from .definition import Definitions
4445
from .dependency import Dependable, Dependency
4546
from .license import License, LicenseExpression, LicenseRepository
4647
from .lifecycle import Lifecycle, LifecycleRepository, _LifecycleRepositoryHelper
@@ -327,6 +328,7 @@ def __init__(
327328
dependencies: Optional[Iterable[Dependency]] = None,
328329
vulnerabilities: Optional[Iterable[Vulnerability]] = None,
329330
properties: Optional[Iterable[Property]] = None,
331+
definitions: Optional[Definitions] = None,
330332
) -> None:
331333
"""
332334
Create a new Bom that you can manually/programmatically add data to later.
@@ -343,6 +345,7 @@ def __init__(
343345
self.vulnerabilities = vulnerabilities or [] # type:ignore[assignment]
344346
self.dependencies = dependencies or [] # type:ignore[assignment]
345347
self.properties = properties or [] # type:ignore[assignment]
348+
self.definitions = definitions or Definitions()
346349

347350
@property
348351
@serializable.type_mapping(UrnUuidHelper)
@@ -552,6 +555,22 @@ def vulnerabilities(self, vulnerabilities: Iterable[Vulnerability]) -> None:
552555
# def formulation(self, ...) -> None:
553556
# ... # TODO Since CDX 1.5
554557

558+
@property
559+
@serializable.view(SchemaVersion1Dot6)
560+
@serializable.xml_sequence(110)
561+
def definitions(self) -> Optional[Definitions]:
562+
"""
563+
The repository for definitions
564+
565+
Returns:
566+
`Definitions`
567+
"""
568+
return self._definitions if len(self._definitions.standards) > 0 else None
569+
570+
@definitions.setter
571+
def definitions(self, definitions: Definitions) -> None:
572+
self._definitions = definitions
573+
555574
def get_component_by_purl(self, purl: Optional['PackageURL']) -> Optional[Component]:
556575
"""
557576
Get a Component already in the Bom by its PURL

cyclonedx/model/component.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from packageurl import PackageURL
2727
from sortedcontainers import SortedSet
2828

29+
from .._internal.bom_ref import bom_ref_from_str as _bom_ref_from_str
2930
from .._internal.compare import ComparablePackageURL as _ComparablePackageURL, ComparableTuple as _ComparableTuple
3031
from .._internal.hash import file_sha1sum as _file_sha1sum
3132
from ..exception.model import InvalidOmniBorIdException, InvalidSwhidException, NoPropertiesProvidedException
@@ -1097,10 +1098,7 @@ def __init__(
10971098
) -> None:
10981099
self.type = type
10991100
self.mime_type = mime_type
1100-
if isinstance(bom_ref, BomRef):
1101-
self._bom_ref = bom_ref
1102-
else:
1103-
self._bom_ref = BomRef(value=str(bom_ref) if bom_ref else None)
1101+
self._bom_ref = _bom_ref_from_str(bom_ref)
11041102
self.supplier = supplier
11051103
self.manufacturer = manufacturer
11061104
self.authors = authors or [] # type:ignore[assignment]

cyclonedx/model/contact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import serializable
2222
from sortedcontainers import SortedSet
2323

24+
from .._internal.bom_ref import bom_ref_from_str as _bom_ref_from_str
2425
from .._internal.compare import ComparableTuple as _ComparableTuple
2526
from ..exception.model import NoPropertiesProvidedException
2627
from ..schema.schema import SchemaVersion1Dot6
@@ -49,8 +50,7 @@ def __init__(
4950
postal_code: Optional[str] = None,
5051
street_address: Optional[str] = None,
5152
) -> None:
52-
self._bom_ref = bom_ref if isinstance(bom_ref, BomRef) else BomRef(
53-
value=bom_ref) if bom_ref else None
53+
self._bom_ref = _bom_ref_from_str(bom_ref, optional=True)
5454
self.country = country
5555
self.region = region
5656
self.locality = locality

0 commit comments

Comments
 (0)