From ffdb4d35d89bc6a82f4c516a8b7a4cc600d0dacc Mon Sep 17 00:00:00 2001 From: HugoPBrito Date: Thu, 23 Jan 2025 17:05:33 +0100 Subject: [PATCH] fix: NoneType object is not iterable --- ...watch_log_group_not_publicly_accessible.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/prowler/providers/aws/services/cloudwatch/cloudwatch_log_group_not_publicly_accessible/cloudwatch_log_group_not_publicly_accessible.py b/prowler/providers/aws/services/cloudwatch/cloudwatch_log_group_not_publicly_accessible/cloudwatch_log_group_not_publicly_accessible.py index 1f46d026ad2..b02424590d4 100644 --- a/prowler/providers/aws/services/cloudwatch/cloudwatch_log_group_not_publicly_accessible/cloudwatch_log_group_not_publicly_accessible.py +++ b/prowler/providers/aws/services/cloudwatch/cloudwatch_log_group_not_publicly_accessible/cloudwatch_log_group_not_publicly_accessible.py @@ -12,18 +12,21 @@ def execute(self): and logs_client.log_groups is not None ): for resource_policies in logs_client.resource_policies.values(): - for resource_policy in resource_policies: - if is_policy_public( - resource_policy.policy, logs_client.audited_account - ): - for statement in resource_policy.policy.get("Statement", []): - public_resources = statement.get("Resource", []) - if isinstance(public_resources, str): - public_resources = [public_resources] - for resource in public_resources: - for log_group in logs_client.log_groups.values(): - if log_group.arn in resource or resource == "*": - public_log_groups.append(log_group.arn) + if resource_policies is not None: + for resource_policy in resource_policies: + if is_policy_public( + resource_policy.policy, logs_client.audited_account + ): + for statement in resource_policy.policy.get( + "Statement", [] + ): + public_resources = statement.get("Resource", []) + if isinstance(public_resources, str): + public_resources = [public_resources] + for resource in public_resources: + for log_group in logs_client.log_groups.values(): + if log_group.arn in resource or resource == "*": + public_log_groups.append(log_group.arn) for log_group in logs_client.log_groups.values(): report = Check_Report_AWS(metadata=self.metadata(), resource=log_group) report.status = "PASS"