Skip to content

feat(gcp): add 6 new GCP checks for CloudSQL, SecretManager, and Cloud Functions#10967

Open
s1ns3nz0 wants to merge 4 commits intoprowler-cloud:masterfrom
s1ns3nz0:feat/gcp-checks-contribution
Open

feat(gcp): add 6 new GCP checks for CloudSQL, SecretManager, and Cloud Functions#10967
s1ns3nz0 wants to merge 4 commits intoprowler-cloud:masterfrom
s1ns3nz0:feat/gcp-checks-contribution

Conversation

@s1ns3nz0
Copy link
Copy Markdown

@s1ns3nz0 s1ns3nz0 commented May 2, 2026

Summary

  • 6 new GCP checks across 3 services (2 new services + 1 extended):
    • cloudfunction_function_inside_vpc — ensures Cloud Functions have a VPC connector attached
    • cloudfunction_function_not_publicly_accessible — detects allUsers/allAuthenticatedUsers IAM bindings on functions
    • cloudsql_instance_cmek_encryption_enabled — verifies CMEK (Customer-Managed Encryption Key) usage on Cloud SQL instances
    • cloudsql_instance_high_availability_enabled — checks availabilityType=REGIONAL for HA standby replica
    • secretmanager_secret_not_publicly_accessible — detects publicly accessible Secret Manager secrets
    • secretmanager_secret_rotation_enabled — verifies rotation period ≤ 90 days and not overdue
  • 2 new service layers: cloudfunction_service.py (Cloud Functions v2 API) and secretmanager_service.py (Secret Manager v1 API)
  • Extended cloudsql_service.py with availabilityType and diskEncryptionConfiguration fields
  • New compliance file: kisa_isms_p_2023_gcp.json — maps checks to KISA ISMS-P 2023 requirements (2.1.3, 2.6.1, 2.6.2, 2.6.4, 2.7.1, 2.9.2, 2.10.2, 2.12.1)
  • 26 test cases across 8 test files covering PASS/FAIL/edge cases (inactive functions, allAuthenticatedUsers, fractional durations, overdue rotation, missing fields)

Verification

  • No overlapping checks found in upstream (confirmed via PR search + codebase audit)
  • All metadata URLs verified working (404s and misleading links fixed)
  • Red-team review completed: 5 HIGH + 8 MEDIUM findings identified and fixed
  • CLI remediation commands verified syntactically correct
  • Terraform HCL verified valid and remediating

Changes

  • 43 files changed (26 new + 2 modified), +2,294 lines

Test plan

  • Run python -m pytest tests/providers/gcp/services/cloudfunction/ -v
  • Run python -m pytest tests/providers/gcp/services/secretmanager/ -v
  • Run python -m pytest tests/providers/gcp/services/cloudsql/cloudsql_instance_cmek_encryption_enabled/ -v
  • Run python -m pytest tests/providers/gcp/services/cloudsql/cloudsql_instance_high_availability_enabled/ -v
  • Verify kisa_isms_p_2023_gcp.json loads without errors in Prowler CLI
  • Run prowler gcp --check cloudfunction_function_inside_vpc against a live GCP project

s1ns3nz0 and others added 4 commits April 25, 2026 11:53
…ud Functions

Implements 6 new GCP security checks aligned with KISA ISMS-P 2023 requirements,
along with a new SecretManager service layer and Cloud Functions service layer.

New checks:
- cloudsql_instance_high_availability_enabled (ISMS-P 2.9.2, 2.10.2, 2.12.1)
- cloudsql_instance_cmek_encryption_enabled   (ISMS-P 2.6.4, 2.7.1, 2.10.2)
- secretmanager_secret_rotation_enabled       (ISMS-P 2.7.1, 2.10.2)
- secretmanager_secret_not_publicly_accessible (ISMS-P 2.6.2, 2.10.2)
- cloudfunction_function_not_publicly_accessible (ISMS-P 2.6.2)
- cloudfunction_function_inside_vpc           (ISMS-P 2.6.1)

Service changes:
- Add SecretManager GCP service (secrets list + IAM policy, thread-safe)
- Add Cloud Functions GCP service (v2 API, locations pagination, thread-safe IAM)
- Extend CloudSQL Instance model with high_availability and cmek_key_name fields
- Use instance.get("settings", {}) to guard against KeyError on error-state instances

