Skip to content

Commit

Permalink
fix(iam-gcp): add getters in iam_service for gcp (#5001)
Browse files Browse the repository at this point in the history
Co-authored-by: Pedro Martín <pedromarting3@gmail.com>
  • Loading branch information
prowler-bot and pedrooot authored Sep 11, 2024
1 parent 5c36820 commit feae73a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions prowler/providers/gcp/services/iam/iam_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def __get_service_accounts__(self):
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,
)
)
Expand Down Expand Up @@ -65,7 +65,7 @@ def __get_service_accounts_keys__(self):
)
response = request.execute()

for key in response["keys"]:
for key in response.get("keys", []):
sa.keys.append(
Key(
name=key["name"].split("/")[-1],
Expand Down Expand Up @@ -149,7 +149,7 @@ def __get_contacts__(self):
.contacts()
.list(parent="organizations/" + org.id)
).execute()
if len(response["contacts"]) > 0:
if len(response.get("contacts", [])) > 0:
contacts = True

self.organizations.append(
Expand Down

0 comments on commit feae73a

Please sign in to comment.