Skip to content

generic_oscal

trestle.core.generic_oscal ¤

Generic classes to support both SSP and DefinedComponents.

IMPLEMENTED_REQUIREMENTS ¤

logger ¤

Classes¤

GenericByComponent (TrestleBaseModel) pydantic-model ¤

Generic ByComponent for SSP and DefinedComponent.

Source code in trestle/core/generic_oscal.py
class GenericByComponent(TrestleBaseModel):
    """Generic ByComponent for SSP and DefinedComponent."""

    # only in SSP
    component_uuid: constr(
        regex=r'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'  # noqa FS003
    ) = Field(
        ...,
        alias='component_uuid',
        description='A machine-oriented identifier reference to the component that is implemeting a given control.',
        title='Component Universally Unique Identifier Reference',
    )
    uuid: constr(
        regex=r'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'  # noqa FS003
    ) = Field(
        ...,
        description=  # noqa E251
        'A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference this by-component entry elsewhere in this or other OSCAL instances. The locally defined UUID of the by-component entry can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned per-subject, which means it should be consistently used to identify the same subject across revisions of the document.',  # noqa E501
        title='By-Component Universally Unique Identifier',
    )
    description: str = Field(
        ...,
        description=  # noqa E251
        'An implementation statement that describes how a control or a control statement is implemented within the referenced system component.',  # noqa E501
        title='Control Implementation Description',
    )
    props: Optional[List[common.Property]] = Field(None)
    links: Optional[List[common.Link]] = Field(None)
    set_parameters: Optional[List[GenericSetParameter]] = Field(None, alias='set-parameters')
    implementation_status: Optional[common.ImplementationStatus] = Field(None, alias='implementation-status')
    # removed export, inherited, satisfied
    responsible_roles: Optional[List[common.ResponsibleRole]] = Field(None, alias='responsible-roles')
    remarks: Optional[str] = None

    @staticmethod
    def generate() -> GenericByComponent:
        """Generate instance of generic ByComponent."""
        uuid = str(uuid4())
        return GenericByComponent(component_uuid=const.SAMPLE_UUID_STR, uuid=uuid, description='')

    def as_ssp(self) -> ossp.ByComponent:
        """Convert to ssp format."""
        set_params = []
        for set_param in as_list(self.set_parameters):
            new_set_param = ossp.SetParameter(
                param_id=set_param.param_id, values=set_param.values, remarks=set_param.remarks
            )
            set_params.append(new_set_param)
        set_params = none_if_empty(set_params)
        return ossp.ByComponent(
            component_uuid=self.component_uuid,
            uuid=self.uuid,
            description=self.description,
            props=self.props,
            links=self.links,
            set_parameters=set_params,
            implementation_status=self.implementation_status,
            responsible_roles=self.responsible_roles
        )
Attributes¤
__class_vars__ special ¤
__custom_root_type__ special ¤
__doc__ special ¤
__exclude_fields__ special ¤
__fields__ special ¤
__include_fields__ special ¤
__post_root_validators__ special ¤
__pre_root_validators__ special ¤
__private_attributes__ special ¤
__schema_cache__ special ¤
__signature__ special ¤
__slots__: Tuple[str, ...] special ¤
__validators__ special ¤
component_uuid: ConstrainedStrValue pydantic-field required ¤

A machine-oriented identifier reference to the component that is implemeting a given control.

description: str pydantic-field required ¤

An implementation statement that describes how a control or a control statement is implemented within the referenced system component.

implementation_status: ImplementationStatus pydantic-field ¤
props: List[trestle.oscal.common.Property] pydantic-field ¤
remarks: str pydantic-field ¤
responsible_roles: List[trestle.oscal.common.ResponsibleRole] pydantic-field ¤
set_parameters: Optional[List[GenericSetParameter]] pydantic-field ¤
uuid: ConstrainedStrValue pydantic-field required ¤

A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference this by-component entry elsewhere in this or other OSCAL instances. The locally defined UUID of the by-component entry can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned per-subject, which means it should be consistently used to identify the same subject across revisions of the document.

