- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
05-29-2024 03:17 AM
We have been deploying custom build and run policies via Checkov (targeting Terraform resources, i.e.: VMs). We do this via the Governance pane in the Prisma Cloud "Cloud Security" component. These policies check usage of tags. Cool.
Now we're trying to create an equivalent set of policies for Container Images Labels. Specifically, we want to create guardrails and alerting around the usage of container images labels.
Anyone have an idea on how to create custom policies for this with Prisma Cloud? (either from CSPM/governance or the CWP/runtime compliance checks, the documentation and examples is not loads extensive and support seems to be missing at times).
Thoughts?
11-14-2024 12:28 PM
Hi Patriciar,
If you would like to check for existence of labels in a Dockerfile at build time you can write a simple custom check, for example to check for org and purpose labels:
metadata:
id: "MyLabelCheck"
name: "Ensure org and purpose labels are present"
category: "APPLICATION_SECURITY"
definition:
and:
- cond_type: attribute
resource_types:
- LABEL
attribute: value
operator: contains
value: "purpose="
- cond_type: attribute
resource_types:
- LABEL
attribute: value
operator: contains
value: "org="
That will check against the LABEL directive in Dockerfile, for example
FROM node:alpine
LABEL org=Accounting purpose=Appserver
RUN useradd -m appuser
USER appuser
WORKDIR /usr/src/app
..etc..
Then you can tell checkov to load the additional check from the directory where you placed the yaml file
checkov [other paramereters] --framework dockerfile --external-checks-dir my_yaml_checks_dir/ --check MyLabelCheck
Hope this helps
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!