This commit is contained in:
Andoni A.
2025-05-28 08:19:29 +02:00
parent be1e3e942b
commit 98ecded7e7
2 changed files with 39 additions and 0 deletions
+28
View File
@@ -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:
"""
+11
View File
@@ -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