Skip to content

Commit

Permalink
feat: add findings
Browse files Browse the repository at this point in the history
Signed-off-by: Takumi Yanagawa <[email protected]>
  • Loading branch information
yana1205 committed Oct 30, 2024
1 parent 1f92380 commit ea97fb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion c2p/framework/c2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def _get_result(self, pvp_result: PVPResult) -> Result:
observations=self._get_observations(pvp_result),
reviewed_controls=oscal_utils.reviewed_controls(self._component_root.component_definition),
local_definitions=pvp_result.local_definitions,
findings=pvp_result.findings,
)
if pvp_result.links != None:
result.links = list(map(lambda x: Link(href=x.href, text=x.description), pvp_result.links))
Expand Down Expand Up @@ -201,7 +202,7 @@ def _get_observations(self, pvp_result: PVPResult) -> List[Observation]:
if observation.props != None:
props = props + observation.props
o = Observation(
uuid=oscal_utils.uuid(),
uuid=observation.uuid if observation.uuid else oscal_utils.uuid(),
title=observation.title,
description=observation.title,
methods=observation.methods,
Expand Down
8 changes: 8 additions & 0 deletions c2p/framework/models/pvp_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from trestle.oscal.assessment_results import LocalDefinitions1

from c2p.common.c2p_base_model import C2PBaseModel
from trestle.oscal.assessment_results import LocalDefinitions1
from trestle.oscal.common import Finding


class ResultEnum(str, Enum):
Expand Down Expand Up @@ -95,6 +97,7 @@ class ObservationByCheck(C2PBaseModel):
Describes an individual observation based on each Check_Id defined in Component Definition.
"""

uuid: Optional[str] = Field(None)
title: Optional[str] = Field(
None,
description='The title for this observation for the check item. If not given, check id is used.',
Expand Down Expand Up @@ -124,6 +127,11 @@ class ObservationByCheck(C2PBaseModel):

class PVPResult(C2PBaseModel):
observations_by_check: Optional[List[ObservationByCheck]] = Field(None)
findings: Optional[List[Finding]] = Field(
None,
description='Equivalent to the "findings" defined in the OSCAL Assessment Results.',
title='Describes an individual finding',
)
local_definitions: Optional[LocalDefinitions1] = Field(
None,
description='Equivalent to the "local-definitions" defined in the OSCAL Assessment Results.',
Expand Down

0 comments on commit ea97fb8

Please sign in to comment.