|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +# you may not use this file except in compliance with the License. |
| 3 | +# You may obtain a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +# See the License for the specific language governing permissions and |
| 11 | +# limitations under the License. |
| 12 | +# |
| 13 | +# SPDX-License-Identifier: Apache-2.0 |
| 14 | +# Copyright (c) OWASP Foundation. All Rights Reserved. |
| 15 | + |
| 16 | +"""Representation of this very python library.""" |
| 17 | + |
| 18 | +__all__ = ['this_tool', 'this_component'] |
| 19 | + |
| 20 | +from typing import Iterable |
| 21 | + |
| 22 | +from .. import __version__ as __ThisVersion # noqa: N812 |
| 23 | +from ..model import ExternalReference, ExternalReferenceType, Tool, XsUri |
| 24 | +from ..model.component import Component, ComponentType |
| 25 | +from ..model.license import DisjunctiveLicense, LicenseAcknowledgement |
| 26 | + |
| 27 | +# !!! keep this file in sync with `pyproject.toml` |
| 28 | + |
| 29 | +# !!! |
| 30 | +# things in here are built on demand, rather than using prepared frozen constants. |
| 31 | +# this is currently a draft and may change in the future. |
| 32 | +# !!! |
| 33 | + |
| 34 | + |
| 35 | +def __ext_refs() -> Iterable[ExternalReference]: |
| 36 | + return ( |
| 37 | + ExternalReference( |
| 38 | + type=ExternalReferenceType.BUILD_SYSTEM, |
| 39 | + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/actions') |
| 40 | + ), |
| 41 | + ExternalReference( |
| 42 | + type=ExternalReferenceType.DISTRIBUTION, |
| 43 | + url=XsUri('https://pypi.org/project/cyclonedx-python-lib/') |
| 44 | + ), |
| 45 | + ExternalReference( |
| 46 | + type=ExternalReferenceType.DOCUMENTATION, |
| 47 | + url=XsUri('https://cyclonedx-python-library.readthedocs.io/') |
| 48 | + ), |
| 49 | + ExternalReference( |
| 50 | + type=ExternalReferenceType.ISSUE_TRACKER, |
| 51 | + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/issues') |
| 52 | + ), |
| 53 | + ExternalReference( |
| 54 | + type=ExternalReferenceType.LICENSE, |
| 55 | + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE') |
| 56 | + ), |
| 57 | + ExternalReference( |
| 58 | + type=ExternalReferenceType.RELEASE_NOTES, |
| 59 | + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md') |
| 60 | + ), |
| 61 | + ExternalReference( |
| 62 | + type=ExternalReferenceType.VCS, |
| 63 | + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib') |
| 64 | + ), |
| 65 | + ExternalReference( |
| 66 | + type=ExternalReferenceType.WEBSITE, |
| 67 | + url=XsUri('https://github.com/CycloneDX/cyclonedx-python-lib/#readme') |
| 68 | + ), |
| 69 | + ) |
| 70 | + |
| 71 | + |
| 72 | +def this_tool() -> Tool: |
| 73 | + """Representation of this very python library as a :class:`Tool`.""" |
| 74 | + |
| 75 | + return Tool( |
| 76 | + vendor='CycloneDX', |
| 77 | + name='cyclonedx-python-lib', |
| 78 | + version=__ThisVersion or 'UNKNOWN', |
| 79 | + external_references=__ext_refs(), |
| 80 | + ) |
| 81 | + |
| 82 | + |
| 83 | +def this_component() -> Component: |
| 84 | + """Representation of this very python library as a :class:`Component`.""" |
| 85 | + |
| 86 | + return Component( |
| 87 | + type=ComponentType.LIBRARY, |
| 88 | + group='CycloneDX', |
| 89 | + name='cyclonedx-python-lib', |
| 90 | + version=__ThisVersion or 'UNKNOWN', |
| 91 | + description='Python library for CycloneDX', |
| 92 | + licenses=(DisjunctiveLicense(id='Apache-2.0', |
| 93 | + acknowledgement=LicenseAcknowledgement.DECLARED),), |
| 94 | + external_references=__ext_refs(), |
| 95 | + # to be expanded ... |
| 96 | + ) |
0 commit comments