Back to Checks
iac

Database auditing retention period should be longer than 90 days

AZU-0025
Service: databaseSeverity: medium
OfficialBuilt-inVerified

When Auditing is configured for a SQL database, if the retention period is not set, the retention will be unlimited.

If the retention period is to be explicitly set, it should be set for no less than 90 days.

Run this check with Prowler

Run in Prowler Cloud
Run
prowler iac --checks AZU-0025

Recommendation

Set retention periods of database auditing to greater than 90 days

Check Code

# METADATA
# title: Database auditing retention period should be longer than 90 days
# description: |
#   When Auditing is configured for a SQL database, if the retention period is not set, the retention will be unlimited.
#
#   If the retention period is to be explicitly set, it should be set for no less than 90 days.
# scope: package
# schemas:
#   - input: schema["cloud"]
# related_resources:
#   - https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview
# custom:
#   id: AZU-0025
#   long_id: azure-database-retention-period-set
#   aliases:
#     - AVD-AZU-0025
#     - retention-period-set
#     - azure-database-retention-period-set
#   provider: azure
#   service: database
#   severity: MEDIUM
#   recommended_action: Set retention periods of database auditing to greater than 90 days
#   input:
#     selector:
#       - type: cloud
#         subtypes:
#           - service: database
#             provider: azure
#   examples: checks/cloud/azure/database/retention_period_set.yaml
package builtin.azure.database.azure0025

import rego.v1

import data.lib.cloud.value

deny contains res if {
	some server in input.azure.database.mssqlservers
	some policy in server.extendedauditingpolicies
	value.less_than(policy.retentionindays, 90)
	value.is_not_equal(policy.retentionindays, 0)

	res := result.new(
		"Server has a retention period of less than 90 days.",
		policy.retentionindays,
	)
}