Methods¤
as_ssp(self) ¤

Convert to ssp format.

Source code in trestle/core/generic_oscal.py
def as_ssp(self) -> ossp.ByComponent:
    """Convert to ssp format."""
    set_params = []
    for set_param in as_list(self.set_parameters):
        new_set_param = ossp.SetParameter(
            param_id=set_param.param_id, values=set_param.values, remarks=set_param.remarks
        )
        set_params.append(new_set_param)
    set_params = none_if_empty(set_params)
    return ossp.ByComponent(
        component_uuid=self.component_uuid,
        uuid=self.uuid,
        description=self.description,
        props=self.props,
        links=self.links,
        set_parameters=set_params,
        implementation_status=self.implementation_status,
        responsible_roles=self.responsible_roles
    )
generate() staticmethod ¤

Generate instance of generic ByComponent.

Source code in trestle/core/generic_oscal.py
@staticmethod
def generate() -> GenericByComponent:
    """Generate instance of generic ByComponent."""
    uuid = str(uuid4())
    return GenericByComponent(component_uuid=const.SAMPLE_UUID_STR, uuid=uuid, description='')

GenericComponent (TrestleBaseModel) pydantic-model ¤

Generic component for SSP SystemComponent and DefinedComponent.

Source code in trestle/core/generic_oscal.py
class GenericComponent(TrestleBaseModel):
    """Generic component for SSP SystemComponent and DefinedComponent."""

    uuid: constr(
        regex=r'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'  # noqa FS003 F722
    ) = Field(
        ...,
        description=  # noqa E251
        'A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference this component elsewhere in this or other OSCAL instances. The locally defined UUID of the component can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned per-subject, which means it should be consistently used to identify the same subject across revisions of the document.',  # noqa E501
        title='Component Identifier',
    )
    type: constr(regex=r'^\S(.*\S)?$') = Field(  # noqa A003 F722
        ...,
        description='A category describing the purpose of the component.',
        title='Component Type',
    )
    title: str = Field(
        ...,
        description='A human readable name for the component.',
        title='Component Title',
    )
    description: str = Field(
        ...,
        description='A description of the component, including information about its function.',
        title='Component Description',
    )
    purpose: Optional[str] = Field(
        None,
        description='A summary of the technological or business purpose of the component.',
        title='Purpose',
    )
    props: Optional[List[common.Property]] = Field(None)
    links: Optional[List[common.Link]] = Field(None)
    responsible_roles: Optional[List[common.ResponsibleRole]] = Field(None, alias='responsible-roles')
    protocols: Optional[List[common.Protocol]] = Field(None)
    # ssp does not have a list of ci's but it does have one ci
    control_implementations: Optional[List[GenericControlImplementation]] = Field(None, alias='control-implementations')
    remarks: Optional[str] = None
    # ssp has
    status: common.ImplementationStatus

    def as_defined_component(self) -> comp.DefinedComponent:
        """Convert to DefinedComponent."""
        status = self.status
        class_dict = copy.deepcopy(self.__dict__)
        class_dict.pop('status', None)
        def_comp = comp.DefinedComponent(**class_dict)
        ControlInterface.insert_status_in_props(def_comp, status)
        return def_comp

    @classmethod
    def from_defined_component(cls, def_comp: comp.DefinedComponent) -> GenericComponent:
        """Convert defined component to generic."""
        status = ControlInterface.get_status_from_props(def_comp)
        class_dict = copy.deepcopy(def_comp.__dict__)
        if 'control_implementations' in class_dict:
            new_cis = []
            for ci in class_dict['control_implementations']:
                new_cis.append(GenericControlImplementation.from_component_ci(ci))
            class_dict['control-implementations'] = new_cis
            class_dict.pop('control_implementations', None)
        class_dict['status'] = status
        return cls(**class_dict)

    def as_system_component(self, status_override: str = '') -> ossp.SystemComponent:
        """Convert to SystemComponent."""
        class_dict = copy.deepcopy(self.__dict__)
        class_dict.pop('control_implementations', None)
        status_str = self.status.state if self.status else const.STATUS_OPERATIONAL
        status_str = status_override if status_override else status_str
        if status_str not in ['under-development', 'operational', 'disposition', 'other']:
            logger.warning(
                f'SystemComponent status {status_str} not recognized.  Setting to {const.STATUS_OPERATIONAL}'
            )
            status_str = const.STATUS_OPERATIONAL
        class_dict['status'] = ossp.Status(state=status_str, remarks=self.status.remarks)
        return ossp.SystemComponent(**class_dict)

    @staticmethod
    def generate() -> GenericComponent:
        """Generate instance of GenericComponent."""
        uuid = str(uuid4())
        status = common.ImplementationStatus(state=const.STATUS_OPERATIONAL)
        return GenericComponent(uuid=uuid, type=const.REPLACE_ME, title='', description='', status=status)
