turbot/azure_compliance

Query: sql_server_auditing_retention_period_90

Usage

powerpipe query azure_compliance.query.sql_server_auditing_retention_period_90

SQL

select
s.id as resource,
case
when (audit -> 'properties' ->> 'retentionDays')::integer = 0 then 'ok'
when (audit -> 'properties' ->> 'retentionDays')::integer >= 90 then 'ok'
else 'alarm'
end as status,
case
when (audit -> 'properties' ->> 'retentionDays')::integer = 0 then name || ' audit retention set to unlimited days.'
when (audit -> 'properties' ->> 'retentionDays')::integer >= 90 then name || ' audit retention greater than 90 days.'
else name || ' audit retention less than 90 days.'
end as reason
, s.resource_group as resource_group
, sub.display_name as subscription
from
azure_sql_server s,
jsonb_array_elements(server_audit_policy) audit,
azure_subscription sub
where
sub.subscription_id = s.subscription_id;

Controls

The query is being used by the following controls: