/
redis.sp
107 lines (103 loc) · 3.15 KB
/
redis.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
query "azure_redis_cache_in_virtual_network" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'subnet_id') is not null then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'subnet_id') is not null then ' in virtual network'
else ' not in virtual network'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'azurerm_redis_cache';
EOQ
}
query "azure_redis_cache_ssl_enabled" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std -> 'enable_non_ssl_port')::boolean then 'alarm'
else 'ok'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'enable_non_ssl_port')::boolean then ' secure connections disabled'
else ' secure connections enabled'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'azurerm_redis_cache';
EOQ
}
query "redis_cache_min_tls_1_2" {
sql = <<-EOQ
select
address as resource,
attributes_std ->> 'minimum_tls_version',
case
when (attributes_std -> 'minimum_tls_version') is null then 'alarm'
when (attributes_std ->> 'minimum_tls_version')::float < 1.2 then 'alarm'
else 'ok'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'minimum_tls_version') is null then ' ''min_tls_version'' not defined'
when (attributes_std ->> 'minimum_tls_version')::float < 1.2 then ' not using the latest version of TLS encryption'
else ' using the latest version of TLS encryption'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'azurerm_redis_cache';
EOQ
}
query "redis_cache_restrict_public_access" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std ->> 'public_network_access_enabled') = 'false' then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std ->> 'public_network_access_enabled') = 'false' then ' not publicly accessible'
else ' publicly accessible'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'azurerm_redis_cache';
EOQ
}
query "redis_cache_standard_replication_enabled" {
sql = <<-EOQ
select
address as resource,
case
when (attributes_std ->> 'sku_name') in ('Standard' , 'Premium') then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std ->> 'sku_name') in ('Standard' , 'Premium') then ' standard replication enabled'
else ' standard replication disabled'
end || '.' reason
${local.tag_dimensions_sql}
${local.common_dimensions_sql}
from
terraform_resource
where
type = 'azurerm_redis_cache';
EOQ
}