Attributes¤
__class_vars__ special ¤
__custom_root_type__ special ¤
__doc__ special ¤
__exclude_fields__ special ¤
__fields__ special ¤
__include_fields__ special ¤
__post_root_validators__ special ¤
__pre_root_validators__ special ¤
__private_attributes__ special ¤
__schema_cache__ special ¤
__signature__ special ¤
__slots__: Tuple[str, ...] special ¤
__validators__ special ¤
control_implementations: List[trestle.core.generic_oscal.GenericControlImplementation] pydantic-field ¤
description: str pydantic-field required ¤

A description of the component, including information about its function.

props: List[trestle.oscal.common.Property] pydantic-field ¤
protocols: List[trestle.oscal.common.Protocol] pydantic-field ¤
purpose: str pydantic-field ¤

A summary of the technological or business purpose of the component.

remarks: str pydantic-field ¤
responsible_roles: List[trestle.oscal.common.ResponsibleRole] pydantic-field ¤
status: ImplementationStatus pydantic-field required ¤
title: str pydantic-field required ¤

A human readable name for the component.

type: ConstrainedStrValue pydantic-field required ¤

A category describing the purpose of the component.

uuid: ConstrainedStrValue pydantic-field required ¤

A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference this component elsewhere in this or other OSCAL instances. The locally defined UUID of the component can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned per-subject, which means it should be consistently used to identify the same subject across revisions of the document.

Methods¤
as_defined_component(self) ¤

Convert to DefinedComponent.

Source code in trestle/core/generic_oscal.py
def as_defined_component(self) -> comp.DefinedComponent:
    """Convert to DefinedComponent."""
    status = self.status
    class_dict = copy.deepcopy(self.__dict__)
    class_dict.pop('status', None)
    def_comp = comp.DefinedComponent(**class_dict)
    ControlInterface.insert_status_in_props(def_comp, status)
    return def_comp
as_system_component(self, status_override='') ¤

Convert to SystemComponent.

Source code in trestle/core/generic_oscal.py
def as_system_component(self, status_override: str = '') -> ossp.SystemComponent:
    """Convert to SystemComponent."""
    class_dict = copy.deepcopy(self.__dict__)
    class_dict.pop('control_implementations', None)
    status_str = self.status.state if self.status else const.STATUS_OPERATIONAL
    status_str = status_override if status_override else status_str
    if status_str not in ['under-development', 'operational', 'disposition', 'other']:
        logger.warning(
            f'SystemComponent status {status_str} not recognized.  Setting to {const.STATUS_OPERATIONAL}'
        )
        status_str = const.STATUS_OPERATIONAL
    class_dict['status'] = ossp.Status(state=status_str, remarks=self.status.remarks)
    return ossp.SystemComponent(**class_dict)
from_defined_component(def_comp) classmethod ¤

Convert defined component to generic.

Source code in trestle/core/generic_oscal.py
@classmethod
def from_defined_component(cls, def_comp: comp.DefinedComponent) -> GenericComponent:
    """Convert defined component to generic."""
    status = ControlInterface.get_status_from_props(def_comp)
    class_dict = copy.deepcopy(def_comp.__dict__)
    if 'control_implementations' in class_dict:
        new_cis = []
        for ci in class_dict['control_implementations']:
            new_cis.append(GenericControlImplementation.from_component_ci(ci))
        class_dict['control-implementations'] = new_cis
        class_dict.pop('control_implementations', None)
    class_dict['status'] = status
    return cls(**class_dict)
