From 6b3b6ca45e08aece5b88452f27fbca7a2b9e481c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20De=20la=20Torre=20Vico?= Date: Wed, 15 Jan 2025 17:45:23 +0100 Subject: [PATCH] feat(appinsights): extract App Insights resource metadata in automated way (#6540) --- prowler/lib/check/models.py | 8 ++++++-- .../appinsights_ensure_is_configured.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/prowler/lib/check/models.py b/prowler/lib/check/models.py index 0b1a6ba2fd..b7a6ac4e89 100644 --- a/prowler/lib/check/models.py +++ b/prowler/lib/check/models.py @@ -416,12 +416,16 @@ class Check_Report: Args: metadata: The metadata of the check. resource: Basic information about the resource. Defaults to None. - Only accepted BaseModels (dict attribute), custom models (to_dict attribute) or objects with __dict__. + Only accepted dict, list, BaseModels (dict attribute), custom models (with to_dict attribute) or objects with __dict__. """ self.status = "" self.check_metadata = CheckMetadata.parse_raw(metadata) - if hasattr(resource, "dict"): + if isinstance(resource, dict): + self.resource_metadata = resource + elif isinstance(resource, list): + self.resource_metadata = dict(enumerate(resource)) + elif hasattr(resource, "dict"): self.resource_metadata = resource.dict() elif hasattr(resource, "to_dict"): self.resource_metadata = resource.to_dict() diff --git a/prowler/providers/azure/services/appinsights/appinsights_ensure_is_configured/appinsights_ensure_is_configured.py b/prowler/providers/azure/services/appinsights/appinsights_ensure_is_configured/appinsights_ensure_is_configured.py index b14f1726c0..04e72f794f 100644 --- a/prowler/providers/azure/services/appinsights/appinsights_ensure_is_configured/appinsights_ensure_is_configured.py +++ b/prowler/providers/azure/services/appinsights/appinsights_ensure_is_configured/appinsights_ensure_is_configured.py @@ -9,7 +9,7 @@ class appinsights_ensure_is_configured(Check): findings = [] for subscription_name, components in appinsights_client.components.items(): - report = Check_Report_Azure(self.metadata()) + report = Check_Report_Azure(metadata=self.metadata(), resource_metadata={}) report.status = "PASS" report.subscription = subscription_name report.resource_name = "AppInsights"