mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 04:51:51 +00:00
fix(api): gcp project id validation for legacy projects (#10078)
This commit is contained in:
committed by
GitHub
parent
fec86754d8
commit
338d514197
@@ -29,6 +29,14 @@ All notable changes to the **Prowler API** are documented in this file.
|
||||
|
||||
---
|
||||
|
||||
## [1.19.3] (Prowler UNRELEASED)
|
||||
|
||||
### 🐞 Fixed
|
||||
|
||||
- GCP provider UID validation regex to allow domain prefixes [(#10078)](https://github.com/prowler-cloud/prowler/pull/10078)
|
||||
|
||||
---
|
||||
|
||||
## [1.19.2] (Prowler v5.18.2)
|
||||
|
||||
### 🐞 Fixed
|
||||
|
||||
@@ -327,10 +327,13 @@ class Provider(RowLevelSecurityProtectedModel):
|
||||
|
||||
@staticmethod
|
||||
def validate_gcp_uid(value):
|
||||
if not re.match(r"^[a-z][a-z0-9-]{5,29}$", value):
|
||||
# Standard format: 6-30 chars, starts with letter, lowercase + digits + hyphens
|
||||
# Legacy App Engine format: domain.com:project-id
|
||||
if not re.match(r"^([a-z][a-z0-9.-]*:)?[a-z][a-z0-9-]{5,29}$", value):
|
||||
raise ModelValidationError(
|
||||
detail="GCP provider ID must be 6 to 30 characters, start with a letter, and contain only lowercase "
|
||||
"letters, numbers, and hyphens.",
|
||||
detail="GCP provider ID must be a valid project ID: 6 to 30 characters, start with a letter, "
|
||||
"and contain only lowercase letters, numbers, and hyphens. "
|
||||
"Legacy App Engine project IDs with a domain prefix (e.g., example.com:my-project) are also accepted.",
|
||||
code="gcp-uid",
|
||||
pointer="/data/attributes/uid",
|
||||
)
|
||||
|
||||
@@ -1079,6 +1079,11 @@ class TestProviderViewSet:
|
||||
[
|
||||
{"provider": "aws", "uid": "111111111111", "alias": "test"},
|
||||
{"provider": "gcp", "uid": "a12322-test54321", "alias": "test"},
|
||||
{
|
||||
"provider": "gcp",
|
||||
"uid": "example.com:my-project-123456",
|
||||
"alias": "legacy-gcp",
|
||||
},
|
||||
{
|
||||
"provider": "kubernetes",
|
||||
"uid": "kubernetes-test-123456789",
|
||||
@@ -1203,6 +1208,11 @@ class TestProviderViewSet:
|
||||
[
|
||||
{"provider": "aws", "uid": "111111111111", "alias": "test"},
|
||||
{"provider": "gcp", "uid": "a12322-test54321", "alias": "test"},
|
||||
{
|
||||
"provider": "gcp",
|
||||
"uid": "example.com:my-project-123456",
|
||||
"alias": "legacy-gcp",
|
||||
},
|
||||
{
|
||||
"provider": "kubernetes",
|
||||
"uid": "kubernetes-test-123456789",
|
||||
|
||||
Reference in New Issue
Block a user