spdx_tools.spdx3.model.software.sbom

 1# SPDX-FileCopyrightText: 2023 spdx contributors
 2#
 3# SPDX-License-Identifier: Apache-2.0
 4from dataclasses import field
 5from enum import Enum, auto
 6
 7from beartype.typing import List, Optional
 8
 9from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
10from spdx_tools.common.typing.type_checks import check_types_and_set_values
11from spdx_tools.spdx3.model import (
12    Bom,
13    CreationInfo,
14    ExternalIdentifier,
15    ExternalMap,
16    ExternalReference,
17    IntegrityMethod,
18    NamespaceMap,
19)
20
21
22class SBOMType(Enum):
23    DESIGN = auto()
24    SOURCE = auto()
25    BUILD = auto()
26    DEPLOYED = auto()
27    RUNTIME = auto()
28    ANALYZED = auto()
29
30
31@dataclass_with_properties
32class Sbom(Bom):
33    sbom_type: List[SBOMType] = field(default_factory=list)
34
35    # We overwrite the super-__init__ as check_types_and_set_values()
36    # takes care of all fields (including inherited ones).
37    def __init__(
38        self,
39        spdx_id: str,
40        element: List[str],
41        root_element: List[str],
42        creation_info: Optional[CreationInfo] = None,
43        name: Optional[str] = None,
44        summary: Optional[str] = None,
45        description: Optional[str] = None,
46        comment: Optional[str] = None,
47        verified_using: List[IntegrityMethod] = None,
48        external_reference: List[ExternalReference] = None,
49        external_identifier: List[ExternalIdentifier] = None,
50        extension: Optional[str] = None,
51        namespaces: List[NamespaceMap] = None,
52        imports: List[ExternalMap] = None,
53        context: Optional[str] = None,
54        sbom_type: List[SBOMType] = None,
55    ):
56        verified_using = [] if verified_using is None else verified_using
57        external_reference = [] if external_reference is None else external_reference
58        external_identifier = [] if external_identifier is None else external_identifier
59        namespaces = [] if namespaces is None else namespaces
60        imports = [] if imports is None else imports
61        sbom_type = [] if sbom_type is None else sbom_type
62        check_types_and_set_values(self, locals())
class SBOMType(enum.Enum):
23class SBOMType(Enum):
24    DESIGN = auto()
25    SOURCE = auto()
26    BUILD = auto()
27    DEPLOYED = auto()
28    RUNTIME = auto()
29    ANALYZED = auto()
DESIGN = <SBOMType.DESIGN: 1>
SOURCE = <SBOMType.SOURCE: 2>
BUILD = <SBOMType.BUILD: 3>
DEPLOYED = <SBOMType.DEPLOYED: 4>
RUNTIME = <SBOMType.RUNTIME: 5>
ANALYZED = <SBOMType.ANALYZED: 6>
Inherited Members
enum.Enum
name
value
@dataclass_with_properties
class Sbom(spdx_tools.spdx3.model.bom.Bom):
32@dataclass_with_properties
33class Sbom(Bom):
34    sbom_type: List[SBOMType] = field(default_factory=list)
35
36    # We overwrite the super-__init__ as check_types_and_set_values()
37    # takes care of all fields (including inherited ones).
38    def __init__(
39        self,
40        spdx_id: str,
41        element: List[str],
42        root_element: List[str],
43        creation_info: Optional[CreationInfo] = None,
44        name: Optional[str] = None,
45        summary: Optional[str] = None,
46        description: Optional[str] = None,
47        comment: Optional[str] = None,
48        verified_using: List[IntegrityMethod] = None,
49        external_reference: List[ExternalReference] = None,
50        external_identifier: List[ExternalIdentifier] = None,
51        extension: Optional[str] = None,
52        namespaces: List[NamespaceMap] = None,
53        imports: List[ExternalMap] = None,
54        context: Optional[str] = None,
55        sbom_type: List[SBOMType] = None,
56    ):
57        verified_using = [] if verified_using is None else verified_using
58        external_reference = [] if external_reference is None else external_reference
59        external_identifier = [] if external_identifier is None else external_identifier
60        namespaces = [] if namespaces is None else namespaces
61        imports = [] if imports is None else imports
62        sbom_type = [] if sbom_type is None else sbom_type
63        check_types_and_set_values(self, locals())
Sbom( spdx_id: str, element: list[str], root_element: list[str], creation_info: Optional[spdx_tools.spdx3.model.creation_info.CreationInfo] = None, name: Optional[str] = None, summary: Optional[str] = None, description: Optional[str] = None, comment: Optional[str] = None, verified_using: list[spdx_tools.spdx3.model.integrity_method.IntegrityMethod] = None, external_reference: list[spdx_tools.spdx3.model.external_reference.ExternalReference] = None, external_identifier: list[spdx_tools.spdx3.model.external_identifier.ExternalIdentifier] = None, extension: Optional[str] = None, namespaces: list[spdx_tools.spdx3.model.namespace_map.NamespaceMap] = None, imports: list[spdx_tools.spdx3.model.external_map.ExternalMap] = None, context: Optional[str] = None, sbom_type: list[SBOMType] = None)
38    def __init__(
39        self,
40        spdx_id: str,
41        element: List[str],
42        root_element: List[str],
43        creation_info: Optional[CreationInfo] = None,
44        name: Optional[str] = None,
45        summary: Optional[str] = None,
46        description: Optional[str] = None,
47        comment: Optional[str] = None,
48        verified_using: List[IntegrityMethod] = None,
49        external_reference: List[ExternalReference] = None,
50        external_identifier: List[ExternalIdentifier] = None,
51        extension: Optional[str] = None,
52        namespaces: List[NamespaceMap] = None,
53        imports: List[ExternalMap] = None,
54        context: Optional[str] = None,
55        sbom_type: List[SBOMType] = None,
56    ):
57        verified_using = [] if verified_using is None else verified_using
58        external_reference = [] if external_reference is None else external_reference
59        external_identifier = [] if external_identifier is None else external_identifier
60        namespaces = [] if namespaces is None else namespaces
61        imports = [] if imports is None else imports
62        sbom_type = [] if sbom_type is None else sbom_type
63        check_types_and_set_values(self, locals())
sbom_type: list[SBOMType]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")