Panther low experimental python

AWS S3 Bucket Lifecycle Configuration

Verifies that the S3 Bucket Object Lifecycle configuration expires data within 90 and 365 days.

View Source

Detection Logic

from panther_base_helpers import deep_get

MAX_RETENTION_PERIOD = 365
MIN_RETENTION_PERIOD = 90


def policy(resource):
    if resource.get("LifecycleRules") is None:
        return False

    for lifecycle_rule in resource.get("LifecycleRules", []):
        if lifecycle_rule.get("Status") != "Enabled":
            continue

        rule_retention_period_days = deep_get(lifecycle_rule, "Expiration", "Days")

        if not rule_retention_period_days:
            continue

        if MIN_RETENTION_PERIOD <= rule_retention_period_days <= MAX_RETENTION_PERIOD:
            return True

    return False

Field Validations

Loading…

Comments (0)

Loading comments...