turbot/steampipe-mod-terraform-gcp-compliance

Control: Ensure that BigQuery datasets are not anonymously or publicly accessible

Description

It is recommended that the IAM policy on BigQuery datasets does not allow anonymous and/or public access.

Usage

Run the control in your terminal:

powerpipe control run terraform_gcp_compliance.control.bigquery_dataset_not_publicly_accessible

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run terraform_gcp_compliance.control.bigquery_dataset_not_publicly_accessible --share

SQL

This control uses a named query:

select
address as resource,
case
when (attributes_std -> 'access') is null then 'ok'
when exists(
select
1
from
jsonb_array_elements(
case
when jsonb_typeof(attributes_std -> 'access') = 'array' then attributes_std -> 'access'
else jsonb_build_array(attributes_std -> 'access')
end
) as access
where
(access ->> 'special_group' is not null and access ->> 'special_group' in ('allAuthenticatedUsers', 'allUsers'))
or
not(access ?| ARRAY['user_by_email', 'group_by_email', 'domain', 'view', 'routine', 'dataset'])
) then 'alarm'
else 'ok'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'access') is null then 'ok'
when exists(
select
1
from
jsonb_array_elements(attributes_std -> 'access') as access
where
(access ->> 'special_group' is not null and access ->> 'special_group' in ('allAuthenticatedUsers', 'allUsers'))
or
not(access ?| ARRAY['user_by_email', 'group_by_email', 'domain', 'view', 'routine', 'dataset'])
) then 'alarm'
else 'ok'
end || '.' reason
, path || ':' || start_line
from
terraform_resource
where
type = 'google_bigquery_dataset';

Tags