Quality hardening (post Red-Team review):
- cloudfunctions: api_version="v2" for serviceConfig.vpcConnector field access
- cloudfunctions: per-location try/except so one region failure does not abort project scan
- secretmanager rotation: int(float(...)) for fractional-second Duration strings
- secretmanager rotation: explicit is not None check to handle 0-day rotation edge case
- secretmanager rotation: next_rotation_time staleness check (FAIL if overdue)
- secretmanager: Secret.location = "global" derived from resource model, not service region
- cloudfunction_function_inside_vpc: skip non-ACTIVE functions; surface ingress_settings advisory
- All threaded IAM calls use http=__get_AuthorizedHttp_client__() (httplib2 thread safety)
- All VALID_CATEGORIES values verified against prowler/lib/check/models.py frozenset

Compliance:
- Add prowler/compliance/gcp/kisa_isms_p_2023_gcp.json mapping all 6 checks
  to requirements 2.1.3, 2.6.1, 2.6.2, 2.6.4, 2.7.1, 2.9.2, 2.10.2, 2.12.1

Tests:
- 22 unit tests across all new checks and services
- gcp_fixtures.py sqladmin mock updated with availabilityType and diskEncryptionConfiguration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Set RelatedUrl to "" in all 6 check metadata files (field is deprecated)
- Set Remediation.Recommendation.Url to https://hub.prowler.com/check/<id>
  for all 6 checks (validator requires hub.prowler.com prefix)
- All 30 unit tests now pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove out-of-scope ingress advisory from VPC check PASS message (H1)
- Add state!=ACTIVE filter to not_publicly_accessible check for
  consistency with inside_vpc check (H2)
- Add allAuthenticatedUsers test cases for both cloudfunction and
  secretmanager service IAM checks (H3)
- Add inactive function skip tests for both cloudfunction checks (H4)
- Fix false PASS on datetime parse failure in rotation check by
  defaulting rotation_overdue=True on error (H5, fail-safe)
- Use .replace("Z","+00:00") for robust ISO timestamp parsing (M4)
- Fix error log messages to use location_id/project_id instead of
  always-global self.region (M1)
- Fix secretmanager_service error log to use project_id (M1)
- Change rotation check category from "encryption" to "secrets" (M6)
- Fix compliance Name to "KISA ISMS-P" (not "KISA ISMS") (M7)
- Fix AdditionalURL to Cloud Functions docs instead of Cloud Run (L1)
- Remove dead RelatedTo reference to non-existent check (L2)
- secretmanager_secret_not_publicly_accessible: replace 404 URL
  manage-access -> access-control (IAM roles for Secret Manager)
- cloudfunction_function_not_publicly_accessible: replace misleading
  function-identity URL -> securing/authenticating (invocation auth)
@s1ns3nz0 s1ns3nz0 requested review from a team as code owners May 2, 2026 08:38
@github-actions github-actions Bot added provider/gcp Issues/PRs related with the Google Cloud Platform provider compliance Issues/PRs related with the Compliance Frameworks metadata-review labels May 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Conflict Markers Resolved

All conflict markers have been successfully resolved in this pull request.

@github-actions github-actions Bot added the community Opened by the Community label May 2, 2026
@jfagoagas jfagoagas added the not-planned Issues that are not in the Prowler roadmap. label May 5, 2026
@jfagoagas
Copy link
Copy Markdown
Member

Hi @s1ns3nz0 thanks for this contribution 🙌

In order for us to be able to review the PR and merge it as fast as possible we need you to split it creating one PR by check. Please, let us know if you need help for that and the team will work with you.

@jfagoagas jfagoagas added size/xl Community PRs with a broad scope, e.g.: creating several checks. status/awaiting-reponse Waiting response from owner labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Opened by the Community compliance Issues/PRs related with the Compliance Frameworks metadata-review not-planned Issues that are not in the Prowler roadmap. provider/gcp Issues/PRs related with the Google Cloud Platform provider size/xl Community PRs with a broad scope, e.g.: creating several checks. status/awaiting-reponse Waiting response from owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants