From 4cca0dc6d893019355e9796716b6f91ea49a8d1a Mon Sep 17 00:00:00 2001 From: pedrooot Date: Fri, 13 Dec 2024 14:20:51 +0100 Subject: [PATCH] feat(gcp): rename exceptions --- prowler/providers/gcp/exceptions/exceptions.py | 4 ++-- prowler/providers/gcp/gcp_provider.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/prowler/providers/gcp/exceptions/exceptions.py b/prowler/providers/gcp/exceptions/exceptions.py index ad76838e42a..b59bf9eecc5 100644 --- a/prowler/providers/gcp/exceptions/exceptions.py +++ b/prowler/providers/gcp/exceptions/exceptions.py @@ -30,7 +30,7 @@ class GCPBaseException(ProwlerException): "message": "Error testing connection to GCP", "remediation": "Check the connection and ensure it is properly set up.", }, - (3006, "GCPLoadCredentialsFromDictError"): { + (3006, "GCPLoadCredentialsFromADCError"): { "message": "Error loading credentials from dictionary", "remediation": "Check the credentials and ensure they are properly set up. client_id, client_secret and refresh_token are required.", }, @@ -115,7 +115,7 @@ def __init__(self, file=None, original_exception=None, message=None): ) -class GCPLoadCredentialsFromDictError(GCPCredentialsError): +class GCPLoadCredentialsFromADCError(GCPCredentialsError): def __init__(self, file=None, original_exception=None, message=None): super().__init__( 3006, file=file, original_exception=original_exception, message=message diff --git a/prowler/providers/gcp/gcp_provider.py b/prowler/providers/gcp/gcp_provider.py index e5dc4383447..eaa4fccad8a 100644 --- a/prowler/providers/gcp/gcp_provider.py +++ b/prowler/providers/gcp/gcp_provider.py @@ -25,7 +25,7 @@ GCPGetProjectError, GCPHTTPError, GCPInvalidProviderIdError, - GCPLoadCredentialsFromDictError, + GCPLoadCredentialsFromADCError, GCPLoadCredentialsFromServiceAccountKeyError, GCPNoAccesibleProjectsError, GCPSetUpSessionError, @@ -112,7 +112,7 @@ def __init__( Raises: GCPNoAccesibleProjectsError if no project IDs can be accessed via Google Credentials GCPSetUpSessionError if an error occurs during the setup session - GCPLoadCredentialsFromDictError if an error occurs during the loading credentials from dict + GCPLoadCredentialsFromADCError if an error occurs during the loading credentials from dict GCPGetProjectError if an error occurs during the get project Returns: @@ -345,7 +345,7 @@ def setup_session( Credentials object and default project ID Raises: - GCPLoadCredentialsFromDictError if an error occurs during the loading credentials from dict + GCPLoadCredentialsFromADCError if an error occurs during the loading credentials from dict GCPLoadCredentialsFromServiceAccountKeyError if an error occurs during the loading credentials from the service account key GCPSetUpSessionError if an error occurs during the setup session @@ -370,7 +370,7 @@ def setup_session( logger.critical( f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" ) - raise GCPLoadCredentialsFromDictError( + raise GCPLoadCredentialsFromADCError( file=__file__, original_exception=error ) @@ -454,7 +454,7 @@ def test_connection( Connection object with is_connected set to True if the connection is successful, or error set to the exception if the connection fails Raises: - GCPLoadCredentialsFromDictError if an error occurs during the loading credentials from dict + GCPLoadCredentialsFromADCError if an error occurs during the loading credentials from dict GCPLoadCredentialsFromServiceAccountKeyError if an error occurs during the loading credentials from dict GCPSetUpSessionError if an error occurs during the setup session GCPCloudResourceManagerAPINotUsedError if the Cloud Resource Manager API has not been used before or it is disabled