Skip to content

Commit

Permalink
chore(azure): Manage new errors in the Defender service (prowler-clou…
Browse files Browse the repository at this point in the history
  • Loading branch information
puchy22 authored Mar 13, 2024
1 parent 85f4595 commit ed60958
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions prowler/providers/azure/services/defender/defender_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from datetime import timedelta
from typing import Dict

from azure.core.exceptions import HttpResponseError
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceNotFoundError,
)
from azure.mgmt.security import SecurityCenter
from pydantic import BaseModel

Expand Down Expand Up @@ -48,6 +52,11 @@ def __get_pricings__(self):
)
}
)
except ResourceNotFoundError as error:
if "Subscription Not Registered" in error.message:
logger.error(
f"Subscription name: {subscription_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: Subscription Not Registered - Please register to Microsoft.Security in order to view your security status"
)
except Exception as error:
logger.error(
f"Subscription name: {subscription_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
Expand All @@ -72,10 +81,14 @@ def __get_auto_provisioning_settings__(self):
)
}
)
except ClientAuthenticationError as error:
if "Subscription Not Registered" in error.message:
logger.error(
f"Subscription name: {subscription_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: Subscription Not Registered - Please register to Microsoft.Security in order to view your security status"
)
except Exception as error:
logger.error(f"Subscription name: {subscription_name}")
logger.error(
f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
f"Subscription name: {subscription_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
return auto_provisioning

Expand Down Expand Up @@ -122,6 +135,11 @@ def __get_settings__(self):
)
}
)
except ClientAuthenticationError as error:
if "Subscription Not Registered" in error.message:
logger.error(
f"Subscription name: {subscription_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: Subscription Not Registered - Please register to Microsoft.Security in order to view your security status"
)
except Exception as error:
logger.error(
f"Subscription name: {subscription_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
Expand Down

0 comments on commit ed60958

Please sign in to comment.