turbot/kubernetes_compliance

Query: cronjob_container_image_tag_specified

Usage

powerpipe query kubernetes_compliance.query.cronjob_container_image_tag_specified

Steampipe Tables

SQL

select
coalesce(uid, concat(path, ':', start_line)) as resource,
case
when c ->> 'image' is null
or c ->> 'image' = '' then 'alarm'
when c ->> 'image' like '%@%' then 'ok'
when (
select
(
regexp_matches(c ->> 'image', '(?:[^\s\/]+\/)?([^\s:]+):?([^\s]*)')
) [ 2 ]
) in ('latest', '') then 'alarm'
else 'ok'
end as status,
case
when c ->> 'image' is null
or c ->> 'image' = '' then c ->> 'name' || ' no image specified.'
when c ->> 'image' like '%@%' then c ->> 'name' || ' image with digest specified.'
when (
select
(
regexp_matches(c ->> 'image', '(?:[^\s\/]+\/)?([^\s:]+):?([^\s]*)')
) [ 2 ]
) in ('latest', '') then c ->> 'name' || ' image with the latest tag or no tag specified.'
else c ->> 'name' || ' image with tag specified.'
end as reason,
name as cronjob_name,
coalesce(context_name, '') as context_name,
namespace,
source_type,
coalesce(path || ':' || start_line || '-' || end_line, '') as path
from
kubernetes_cronjob,
jsonb_array_elements(
job_template -> 'spec' -> 'template' -> 'spec' -> 'containers'
) as c;

Controls

The query is being used by the following controls: