prowler-cloud / prowler

Prowler is an Open Source Security tool for AWS, Azure, GCP and Kubernetes to do security assessments, audits, incident response, compliance, continuous monitoring, hardening and forensics readiness. Includes CIS, NIST 800, NIST CSF, CISA, FedRAMP, PCI-DSS, GDPR, HIPAA, FFIEC, SOC2, GXP, Well-Architected Security, ENS and more
https://prowler.com
Apache License 2.0
9.99k stars 1.47k forks source link

fix(gcp): Not all gcp projects have name #4387

Closed jacky9813 closed 1 week ago

jacky9813 commented 1 week ago

Context

When I scanning GCP with Prowler, the following message appears:

2024-07-05 15:57:51,692 [File: gcp_provider.py:267]     [Module: gcp_provider]   CRITICAL: KeyError[231]: 'name'

2024-07-05 15:57:51,694 [File: gcp_provider.py:80]  [Module: gcp_provider]   CRITICAL: No Input Project IDs can be accessed via Google Credentials.

Turns out the project from the response of resource manager API may not contain name field.

Description

This will fallback to project ID if project name is not provided.

I have retested the modified code again and works.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.61%. Comparing base (bf83f38) to head (742f316). Report is 3 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #4387 +/- ## ========================================== - Coverage 87.62% 87.61% -0.01% ========================================== Files 851 851 Lines 26600 26600 ========================================== - Hits 23307 23305 -2 - Misses 3293 3295 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.