mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
fix(iam): Handle NoSuchEntityException when calling list_attached_role_policies (#2571)
This commit is contained in:
@@ -363,17 +363,23 @@ class IAM:
|
|||||||
logger.info("IAM - List Attached User Policies...")
|
logger.info("IAM - List Attached User Policies...")
|
||||||
try:
|
try:
|
||||||
for role in self.roles:
|
for role in self.roles:
|
||||||
attached_role_policies = []
|
try:
|
||||||
list_attached_role_policies_paginator = self.client.get_paginator(
|
attached_role_policies = []
|
||||||
"list_attached_role_policies"
|
list_attached_role_policies_paginator = self.client.get_paginator(
|
||||||
)
|
"list_attached_role_policies"
|
||||||
for page in list_attached_role_policies_paginator.paginate(
|
)
|
||||||
RoleName=role.name
|
for page in list_attached_role_policies_paginator.paginate(
|
||||||
):
|
RoleName=role.name
|
||||||
for policy in page["AttachedPolicies"]:
|
):
|
||||||
attached_role_policies.append(policy)
|
for policy in page["AttachedPolicies"]:
|
||||||
|
attached_role_policies.append(policy)
|
||||||
|
|
||||||
role.attached_policies = attached_role_policies
|
role.attached_policies = attached_role_policies
|
||||||
|
except ClientError as error:
|
||||||
|
if error.response["Error"]["Code"] == "NoSuchEntityException":
|
||||||
|
logger.warning(
|
||||||
|
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||||
|
)
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|||||||
Reference in New Issue
Block a user