turbot/steampipe-mod-kubernetes-compliance

Control: Replication Controller containers should have secrets defined as files

Description

This check ensures that the container in the Replication Controller has secrets defined as files.

Usage

Run the control in your terminal:

powerpipe control run kubernetes_compliance.control.replication_controller_container_secrets_defined_as_files

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run kubernetes_compliance.control.replication_controller_container_secrets_defined_as_files --share

SQL

This control uses a named query:

select
coalesce(uid, concat(path, ':', start_line)) as resource,
case
when env like '%valueFrom%' and env like '%secretKeyRef%' then 'alarm'
else 'ok'
end as status,
case
when env like '%valueFrom%' and env like '%secretKeyRef%' then c ->> 'name' || ' container has secrets defined.'
else c ->> 'name' || ' container has no secrets defined.'
end as reason,
name as replication_controller_name
, coalesce(context_name, '') as context_name, namespace, source_type, coalesce(path || ':' || start_line || '-' || end_line, '') as path
from
kubernetes_replication_controller,
jsonb_array_elements(template -> 'spec' -> 'containers') as c,
jsonb_array_elements_text(c -> 'env') as env
union
select
coalesce(uid, concat(path, ':', start_line)) as resource,
case
when env like '%secretRef%' then 'alarm'
else 'ok'
end as status,
case
when env like '%secretRef%' then c ->> 'name' || ' container has secrets defined.'
else c ->> 'name' || ' container has no secrets defined.'
end as reason,
name as replication_controller_name
, coalesce(context_name, '') as context_name, namespace, source_type, coalesce(path || ':' || start_line || '-' || end_line, '') as path
from
kubernetes_replication_controller,
jsonb_array_elements(template -> 'spec' -> 'containers') as c,
jsonb_array_elements_text(c -> 'envFrom') as env;

Tags