generate() staticmethod ¤

Generate instance of GenericComponent.

Source code in trestle/core/generic_oscal.py
@staticmethod
def generate() -> GenericComponent:
    """Generate instance of GenericComponent."""
    uuid = str(uuid4())
    status = common.ImplementationStatus(state=const.STATUS_OPERATIONAL)
    return GenericComponent(uuid=uuid, type=const.REPLACE_ME, title='', description='', status=status)

GenericControlImplementation (TrestleBaseModel) pydantic-model ¤

Generic control implementation for SSP and CompDef.

Source code in trestle/core/generic_oscal.py
class GenericControlImplementation(TrestleBaseModel):
    """Generic control implementation for SSP and CompDef."""

    # not in ssp
    uuid: constr(
        regex=r'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'  # noqa FS003 F722
    ) = Field(
        ...,
        description=  # noqa E251
        'A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference a set of implemented controls elsewhere in this or other OSCAL instances. The locally defined UUID of the control implementation set can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned per-subject, which means it should be consistently used to identify the same subject across revisions of the document.',  # noqa E501
        title='Control Implementation Set Identifier',
    )
    # not in ssp
    source: str = Field(
        ...,
        description=  # noqa E251
        'A reference to an OSCAL catalog or profile providing the referenced control or subcontrol definition.',  # noqa E501
        title='Source Resource Reference',
    )
    description: str = Field(
        ...,
        description=  # noqa E251
        'A description of how the specified set of controls are implemented for the containing component or capability.',  # noqa E501
        title='Control Implementation Description',
    )
    # not in ssp
    props: Optional[List[common.Property]] = Field(None)
    # not in ssp
    links: Optional[List[common.Link]] = Field(None)
    set_parameters: Optional[List[GenericSetParameter]] = Field(None, alias='set-parameters')
    implemented_requirements: List[GenericImplementedRequirement] = Field(..., alias='implemented-requirements')

    @staticmethod
    def generate() -> GenericControlImplementation:
        """Generate instance of this class."""
        uuid = str(uuid4())
        imp_reqs = [GenericImplementedRequirement.generate()]
        class_dict = {
            'uuid': uuid,
            'control-id': const.REPLACE_ME,
            'source': const.REPLACE_ME,
            'description': '',
            'implemented-requirements': imp_reqs
        }
        return GenericControlImplementation(**class_dict)

    @classmethod
    def from_component_ci(cls, control_imp: comp.ControlImplementation) -> GenericControlImplementation:
        """Convert component control imp to generic."""
        class_dict = copy.deepcopy(control_imp.__dict__)
        if IMPLEMENTED_REQUIREMENTS in class_dict:
            new_irs = []
            ir_list = class_dict.get(IMPLEMENTED_REQUIREMENTS, None)
            for ir in as_list(ir_list):
                new_ir = GenericImplementedRequirement.from_comp_def(ir)
                new_irs.append(new_ir)
            class_dict['implemented-requirements'] = none_if_empty(new_irs)
            class_dict.pop(IMPLEMENTED_REQUIREMENTS, None)
            new_sps = []
            sp_list = class_dict.get('set_parameters', None)
            for sp in as_list(sp_list):
                new_sps.append(GenericSetParameter.from_defined_component(sp))
            class_dict['set-parameters'] = none_if_empty(new_sps)
            class_dict.pop('set_parameters', None)

        return cls(**class_dict)

    def as_ssp(self) -> ossp.ControlImplementation:
        """Represent in ssp form."""
        imp_reqs = []
        for imp_req in self.implemented_requirements:
            imp_reqs.append(imp_req.as_ssp())
        class_dict = self.__dict__
        for prop in ['uuid', 'source', 'props', 'links', IMPLEMENTED_REQUIREMENTS]:
            class_dict.pop(prop, None)
        if imp_reqs:
            class_dict['implemented-requirements'] = imp_reqs
            class_dict.pop(IMPLEMENTED_REQUIREMENTS, None)
        return ossp.ControlImplementation(**class_dict)
Attributes¤
__class_vars__ special ¤
__custom_root_type__ special ¤
__doc__ special ¤
__exclude_fields__ special ¤
__fields__ special ¤
__include_fields__ special ¤
__post_root_validators__ special ¤
__pre_root_validators__ special ¤
__private_attributes__ special ¤
__schema_cache__ special ¤
__signature__ special ¤
__slots__: Tuple[str, ...] special ¤
__validators__ special ¤
description: str pydantic-field required ¤

A description of how the specified set of controls are implemented for the containing component or capability.

implemented_requirements: List[trestle.core.generic_oscal.GenericImplementedRequirement] pydantic-field required ¤
props: List[trestle.oscal.common.Property] pydantic-field ¤
set_parameters: List[trestle.core.generic_oscal.GenericSetParameter] pydantic-field ¤
source: str pydantic-field required ¤

A reference to an OSCAL catalog or profile providing the referenced control or subcontrol definition.

uuid: ConstrainedStrValue pydantic-field required ¤

A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference a set of implemented controls elsewhere in this or other OSCAL instances. The locally defined UUID of the control implementation set can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance). This UUID should be assigned per-subject, which means it should be consistently used to identify the same subject across revisions of the document.

Methods¤
as_ssp(self) ¤

Represent in ssp form.

Source code in trestle/core/generic_oscal.py
def as_ssp(self) -> ossp.ControlImplementation:
    """Represent in ssp form."""
    imp_reqs = []
    for imp_req in self.implemented_requirements:
        imp_reqs.append(imp_req.as_ssp())
    class_dict = self.__dict__
    for prop in ['uuid', 'source', 'props', 'links', IMPLEMENTED_REQUIREMENTS]:
        class_dict.pop(prop, None)
    if imp_reqs:
        class_dict['implemented-requirements'] = imp_reqs
        class_dict.pop(IMPLEMENTED_REQUIREMENTS, None)
    return ossp.ControlImplementation(**class_dict)
from_component_ci(control_imp) classmethod ¤

Convert component control imp to generic.

Source code in trestle/core/generic_oscal.py
@classmethod
def from_component_ci(cls, control_imp: comp.ControlImplementation) -> GenericControlImplementation:
    """Convert component control imp to generic."""
    class_dict = copy.deepcopy(control_imp.__dict__)
    if IMPLEMENTED_REQUIREMENTS in class_dict:
        new_irs = []
        ir_list = class_dict.get(IMPLEMENTED_REQUIREMENTS, None)
        for ir in as_list(ir_list):
            new_ir = GenericImplementedRequirement.from_comp_def(ir)
            new_irs.append(new_ir)
        class_dict['implemented-requirements'] = none_if_empty(new_irs)
        class_dict.pop(IMPLEMENTED_REQUIREMENTS, None)
        new_sps = []
        sp_list = class_dict.get('set_parameters', None)
        for sp in as_list(sp_list):
            new_sps.append(GenericSetParameter.from_defined_component(sp))
        class_dict['set-parameters'] = none_if_empty(new_sps)
        class_dict.pop('set_parameters', None)

    return cls(**class_dict)
generate() staticmethod ¤

Generate instance of this class.

Source code in trestle/core/generic_oscal.py
@staticmethod
def generate() -> GenericControlImplementation:
    """Generate instance of this class."""
    uuid = str(uuid4())
    imp_reqs = [GenericImplementedRequirement.generate()]
    class_dict = {
        'uuid': uuid,
        'control-id': const.REPLACE_ME,
        'source': const.REPLACE_ME,
        'description': '',
        'implemented-requirements': imp_reqs
    }
    return GenericControlImplementation(**class_dict)

GenericImplementedRequirement (TrestleBaseModel) pydantic-model ¤

Generic ImplementedRequirement for SSP and DefinedComponent.

