Skip to main content

Overview

This feature allow operators to group related policies into one single entity that can be reused across the organization. With Policy Groups, materials and policies can be enforced in Chainloop contracts with little or no effort. For example, they might want to create a “SBOM quality” group with some SBOM-related policies. The policy groups can be defined this way:
Policy groups can also be stored and managed in the platform using the Enterprise Edition CLI. For a complete guide on managing policy groups and other resources declaratively via YAML, see Declarative Resource Management.

Using Policy Groups

This policy group could be applied to any contract:
As we introduced earlier, policy groups define both materials and policies applied to them. Once they are included to a contract, they become part of the contract. From this point of view, they can be seen as subcontracts, as they can also be used to enforce materials to be present in the attestation. For example, after applying the above contract, doing an attestation push would fail until the required material is provided:

Policy group parameters

In the same way as policies, groups can accept arguments, which are specified in the inputs section. Then those inputs can be passed down to policies using interpolation. In the example above, bannedComponents input parameter (which is mandatory) is passed to the underlying policy with the expression {{ inputs.bannedComponents }}

Skipping specific policies

Sometimes you may want to use a policy group but temporarily or permanently exclude certain policies from evaluation without modifying the group definition itself. This is useful when:
  • A specific policy doesn’t apply to a particular workflow
  • You need to temporarily bypass a policy during development or migration
  • Different workflows need different subsets of policies from the same group
You can use the skip field to selectively exclude policies by their metadata name:
Policy names in the skip list refer to the policy’s metadata name (the name field in the policy definition)
This feature provides flexibility in policy enforcement per workflow without requiring multiple versions of the same policy group.

Using placeholders in material names

In the previous example, our policy group enforces a sbom material. But what if our contract requires multiple SBOMs (because we are building several images in the same pipeline, for example)? By using parameters and placeholders in material names, we can add as many instances of the same policy group as we need:
In our contract:
And finally, in our attestation, we can see the new configuration applied: