turbot/gcp_compliance

Query: cloudfunction_function_no_deployments_manager_permission

Usage

powerpipe query gcp_compliance.query.cloudfunction_function_no_deployments_manager_permission

SQL

with role_with_deployments_manager_permission as (
select
distinct name,
project
from
gcp_iam_role,
jsonb_array_elements_text(included_permissions) as p
where
not is_gcp_managed
and p in ('deploymentmanager.deployments.create', 'deploymentmanager.deployments.update' )
), policy_with_deployments_manager_permission as (
select
distinct entity,
project
from
gcp_iam_policy,
jsonb_array_elements(bindings) as p,
jsonb_array_elements_text(p -> 'members') as entity
where
p ->> 'role' in ('roles/deploymentmanager.editor' )
or p ->> 'role' in (select name from role_with_deployments_manager_permission )
)
select
f.project as resource,
case
when f.service_account_email is not null then 'alarm'
else 'ok'
end as status,
case
when f.service_account_email is not null then f.title || ' allow deployment manager''s permission.'
else f.title || ' restrict deployment manager''s permission.'
end as reason
, f.project as project
, f.project as project
from
gcp_cloudfunctions_function as f
left join policy_with_deployments_manager_permission as b on f.project = b.project and b.entity = concat('serviceAccount:' || f.service_account_email);

Controls

The query is being used by the following controls: