You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/reference/policies.mdx
+66Lines changed: 66 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -195,3 +195,69 @@ For example
195
195
196
196
## How to write a Chainloop policy in Rego
197
197
Check [this how-to](/guides/rego-policies) to know how you can write Chainloop policies in [Rego language](https://www.openpolicyagent.org/docs/latest/policy-language/#learning-rego).
198
+
199
+
200
+
## Policy Groups
201
+
202
+
This feature allow operators to group related policies into one single entity that can be reused across the organization.
203
+
With Policy Groups, materials and policies can be enforced in Chainloop contracts with little or no effort.
204
+
205
+
For example, they might want to create a "SBOM quality" group with some SBOM-related policies. The policy groups can be defined this way:
206
+
```yaml
207
+
# sbom-quality.yaml
208
+
apiVersion: workflowcontract.chainloop.dev/v1
209
+
kind: PolicyGroup
210
+
metadata:
211
+
name: sbom-quality
212
+
description: This policy group applies a number of SBOM-related policies
213
+
annotations:
214
+
category: SBOM
215
+
spec:
216
+
inputs:
217
+
- name: bannedLicenses
218
+
description: comma separated list of licenses to ban
219
+
required: true
220
+
- name: bannedComponents
221
+
description: comma separated list of components to ban
222
+
required: true
223
+
policies:
224
+
materials:
225
+
- name: sbom
226
+
type: SBOM_CYCLONEDX_JSON
227
+
policies:
228
+
- ref: sbom-banned-licenses
229
+
with:
230
+
licenses: {{ inputs.bannedLicenses }}
231
+
- ref: sbom-banned-components
232
+
with:
233
+
components: {{ inputs.bannedComponents }}
234
+
```
235
+
236
+
### Using Policy Groups
237
+
238
+
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,
250
+
they become part of the contract. From this point of view, they can be seen as subcontracts.
251
+
252
+
### Policy group parameters
253
+
254
+
In the same way as [policies](policies#policy-arguments), groups can accept arguments, which are specified in the `inputs` section.
255
+
Then those inputs can be passed down to policies using interpolation.
256
+
257
+
In the example above, `bannedComponents` input parameter (which is mandatory) is passed to the underlying policy with the expression `{{ inputs.banneComponents }}`
0 commit comments