Source code in trestle/core/generic_oscal.py
class GenericImplementedRequirement(TrestleBaseModel):
    """Generic ImplementedRequirement for SSP and DefinedComponent."""

    uuid: constr(
        regex=r'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'  # noqa FS003 F722
    ) = Field(
        ...,
        description=  # noqa E251
        'A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference a specific control implementation elsewhere in this or other OSCAL instances. The locally defined UUID of the control implementation can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance).This UUID should be assigned per-subject, which means it should be consistently used to identify the same subject across revisions of the document.',  # noqa E501
        title='Control Implementation Identifier',
    )
    control_id: constr(
        regex=  # noqa E251
        r'^[_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-\.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$'  # noqa E501
    ) = Field(
        ...,
        alias='control-id',
        description=  # noqa E251
        'A human-oriented identifier reference to a control with a corresponding id value. When referencing an externally defined control, the Control Identifier Reference must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).',  # noqa E501
        title='Control Identifier Reference',
    )
    # only compdef has description
    description: str = Field(
        ...,
        description=  # noqa E251
        'A description of how the specified control is implemented for the containing component or capability.',  # noqa E501
        title='Control Implementation Description',
    )
    props: Optional[List[common.Property]] = Field(None)
    links: Optional[List[common.Link]] = Field(None)
    set_parameters: Optional[List[GenericSetParameter]] = Field(None, alias='set-parameters')
    responsible_roles: Optional[List[common.ResponsibleRole]] = Field(None, alias='responsible-roles')
    statements: Optional[List[GenericStatement]] = Field(None)
    remarks: Optional[str] = None
    # ssp has following
    by_components: Optional[List[GenericByComponent]] = Field(None, alias='by-components')

    @staticmethod
    def generate() -> GenericImplementedRequirement:
        """Generate instance of this class."""
        uuid = str(uuid4())
        class_dict = {'uuid': uuid, 'control-id': const.REPLACE_ME, 'description': ''}
        return GenericImplementedRequirement(**class_dict)

    @classmethod
    def from_comp_def(cls, imp_req: comp.ImplementedRequirement) -> GenericImplementedRequirement:
        """Convert component form of imp req to generic."""
        class_dict = copy.deepcopy(imp_req.__dict__)
        class_dict['control-id'] = class_dict.pop('control_id', None)
        return cls(**class_dict)

    def as_ssp(self) -> ossp.ImplementedRequirement:
        """Convert to ssp form."""
        class_dict = copy.deepcopy(self.__dict__)
        del class_dict['description']
        new_stat_list = []
        for statement in as_list(self.statements):
            new_stat_list.append(statement.as_ssp())
        if new_stat_list:
            class_dict['statements'] = new_stat_list
        return ossp.ImplementedRequirement(**class_dict)
Attributes¤
__class_vars__ special ¤
__custom_root_type__ special ¤
__doc__ special ¤
__exclude_fields__ special ¤
__fields__ special ¤
__include_fields__ special ¤
__post_root_validators__ special ¤
__pre_root_validators__ special ¤
__private_attributes__ special ¤
__schema_cache__ special ¤
__signature__ special ¤
__slots__: Tuple[str, ...] special ¤
__validators__ special ¤
by_components: List[trestle.core.generic_oscal.GenericByComponent] pydantic-field ¤
control_id: ConstrainedStrValue pydantic-field required ¤

A human-oriented identifier reference to a control with a corresponding id value. When referencing an externally defined control, the Control Identifier Reference must be used in the context of the external / imported OSCAL instance (e.g., uri-reference).

description: str pydantic-field required ¤

A description of how the specified control is implemented for the containing component or capability.

props: List[trestle.oscal.common.Property] pydantic-field ¤
remarks: str pydantic-field ¤
responsible_roles: List[trestle.oscal.common.ResponsibleRole] pydantic-field ¤
set_parameters: List[trestle.core.generic_oscal.GenericSetParameter] pydantic-field ¤
statements: List[trestle.core.generic_oscal.GenericStatement] pydantic-field ¤
uuid: ConstrainedStrValue pydantic-field required ¤

