Skip to content

Commit 78f36f4

Browse files
authored
Update azure_mandatory_sql_subscription_resource_group_mandatory.yaml
1 parent 64c07a5 commit 78f36f4

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

compliance/controls/azure/azure_mandatory_sql_subscription_resource_group_mandatory.yaml

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,42 @@ integration_type:
55
- azure_subscription
66
parameters:
77
- key: azureMandatoryTags
8+
default: '["name","environment"]'
89
policy:
9-
language: sql
10-
primary_resource: azure_resource_group
11-
definition: |
12-
WITH analysis AS (
13-
SELECT
14-
platform_integration_id,
15-
platform_resource_id,
16-
id,
17-
title,
18-
tags ?& '{{.azureMandatoryTags}}'::text[] AS has_mandatory_tags,
19-
TO_JSONB('{{.azureMandatoryTags}}'::text[]) - ARRAY(
20-
SELECT jsonb_object_keys(tags)
21-
) AS missing_tags,
22-
subscription_id
23-
FROM
24-
azure_resource_group
25-
)
26-
SELECT
27-
platform_integration_id,
28-
platform_resource_id,
29-
id AS resource,
30-
CASE
31-
WHEN has_mandatory_tags THEN 'ok'
32-
ELSE 'alarm'
33-
END AS status,
34-
CASE
35-
WHEN has_mandatory_tags THEN title || ' has all mandatory tags.'
36-
ELSE title || ' is missing tags: ' || array_to_string(
37-
ARRAY(
38-
SELECT jsonb_array_elements_text(missing_tags)
39-
), ', ') || '.'
40-
END AS reason,
41-
subscription_id
42-
FROM
43-
analysis;
10+
language: sql
11+
primary_resource: azure_resource_group
12+
definition: |
13+
WITH analysis AS (
14+
SELECT
15+
platform_integration_id,
16+
platform_resource_id,
17+
id,
18+
title,
19+
tags ?& '{{.azureMandatoryTags}}'::text[] AS has_mandatory_tags,
20+
TO_JSONB('{{.azureMandatoryTags}}'::text[]) - ARRAY(
21+
SELECT jsonb_object_keys(tags)
22+
) AS missing_tags,
23+
subscription_id
24+
FROM
25+
azure_resource_group
26+
)
27+
SELECT
28+
platform_integration_id,
29+
platform_resource_id,
30+
id AS resource,
31+
CASE
32+
WHEN has_mandatory_tags THEN 'ok'
33+
ELSE 'alarm'
34+
END AS status,
35+
CASE
36+
WHEN has_mandatory_tags THEN title || ' has all mandatory tags.'
37+
ELSE title || ' is missing tags: ' || array_to_string(
38+
ARRAY(
39+
SELECT jsonb_array_elements_text(missing_tags)
40+
), ', ') || '.'
41+
END AS reason,
42+
subscription_id
43+
FROM
44+
analysis;
4445
severity: high
4546
tags: {}

0 commit comments

Comments
 (0)