From bc80edd5861d780cdcb73f1e97c4117b9128e745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Mart=C3=ADn?= Date: Fri, 10 May 2024 13:28:27 +0200 Subject: [PATCH] chore(deps): remove mrestazure deprecated (#3974) --- poetry.lock | 35 +------------------ .../providers/azure/lib/regions/regions.py | 32 +++++++---------- pyproject.toml | 1 - .../azure/lib/regions/regions_test.py | 29 +++++++-------- 4 files changed, 26 insertions(+), 71 deletions(-) diff --git a/poetry.lock b/poetry.lock index 90352cf036..355c986806 100644 --- a/poetry.lock +++ b/poetry.lock @@ -11,23 +11,6 @@ files = [ {file = "about_time-4.2.1-py3-none-any.whl", hash = "sha256:8bbf4c75fe13cbd3d72f49a03b02c5c7dca32169b6d49117c257e7eb3eaee341"}, ] -[[package]] -name = "adal" -version = "1.2.7" -description = "Note: This library is already replaced by MSAL Python, available here: https://pypi.org/project/msal/ .ADAL Python remains available here as a legacy. The ADAL for Python library makes it easy for python application to authenticate to Azure Active Directory (AAD) in order to access AAD protected web resources." -optional = false -python-versions = "*" -files = [ - {file = "adal-1.2.7-py2.py3-none-any.whl", hash = "sha256:2a7451ed7441ddbc57703042204a3e30ef747478eea022c70f789fc7f084bc3d"}, - {file = "adal-1.2.7.tar.gz", hash = "sha256:d74f45b81317454d96e982fd1c50e6fb5c99ac2223728aea8764433a39f566f1"}, -] - -[package.dependencies] -cryptography = ">=1.1.0" -PyJWT = ">=1.0.0,<3" -python-dateutil = ">=2.1.0,<3" -requests = ">=2.0.0,<3" - [[package]] name = "aiohttp" version = "3.9.5" @@ -2707,22 +2690,6 @@ requests-oauthlib = ">=0.5.0" [package.extras] async = ["aiodns", "aiohttp (>=3.0)"] -[[package]] -name = "msrestazure" -version = "0.6.4" -description = "AutoRest swagger generator Python client runtime. Azure-specific module." -optional = false -python-versions = "*" -files = [ - {file = "msrestazure-0.6.4-py2.py3-none-any.whl", hash = "sha256:3de50f56147ef529b31e099a982496690468ecef33f0544cb0fa0cfe1e1de5b9"}, - {file = "msrestazure-0.6.4.tar.gz", hash = "sha256:a06f0dabc9a6f5efe3b6add4bd8fb623aeadacf816b7a35b0f89107e0544d189"}, -] - -[package.dependencies] -adal = ">=0.6.0,<2.0.0" -msrest = ">=0.6.0,<2.0.0" -six = "*" - [[package]] name = "multidict" version = "6.0.5" @@ -4922,4 +4889,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.13" -content-hash = "b3660c0666eb4d7103df5a11f716b3d6a6f479a0d16d33eb0c48118697981e5f" +content-hash = "3f20034be7c0ff931186fb60dbeff3986811a8fa0a014c713531e6016126c64e" diff --git a/prowler/providers/azure/lib/regions/regions.py b/prowler/providers/azure/lib/regions/regions.py index a9d29d7eca..4c75fcde79 100644 --- a/prowler/providers/azure/lib/regions/regions.py +++ b/prowler/providers/azure/lib/regions/regions.py @@ -1,38 +1,32 @@ from azure.identity import AzureAuthorityHosts -from msrestazure.azure_cloud import ( - AZURE_CHINA_CLOUD, - AZURE_GERMAN_CLOUD, - AZURE_US_GOV_CLOUD, -) + +AZURE_CHINA_CLOUD = "https://management.chinacloudapi.cn" +AZURE_US_GOV_CLOUD = "https://management.usgovcloudapi.net" +AZURE_GERMAN_CLOUD = "https://management.microsoftazure.de" +AZURE_GENERIC_CLOUD = "https://management.azure.com" def get_regions_config(region): allowed_regions = { "AzureCloud": { "authority": None, - "base_url": "https://management.azure.com", - "credential_scopes": ["https://management.azure.com/.default"], + "base_url": AZURE_GENERIC_CLOUD, + "credential_scopes": [AZURE_GENERIC_CLOUD + "/.default"], }, "AzureChinaCloud": { "authority": AzureAuthorityHosts.AZURE_CHINA, - "base_url": AZURE_CHINA_CLOUD.endpoints.resource_manager, - "credential_scopes": [ - AZURE_CHINA_CLOUD.endpoints.resource_manager + "/.default" - ], + "base_url": AZURE_CHINA_CLOUD, + "credential_scopes": [AZURE_CHINA_CLOUD + "/.default"], }, "AzureUSGovernment": { "authority": AzureAuthorityHosts.AZURE_GOVERNMENT, - "base_url": AZURE_US_GOV_CLOUD.endpoints.resource_manager, - "credential_scopes": [ - AZURE_US_GOV_CLOUD.endpoints.resource_manager + "/.default" - ], + "base_url": AZURE_US_GOV_CLOUD, + "credential_scopes": [AZURE_US_GOV_CLOUD + "/.default"], }, "AzureGermanCloud": { "authority": AzureAuthorityHosts.AZURE_GERMANY, - "base_url": AZURE_GERMAN_CLOUD.endpoints.resource_manager, - "credential_scopes": [ - AZURE_GERMAN_CLOUD.endpoints.resource_manager + "/.default" - ], + "base_url": AZURE_GERMAN_CLOUD, + "credential_scopes": [AZURE_GERMAN_CLOUD + "/.default"], }, } return allowed_regions[region] diff --git a/pyproject.toml b/pyproject.toml index 689a2a851f..adc0e0343e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,6 @@ jsonschema = "4.22.0" kubernetes = "29.0.0" microsoft-kiota-abstractions = "1.3.2" msgraph-sdk = "1.3.0" -msrestazure = "0.6.4" numpy = "1.26.4" pandas = "2.2.2" py-ocsf-models = "0.1.0" diff --git a/tests/providers/azure/lib/regions/regions_test.py b/tests/providers/azure/lib/regions/regions_test.py index acf9d2b1f9..8e237547fd 100644 --- a/tests/providers/azure/lib/regions/regions_test.py +++ b/tests/providers/azure/lib/regions/regions_test.py @@ -1,12 +1,13 @@ from azure.identity import AzureAuthorityHosts -from msrestazure.azure_cloud import ( + +from prowler.providers.azure.lib.regions.regions import ( AZURE_CHINA_CLOUD, + AZURE_GENERIC_CLOUD, AZURE_GERMAN_CLOUD, AZURE_US_GOV_CLOUD, + get_regions_config, ) -from prowler.providers.azure.lib.regions.regions import get_regions_config - class Test_azure_regions: def test_get_regions_config(self): @@ -19,29 +20,23 @@ class Test_azure_regions: expected_output = { "AzureCloud": { "authority": None, - "base_url": "https://management.azure.com", - "credential_scopes": ["https://management.azure.com/.default"], + "base_url": AZURE_GENERIC_CLOUD, + "credential_scopes": [AZURE_GENERIC_CLOUD + "/.default"], }, "AzureChinaCloud": { "authority": AzureAuthorityHosts.AZURE_CHINA, - "base_url": AZURE_CHINA_CLOUD.endpoints.resource_manager, - "credential_scopes": [ - AZURE_CHINA_CLOUD.endpoints.resource_manager + "/.default" - ], + "base_url": AZURE_CHINA_CLOUD, + "credential_scopes": [AZURE_CHINA_CLOUD + "/.default"], }, "AzureUSGovernment": { "authority": AzureAuthorityHosts.AZURE_GOVERNMENT, - "base_url": AZURE_US_GOV_CLOUD.endpoints.resource_manager, - "credential_scopes": [ - AZURE_US_GOV_CLOUD.endpoints.resource_manager + "/.default" - ], + "base_url": AZURE_US_GOV_CLOUD, + "credential_scopes": [AZURE_US_GOV_CLOUD + "/.default"], }, "AzureGermanCloud": { "authority": AzureAuthorityHosts.AZURE_GERMANY, - "base_url": AZURE_GERMAN_CLOUD.endpoints.resource_manager, - "credential_scopes": [ - AZURE_GERMAN_CLOUD.endpoints.resource_manager + "/.default" - ], + "base_url": AZURE_GERMAN_CLOUD, + "credential_scopes": [AZURE_GERMAN_CLOUD + "/.default"], }, }