fix(iam-gcp): add getters in iam_service for gcp (#5001)

Co-authored-by: Pedro Martín <pedromarting3@gmail.com>
This commit is contained in:
Prowler Bot
2024-09-11 17:33:37 +02:00
committed by GitHub
parent 5c36820149
commit feae73a9d3
@@ -29,12 +29,12 @@ class IAM(GCPService):
while request is not None:
response = request.execute()
for account in response["accounts"]:
for account in response.get("accounts", []):
self.service_accounts.append(
ServiceAccount(
name=account["name"],
email=account["email"],
display_name=account.get("displayName", ""),
display_name=account["displayName"],
project_id=project_id,
)
)
@@ -65,7 +65,7 @@ class IAM(GCPService):
)
response = request.execute()
for key in response["keys"]:
for key in response.get("keys", []):
sa.keys.append(
Key(
name=key["name"].split("/")[-1],
@@ -149,7 +149,7 @@ class EssentialContacts(GCPService):
.contacts()
.list(parent="organizations/" + org.id)
).execute()
if len(response["contacts"]) > 0:
if len(response.get("contacts", [])) > 0:
contacts = True
self.organizations.append(