A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference a specific control implementation elsewhere in this or other OSCAL instances. The locally defined UUID of the control implementation can be used to reference the data item locally or globally (e.g., in an imported OSCAL instance).This UUID should be assigned per-subject, which means it should be consistently used to identify the same subject across revisions of the document.

Methods¤
as_ssp(self) ¤

Convert to ssp form.

Source code in trestle/core/generic_oscal.py
def as_ssp(self) -> ossp.ImplementedRequirement:
    """Convert to ssp form."""
    class_dict = copy.deepcopy(self.__dict__)
    del class_dict['description']
    new_stat_list = []
    for statement in as_list(self.statements):
        new_stat_list.append(statement.as_ssp())
    if new_stat_list:
        class_dict['statements'] = new_stat_list
    return ossp.ImplementedRequirement(**class_dict)
from_comp_def(imp_req) classmethod ¤

Convert component form of imp req to generic.

Source code in trestle/core/generic_oscal.py
@classmethod
def from_comp_def(cls, imp_req: comp.ImplementedRequirement) -> GenericImplementedRequirement:
    """Convert component form of imp req to generic."""
    class_dict = copy.deepcopy(imp_req.__dict__)
    class_dict['control-id'] = class_dict.pop('control_id', None)
    return cls(**class_dict)
generate() staticmethod ¤

Generate instance of this class.

Source code in trestle/core/generic_oscal.py
@staticmethod
def generate() -> GenericImplementedRequirement:
    """Generate instance of this class."""
    uuid = str(uuid4())
    class_dict = {'uuid': uuid, 'control-id': const.REPLACE_ME, 'description': ''}
    return GenericImplementedRequirement(**class_dict)

GenericSetParameter (TrestleBaseModel) pydantic-model ¤

Generic SetParameter for SSP and DefinedComponent.

Source code in trestle/core/generic_oscal.py
class GenericSetParameter(TrestleBaseModel):
    """Generic SetParameter for SSP and DefinedComponent."""

    param_id: constr(
        regex=  # noqa E251
        r'^[_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-\.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$'  # noqa E501
    ) = Field(
        ...,
        alias='param-id',
        description=  # noqa E251
        "A human-oriented reference to a parameter within a control, who's catalog has been imported into the current implementation context.",  # noqa E501
        title='Parameter ID',
    )
    values: List[str] = Field(...)
    remarks: Optional[str] = None

    @staticmethod
    def from_defined_component(sp: comp.SetParameter):
        """Generate generic set parameter from comp_def version."""
        class_dict = {'param-id': sp.param_id, 'values': sp.values, 'remarks': sp.remarks}
        return GenericSetParameter(**class_dict)

    def to_ssp(self):
        """Convert to ssp format."""
        return (ossp.SetParameter(param_id=self.param_id, values=self.values, remarks=self.remarks))
Attributes¤
__class_vars__ special ¤
__custom_root_type__ special ¤
__doc__ special ¤
__exclude_fields__ special ¤
__fields__ special ¤
__include_fields__ special ¤
__post_root_validators__ special ¤
__pre_root_validators__ special ¤
__private_attributes__ special ¤
__schema_cache__ special ¤
__signature__ special ¤
__slots__: Tuple[str, ...] special ¤
__validators__ special ¤
param_id: ConstrainedStrValue pydantic-field required ¤

A human-oriented reference to a parameter within a control, who's catalog has been imported into the current implementation context.

remarks: str pydantic-field ¤
values: List[str] pydantic-field required ¤
Methods¤
from_defined_component(sp) staticmethod ¤

Generate generic set parameter from comp_def version.

Source code in trestle/core/generic_oscal.py
@staticmethod
def from_defined_component(sp: comp.SetParameter):
    """Generate generic set parameter from comp_def version."""
    class_dict = {'param-id': sp.param_id, 'values': sp.values, 'remarks': sp.remarks}
    return GenericSetParameter(**class_dict)
to_ssp(self) ¤

Convert to ssp format.

Source code in trestle/core/generic_oscal.py
def to_ssp(self):
    """Convert to ssp format."""
    return (ossp.SetParameter(param_id=self.param_id, values=self.values, remarks=self.remarks))

