From 8503c6a64d742cf2f04d0e3e7e8f94b0cdcf025c Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 4 May 2023 11:06:24 +0200 Subject: [PATCH] fix(client_error): Handle errors (#2308) --- .../aws/services/cloudformation/cloudformation_service.py | 2 +- prowler/providers/aws/services/dynamodb/dynamodb_service.py | 2 +- prowler/providers/aws/services/iam/iam_service.py | 2 +- prowler/providers/aws/services/rds/rds_service.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/prowler/providers/aws/services/cloudformation/cloudformation_service.py b/prowler/providers/aws/services/cloudformation/cloudformation_service.py index 5561adef..b884e480 100644 --- a/prowler/providers/aws/services/cloudformation/cloudformation_service.py +++ b/prowler/providers/aws/services/cloudformation/cloudformation_service.py @@ -81,7 +81,7 @@ class CloudFormation: stack.is_nested_stack = True if stack.root_nested_stack != "" else False except ClientError as error: - if error.response["Error"]["Code"] != "ValidationError": + if error.response["Error"]["Code"] == "ValidationError": logger.warning( f"{stack.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" ) diff --git a/prowler/providers/aws/services/dynamodb/dynamodb_service.py b/prowler/providers/aws/services/dynamodb/dynamodb_service.py index e89fdc0f..5f3074fd 100644 --- a/prowler/providers/aws/services/dynamodb/dynamodb_service.py +++ b/prowler/providers/aws/services/dynamodb/dynamodb_service.py @@ -177,7 +177,7 @@ class DAX: cluster.tags = response except ClientError as error: - if error.response["Error"]["Code"] != "InvalidARNFault": + if error.response["Error"]["Code"] == "InvalidARNFault": logger.warning( f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" ) diff --git a/prowler/providers/aws/services/iam/iam_service.py b/prowler/providers/aws/services/iam/iam_service.py index 426a4b7b..7da3ba22 100644 --- a/prowler/providers/aws/services/iam/iam_service.py +++ b/prowler/providers/aws/services/iam/iam_service.py @@ -119,7 +119,7 @@ class IAM: credential_list = list(csv_reader) except ClientError as error: - if error.response["Error"]["Code"] != "LimitExceededException": + if error.response["Error"]["Code"] == "LimitExceededException": logger.warning( f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" ) diff --git a/prowler/providers/aws/services/rds/rds_service.py b/prowler/providers/aws/services/rds/rds_service.py index 9b872d6e..cc191f57 100644 --- a/prowler/providers/aws/services/rds/rds_service.py +++ b/prowler/providers/aws/services/rds/rds_service.py @@ -150,7 +150,7 @@ class RDS: if "all" in att["AttributeValues"]: snapshot.public = True except ClientError as error: - if error.response["Error"]["Code"] != "DBSnapshotNotFound": + if error.response["Error"]["Code"] == "DBSnapshotNotFound": logger.warning( f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" )