Skip to content

Commit d18c5a8

Browse files
rchotacodeRonan Chotadanibarranqueroo
authored
fix(oci): fix identity clients (#10520)
Co-authored-by: Ronan Chota <ronan.chota@saic.com> Co-authored-by: Daniel Barranquero <danielbo2001@gmail.com>
1 parent ab00c2d commit d18c5a8

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

prowler/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ All notable changes to the **Prowler SDK** are documented in this file.
4343
- Oracle Cloud patch for filestorage, blockstorage, kms, and compute services in OCI to allow for region scanning outside home [(#10455)](https://github.com/prowler-cloud/prowler/pull/10472)
4444
- Oracle cloud provider now supports multi-region filtering [(#10435)](https://github.com/prowler-cloud/prowler/pull/10473)
4545
- `prowler image --registry` failing with `ImageNoImagesProvidedError` due to registry arguments not being forwarded to `ImageProvider` in `init_global_provider` [(#10457)](https://github.com/prowler-cloud/prowler/issues/10457)
46+
- Oracle Cloud multi-region support for identity client configuration in blockstorage, identity, and filestorage services [(#10519)](https://github.com/prowler-cloud/prowler/pull/10520)
4647

4748
---
4849

prowler/providers/oraclecloud/services/blockstorage/blockstorage_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def __list_boot_volumes__(self, regional_client):
111111
try:
112112
# Get availability domains for this compartment
113113
identity_client = self._create_oci_client(
114-
oci.identity.IdentityClient
114+
oci.identity.IdentityClient,
115+
config_overrides={"region": regional_client.region},
115116
)
116117
availability_domains = identity_client.list_availability_domains(
117118
compartment_id=compartment.id

prowler/providers/oraclecloud/services/filestorage/filestorage_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def __list_file_systems__(self, regional_client):
3939
try:
4040
# Get availability domains for this compartment
4141
identity_client = self._create_oci_client(
42-
oci.identity.IdentityClient
42+
oci.identity.IdentityClient,
43+
config_overrides={"region": regional_client.region},
4344
)
4445
availability_domains = identity_client.list_availability_domains(
4546
compartment_id=compartment.id

prowler/providers/oraclecloud/services/identity/identity_service.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, provider):
3535
self.__threading_call__(self.__list_dynamic_groups__)
3636
self.__threading_call__(self.__list_domains__)
3737
self.__threading_call__(self.__list_domain_password_policies__)
38-
self.__get_password_policy__()
38+
self.__threading_call__(self.__get_password_policy__)
3939
self.__threading_call__(self.__search_root_compartment_resources__)
4040
self.__threading_call__(self.__search_active_non_root_compartments__)
4141

@@ -49,10 +49,9 @@ def __get_client__(self, region):
4949
Returns:
5050
Identity client instance
5151
"""
52-
client_region = self.regional_clients.get(region)
53-
if client_region:
54-
return self._create_oci_client(oci.identity.IdentityClient)
55-
return None
52+
return self._create_oci_client(
53+
oci.identity.IdentityClient, config_overrides={"region": region}
54+
)
5655

5756
def __list_users__(self, regional_client):
5857
"""
@@ -66,7 +65,7 @@ def __list_users__(self, regional_client):
6665
if regional_client.region not in self.provider.identity.region:
6766
return
6867

69-
identity_client = self._create_oci_client(oci.identity.IdentityClient)
68+
identity_client = self.__get_client__(regional_client.region)
7069

7170
logger.info("Identity - Listing Users...")
7271

@@ -316,7 +315,7 @@ def __list_groups__(self, regional_client):
316315
if regional_client.region not in self.provider.identity.region:
317316
return
318317

319-
identity_client = self._create_oci_client(oci.identity.IdentityClient)
318+
identity_client = self.__get_client__(regional_client.region)
320319

321320
logger.info("Identity - Listing Groups...")
322321

@@ -359,7 +358,7 @@ def __list_policies__(self, regional_client):
359358
if regional_client.region not in self.provider.identity.region:
360359
return
361360

362-
identity_client = self._create_oci_client(oci.identity.IdentityClient)
361+
identity_client = self.__get_client__(regional_client.region)
363362

364363
logger.info("Identity - Listing Policies...")
365364

@@ -404,7 +403,7 @@ def __list_dynamic_groups__(self, regional_client):
404403
if regional_client.region not in self.provider.identity.region:
405404
return
406405

407-
identity_client = self._create_oci_client(oci.identity.IdentityClient)
406+
identity_client = self.__get_client__(regional_client.region)
408407

409408
logger.info("Identity - Listing Dynamic Groups...")
410409

@@ -452,7 +451,7 @@ def __list_domains__(self, regional_client):
452451
if regional_client.region not in self.provider.identity.region:
453452
return
454453

455-
identity_client = self._create_oci_client(oci.identity.IdentityClient)
454+
identity_client = self.__get_client__(regional_client.region)
456455

457456
logger.info("Identity - Listing Identity Domains...")
458457

@@ -549,10 +548,13 @@ def __list_domain_password_policies__(self, regional_client):
549548
f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
550549
)
551550

552-
def __get_password_policy__(self):
551+
def __get_password_policy__(self, regional_client):
553552
"""Get the password policy for the tenancy."""
554553
try:
555-
identity_client = self._create_oci_client(oci.identity.IdentityClient)
554+
if regional_client.region not in self.provider.identity.region:
555+
return
556+
557+
identity_client = self.__get_client__(regional_client.region)
556558

557559
logger.info("Identity - Getting Password Policy...")
558560

@@ -584,7 +586,8 @@ def __search_root_compartment_resources__(self, regional_client):
584586

585587
# Create search client using the helper method for proper authentication
586588
search_client = self._create_oci_client(
587-
oci.resource_search.ResourceSearchClient
589+
oci.resource_search.ResourceSearchClient,
590+
config_overrides={"region": regional_client.region},
588591
)
589592

590593
# Query to search for resources in root compartment
@@ -631,7 +634,8 @@ def __search_active_non_root_compartments__(self, regional_client):
631634

632635
# Create search client using the helper method for proper authentication
633636
search_client = self._create_oci_client(
634-
oci.resource_search.ResourceSearchClient
637+
oci.resource_search.ResourceSearchClient,
638+
config_overrides={"region": regional_client.region},
635639
)
636640

637641
# Query to search for active compartments in the tenancy (excluding root)

0 commit comments

Comments
 (0)