From 98ecded7e73b1a26d566cf24082d093e4a888b0e Mon Sep 17 00:00:00 2001 From: "Andoni A." <14891798+andoniaf@users.noreply.github.com> Date: Wed, 28 May 2025 08:19:29 +0200 Subject: [PATCH] wip --- prowler/lib/check/models.py | 28 ++++++++++++++++++++++++++++ prowler/lib/outputs/finding.py | 11 +++++++++++ 2 files changed, 39 insertions(+) diff --git a/prowler/lib/check/models.py b/prowler/lib/check/models.py index 875350c757..926f83d239 100644 --- a/prowler/lib/check/models.py +++ b/prowler/lib/check/models.py @@ -631,6 +631,34 @@ class CheckReportNHN(Check_Report): self.location = getattr(resource, "location", "kr1") +@dataclass +class CheckReportIaC(Check_Report): + """Contains the IaC Check's finding information.""" + + resource_name: str + resource_path: str + resource_line_range: str + + def __init__(self, iac_finding: Any) -> None: + """Initialize the IaC Check's finding information. + + Args: + iac_finding: The IaC finding. + """ + super().__init__() + self.metadata = CheckMetadata( + Provider="iac", + ServiceName=iac_finding.check_type, + CheckID=iac_finding.check_id, + CheckTitle=iac_finding.check_name, + CheckType=[], + # TODO: Map all the mandatory values + ) + self.resource_name = getattr(iac_finding, "resource", "") + self.resource_path = getattr(iac_finding, "file_path", "") + self.resource_line_range = getattr(iac_finding, "file_line_range", "") + + # Testing Pending def load_check_metadata(metadata_file: str) -> CheckMetadata: """ diff --git a/prowler/lib/outputs/finding.py b/prowler/lib/outputs/finding.py index ffa0a2f44e..06ab742aac 100644 --- a/prowler/lib/outputs/finding.py +++ b/prowler/lib/outputs/finding.py @@ -282,6 +282,17 @@ class Finding(BaseModel): output_data["resource_uid"] = check_output.resource_id output_data["region"] = check_output.location + elif provider.type == "iac": + output_data["auth_method"] = "local" # at least for now + output_data["resource_name"] = check_output.resource_name + output_data["resource_path"] = check_output.resource_path + output_data["resource_line_range"] = check_output.resource_line_range + # output_data["account_name"] = provider.identity.account_name + # output_data["account_uid"] = provider.identity.account_id + output_data["framework"] = ( + check_output.check_metadata.ServiceName + ) # TODO: can we get the framework from the check_output? + # check_output Unique ID # TODO: move this to a function # TODO: in Azure, GCP and K8s there are findings without resource_name