From b01eb3af9568c017d18611462e5ae7be2e0a8dde Mon Sep 17 00:00:00 2001 From: Nacho Rivera Date: Wed, 14 Jun 2023 12:15:33 +0200 Subject: [PATCH] fix(rds checks): test if key exists prior checking it (#2489) --- .../rds_instance_deletion_protection.py | 7 ++++++- .../rds/rds_instance_multi_az/rds_instance_multi_az.py | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/prowler/providers/aws/services/rds/rds_instance_deletion_protection/rds_instance_deletion_protection.py b/prowler/providers/aws/services/rds/rds_instance_deletion_protection/rds_instance_deletion_protection.py index a540efd8..6f8ed67c 100644 --- a/prowler/providers/aws/services/rds/rds_instance_deletion_protection/rds_instance_deletion_protection.py +++ b/prowler/providers/aws/services/rds/rds_instance_deletion_protection/rds_instance_deletion_protection.py @@ -13,7 +13,12 @@ class rds_instance_deletion_protection(Check): report.resource_tags = db_instance.tags # Check if is member of a cluster if db_instance.cluster_id: - if rds_client.db_clusters[db_instance.cluster_arn].deletion_protection: + if ( + db_instance.cluster_arn in rds_client.db_clusters + and rds_client.db_clusters[ + db_instance.cluster_arn + ].deletion_protection + ): report.status = "PASS" report.status_extended = f"RDS Instance {db_instance.id} deletion protection is enabled at cluster {db_instance.cluster_id} level." else: diff --git a/prowler/providers/aws/services/rds/rds_instance_multi_az/rds_instance_multi_az.py b/prowler/providers/aws/services/rds/rds_instance_multi_az/rds_instance_multi_az.py index fe2ff393..687c9b19 100644 --- a/prowler/providers/aws/services/rds/rds_instance_multi_az/rds_instance_multi_az.py +++ b/prowler/providers/aws/services/rds/rds_instance_multi_az/rds_instance_multi_az.py @@ -13,7 +13,10 @@ class rds_instance_multi_az(Check): report.resource_tags = db_instance.tags # Check if is member of a cluster if db_instance.cluster_id: - if rds_client.db_clusters[db_instance.cluster_arn].multi_az: + if ( + db_instance.cluster_arn in rds_client.db_clusters + and rds_client.db_clusters[db_instance.cluster_arn].multi_az + ): report.status = "PASS" report.status_extended = f"RDS Instance {db_instance.id} has multi-AZ enabled at cluster {db_instance.cluster_id} level." else: