mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 04:21:52 +00:00
fix(gcp): check check_name has no resource_name error (#9178)
Co-authored-by: Hugo Pereira Brito <101209179+HugoPBrito@users.noreply.github.com> Co-authored-by: Daniel Barranquero <danielbo2001@gmail.com>
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
All notable changes to the **Prowler SDK** are documented in this file.
|
||||
|
||||
## [v5.13.2] (Prowler UNRELEASED)
|
||||
|
||||
### Fixed
|
||||
- Check `check_name` has no `resource_name` error for GCP provider [(#9169)](https://github.com/prowler-cloud/prowler/pull/9169)
|
||||
|
||||
## [v5.13.1] (Prowler v5.13.1)
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -588,8 +588,17 @@ class Check_Report_GCP(Check_Report):
|
||||
or getattr(resource, "name", None)
|
||||
or ""
|
||||
)
|
||||
|
||||
# Prefer the explicit resource_name argument, otherwise look for a name attribute on the resource
|
||||
resource_name_candidate = resource_name or getattr(resource, "name", None)
|
||||
if not resource_name_candidate and isinstance(resource, dict):
|
||||
# Some callers pass a dict, so fall back to the dict entry if available
|
||||
resource_name_candidate = resource.get("name")
|
||||
if isinstance(resource_name_candidate, str):
|
||||
# Trim whitespace so empty strings collapse to the default
|
||||
resource_name_candidate = resource_name_candidate.strip()
|
||||
self.resource_name = (
|
||||
resource_name or getattr(resource, "name", "") or "GCP Project"
|
||||
str(resource_name_candidate) if resource_name_candidate else "GCP Project"
|
||||
)
|
||||
self.project_id = project_id or getattr(resource, "project_id", "")
|
||||
self.location = (
|
||||
|
||||
Reference in New Issue
Block a user