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
When defining a contract, a new `policies` section can be specified. Policies can be applied to any material, but also to the attestation statement as a whole.
37
37
```yaml
38
38
schemaVersion: v1
@@ -46,8 +46,10 @@ materials:
46
46
policies:
47
47
materials: # policies applied to materials
48
48
- ref: file://cyclonedx-licenses.yaml # (1)
49
+
# or optionally with the digest appended, see integrity checks below
- (1) materials will be validated against `cyclonedx-licenses.yaml` policy. But, since that policy has a `type` property set to `SBOM_CYCLONEDX_JSON`, only SBOM materials (`sbom` and `another-sbom` in this case) will be evaluated.
@@ -68,7 +70,7 @@ Finally, note that material policies are evaluated during `chainloop attestation
68
70
69
71
### Embedding or referencing policies
70
72
There are two ways to attach a policy to a contract:
71
-
* **By referencing it**, as it can be seen in the examples above. `ref` property admits a local `file://`` (filesystem) or remote reference `https://`. For example:
73
+
* **By referencing it**, as it can be seen in the examples above. `ref` property admits a local `file://` (filesystem) or remote reference `https://`. For example:
72
74
```yaml
73
75
policies:
74
76
materials:
@@ -78,7 +80,7 @@ There are two ways to attach a policy to a contract:
are both equivalent. The advantage of having remote policies is that they can be easily reused, allowing organizations to create policy catalogs.
84
86
@@ -127,7 +129,22 @@ policies:
127
129
```
128
130
(1) This is interpreted as a string, that's why we need to add `to_number` in the policy script
129
131
130
-
### Rego scripts
132
+
### Integrity Checks
133
+
134
+
Optionally, you can append the sha256 hash of the policy file content to your policy attachment reference. By doing so, the policy engine will make sure the resolved policy matches the expected hash in the contract reference.
135
+
136
+
For example
137
+
138
+
```yaml
139
+
policies:
140
+
materials:
141
+
# append digest to optionally check the integrity of the policy file during evaluation
Currently, policy scripts are assumed to be written in [Rego language](https://www.openpolicyagent.org/docs/latest/policy-language/#learning-rego). Other policy engines might be implemented in the future.
132
149
The only requirement of the policy is the existence of one or multiple `violations` rules, which evaluate to a **set of violation messages**.
0 commit comments