GenericStatement (TrestleBaseModel) pydantic-model ¤

Generic statement for SSP and DefinedComp.

Source code in trestle/core/generic_oscal.py
class GenericStatement(TrestleBaseModel):
    """Generic statement for SSP and DefinedComp."""

    statement_id: constr(
        regex=  # noqa E251
        r'^[_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-\.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$'  # noqa FS003 E501
    ) = Field(
        ...,
        alias='statement_id',
        description='A human-oriented identifier reference to a control statement.',
        title='Control Statement Reference',
    )
    uuid: constr(
        regex=r'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'  # noqa FS003 F722
    ) = Field(
        ...,
        description=  # noqa E251
        'A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference this control statement elsewhere in this or other OSCAL instances. The UUID of the control statement in the source OSCAL instance is sufficient to reference the data item locally or globally (e.g., in an imported OSCAL instance).',  # noqa E501
        title='Control Statement Reference Universally Unique Identifier',
    )
    # this is not in ssp statement
    description: str = Field(
        ...,
        description='A summary of how the containing control statement is implemented by the component or capability.',
        title='Statement Implementation Description',
    )
    props: Optional[List[common.Property]] = Field(None)
    links: Optional[List[common.Link]] = Field(None)
    responsible_roles: Optional[List[common.ResponsibleRole]] = Field(None, alias='responsible-roles')
    remarks: Optional[str] = None
    # ssp has following
    by_components: Optional[List[GenericByComponent]] = Field(None, alias='by-components')

    def as_ssp(self) -> ossp.Statement:
        """Represent in ssp form."""
        class_dict = copy.deepcopy(self.__dict__)
        class_dict.pop('description', None)
        by_comps = []
        for by_comp in as_list(self.by_components):
            new_by_comp = by_comp.as_ssp()
            by_comps.append(new_by_comp)
        return ossp.Statement(
            statement_id=self.statement_id,
            uuid=self.uuid,
            props=self.props,
            links=self.links,
            responsible_roles=self.responsible_roles,
            by_components=by_comps,
            remarks=self.remarks
        )
Attributes¤
__class_vars__ special ¤
__custom_root_type__ special ¤
__doc__ special ¤
__exclude_fields__ special ¤
__fields__ special ¤
__include_fields__ special ¤
__post_root_validators__ special ¤
__pre_root_validators__ special ¤
__private_attributes__ special ¤
__schema_cache__ special ¤
__signature__ special ¤
__slots__: Tuple[str, ...] special ¤
__validators__ special ¤
by_components: List[trestle.core.generic_oscal.GenericByComponent] pydantic-field ¤
description: str pydantic-field required ¤

A summary of how the containing control statement is implemented by the component or capability.

props: List[trestle.oscal.common.Property] pydantic-field ¤
remarks: str pydantic-field ¤
responsible_roles: List[trestle.oscal.common.ResponsibleRole] pydantic-field ¤
statement_id: ConstrainedStrValue pydantic-field required ¤

A human-oriented identifier reference to a control statement.

uuid: ConstrainedStrValue pydantic-field required ¤

A machine-oriented, globally unique identifier with cross-instance scope that can be used to reference this control statement elsewhere in this or other OSCAL instances. The UUID of the control statement in the source OSCAL instance is sufficient to reference the data item locally or globally (e.g., in an imported OSCAL instance).

Methods¤
as_ssp(self) ¤

Represent in ssp form.

Source code in trestle/core/generic_oscal.py
def as_ssp(self) -> ossp.Statement:
    """Represent in ssp form."""
    class_dict = copy.deepcopy(self.__dict__)
    class_dict.pop('description', None)
    by_comps = []
    for by_comp in as_list(self.by_components):
        new_by_comp = by_comp.as_ssp()
        by_comps.append(new_by_comp)
    return ossp.Statement(
        statement_id=self.statement_id,
        uuid=self.uuid,
        props=self.props,
        links=self.links,
        responsible_roles=self.responsible_roles,
        by_components=by_comps,
        remarks=self.remarks
    )

handler: python