turbot/steampipe-mod-oci-insights

Dashboard: OCI VCN Network Security Group Dashboard

This dashboard answers the following questions:

  • How many security groups are in each tenancy, compartment, and region?
  • How many security groups have unrestricted ingress SSH and RDP?
This dashboard contains 3 cards.

Usage

Install the mod:

mkdir dashboards
cd dashboards
powerpipe mod init
powerpipe mod install github.com/turbot/steampipe-mod-oci-insights

Start the Powerpipe server:

steampipe service start
powerpipe server

Open http://localhost:9033 in your browser and select OCI VCN Network Security Group Dashboard dashboard.

You could also snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe dashboard run oci_insights.dashboard.oci_vcn_network_security_group_dashboard --share

Queries

This dashboard uses the the following queries:
with non_compliant_rules as (
select
id,
count(*) as num_noncompliant_rules
from
oci_core_network_security_group,
jsonb_array_elements(rules) as r
where
r ->> 'direction' = 'INGRESS'
and r ->> 'sourceType' = 'CIDR_BLOCK'
and r ->> 'source' = '0.0.0.0/0'
and (
r ->> 'protocol' = 'all'
or (
(r -> 'tcpOptions' -> 'destinationPortRange' ->> 'min')::integer <= 22
and (r -> 'tcpOptions' -> 'destinationPortRange' ->> 'max')::integer >= 22
)
)
and lifecycle_state <> 'TERMINATED'
group by id
),
sg_list as (
select
nsg.id,
case
when non_compliant_rules.id is null then true
else false
end as restricted
from
oci_core_network_security_group as nsg
left join non_compliant_rules on non_compliant_rules.id = nsg.id
left join oci_identity_compartment c on c.id = nsg.compartment_id
where
nsg.lifecycle_state <> 'TERMINATED'
)
select
case
when restricted then 'restricted'
else 'unrestricted'
end as restrict_ingress_rdp_status,
count(*)
from
sg_list
group by restricted;

Tags