turbot/terraform_aws_compliance

Query: vpc_network_acl_allow_ssh_port_22_ingress

Usage

powerpipe query terraform_aws_compliance.query.vpc_network_acl_allow_ssh_port_22_ingress

Steampipe Tables

SQL

with rules as (
select distinct
address as name
from
terraform_resource,
jsonb_array_elements(
case jsonb_typeof(attributes_std -> 'ingress')
when 'array' then (attributes_std -> 'ingress')
else jsonb_build_array(attributes_std -> 'ingress')
end
) ingress
where
type = 'aws_network_acl' and
ingress is not null and
(ingress ->> 'cidr_block' = '0.0.0.0/0' or ingress ->> 'ipv6_cidr_block' = '::/0')
and ingress ->> 'action' = 'allow'
and (
ingress ->> 'protocol' = '-1' or
(ingress ->> 'from_port') :: integer >= 22 or
(ingress ->> 'to_port') :: integer <= 22
)
)
select
r.address as resource,
case
when g.name is null then 'ok'
else 'alarm'
end as status,
split_part(r.address, '.', 2) || case
when g.name is null then ' restricts SSH access from the internet through port 22'
else ' allows SSH access from the internet through port 22'
end || '.' reason
, path || ':' || start_line
from
terraform_resource as r
left join rules as g on g.name = r.address
where
type = 'aws_network_acl';

Controls

The query is being used by the following controls: