Skip to content

Instantly share code, notes, and snippets.

@judell
Last active April 14, 2023 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save judell/d38b2be25812b67bac9d04d39664caae to your computer and use it in GitHub Desktop.
Save judell/d38b2be25812b67bac9d04d39664caae to your computer and use it in GitHub Desktop.
javier-2
dashboard "javier" {
with "tls_connection" {
sql = <<EOQ
create or replace function public.tls_connection(domain text) returns setof net_tls_connection as $$
select
*
from
net_tls_connection
where
address = domain || ':443'
and handshake_completed
$$ language sql
EOQ
}
benchmark "tls_version" {
title = "sample benchmark"
children = [
control.tls_whitehouse,
control.tls_steampipe
]
}
card {
width = 3
title = "whitehouse.gov"
sql = <<EOQ
select max(version) from tls_connection('whitehouse.gov')
EOQ
}
card {
width = 3
title = "steampipe.io"
sql = <<EOQ
select max(version) from tls_connection('steampipe.io')
EOQ
}
container {
chart "tls_version_whitehouse" {
args = [ "whitehouse.gov" ]
title = "whitehouse.gov"
base = chart.tls_version
width = 6
}
chart "tls_version_steampipe" {
args = [ "steampipe.io" ]
title = "steampipe.io"
base = chart.tls_version
}
}
container {
table "tls_version_whitehouse" {
title = "whitehouse.gov"
width = 6
sql = <<EOT
select * from tls_connection('whitehouse.gov')
EOT
}
table "tls_version_steampipe" {
width = 6
title = "steampipe.io"
sql = <<EOT
select * from tls_connection('steampipe.io')
EOT
}
}
}
control "tls_whitehouse" {
args = [ "whitehouse.gov" ]
title = "control.tls_whitehouse"
query = query.tls_control
}
control "tls_steampipe" {
args = [ "steampipe.io" ]
title = "control.tls_steampipe"
query = query.tls_control
}
query "tls_control" {
sql = <<EOQ
with data as (
select
max(version) as max_version,
address
from
tls_connection($1)
group by
address
)
select
address as resource,
case
when max_version >= 'TLS v1.2' then 'ok'
else 'alarm'
end as status,
case
when max_version >= 'TLS v1.2' then $1 || ' TLS max_version is compliant: ' || max_version
else $1 || ' TLS version is NOT compliant: ' || max_version
end as reason
from
data
EOQ
}
chart "tls_version" {
type = "donut"
width = 6
sql = <<EOT
select
version,
count(*)
from
tls_connection($1)
group by
version
EOT
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment