feat: add changelog and fix flake8

This commit is contained in:
Daniel Barranquero
2025-10-17 12:11:40 +02:00
parent a8d775d162
commit 77d61881a0
3 changed files with 19 additions and 13 deletions
+1
View File
@@ -17,6 +17,7 @@ All notable changes to the **Prowler SDK** are documented in this file.
- Oracle Cloud provider with CIS 3.0 benchmark [(#8893)](https://github.com/prowler-cloud/prowler/pull/8893)
- Support for Atlassian Document Format (ADF) in Jira integration [(#8878)](https://github.com/prowler-cloud/prowler/pull/8878)
- Add Common Cloud Controls for AWS, Azure and GCP [(#8000)](https://github.com/prowler-cloud/prowler/pull/8000)
- `cloudstorage_bucket_lifecycle_management_enabled` check for GCP provider [(#8936)](https://github.com/prowler-cloud/prowler/pull/8936)
### Changed
@@ -1,17 +1,18 @@
from prowler.lib.check.models import Check, Check_Report_GCP
from prowler.providers.gcp.services.cloudstorage.cloudstorage_client import cloudstorage_client
from prowler.providers.gcp.services.cloudstorage.cloudstorage_client import (
cloudstorage_client,
)
class cloudstorage_bucket_lifecycle_management_enabled(Check):
"""Ensure Cloud Storage buckets have lifecycle management enabled with at least one valid rule.
Reports PASS if a bucket has at least one valid lifecycle rule
(with a supported action and condition), otherwise FAIL.
"""
def execute(self) -> list[Check_Report_GCP]:
"""Run the lifecycle management check for each Cloud Storage bucket.
Returns:
@@ -27,25 +28,29 @@ class cloudstorage_bucket_lifecycle_management_enabled(Check):
)
rules = bucket.lifecycle_rules
if rules:
valid_rules = []
for rule in rules:
action_type = rule.get("action", {}).get("type")
condition = rule.get("condition")
if action_type in ("Delete", "SetStorageClass", "AbortIncompleteMultipartUpload") and condition:
if (
action_type
in (
"Delete",
"SetStorageClass",
"AbortIncompleteMultipartUpload",
)
and condition
):
valid_rules.append(rule)
if valid_rules:
report.status = "PASS"
report.status_extended = (
f"Bucket {bucket.name} has lifecycle management enabled with {len(valid_rules)} valid rule(s)."
)
report.status_extended = f"Bucket {bucket.name} has lifecycle management enabled with {len(valid_rules)} valid rule(s)."
else:
report.status = "FAIL"
report.status_extended = (
f"Bucket {bucket.name} has lifecycle rules configured but none are valid."
)
report.status_extended = f"Bucket {bucket.name} has lifecycle rules configured but none are valid."
findings.append(report)
return findings
@@ -36,7 +36,7 @@ class CloudStorage(GCPService):
lifecycle = bucket.get("lifecycle")
if isinstance(lifecycle, dict):
rules = lifecycle.get("rule")
if isinstance(rules, list):
if isinstance(rules, list):
lifecycle_rules = rules
self.buckets.append(