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
* add page for CEL support
* add page for CEL support
* add page for CEL support
* add page for CEL support
* add page for CEL support
* add page for CEL support
* add page for CEL support
* add page for CEL support
Datree supports writing custom rules in the [CEL](https://github.com/google/cel-spec) language, by utilizing a custom JSON Schema keyword.
7
+
8
+
:::info Supported version
9
+
Writing custom rules in CEL is supported in CLI version [1.9.19](https://github.com/datreeio/datree/releases/tag/1.9.19) and above.
10
+
:::
11
+
12
+
## Required properties
13
+
14
+
In addition to the basic [required format](/custom-rules/custom-rules-overview#rule-format), a CEL custom rule has the following requirements:
15
+
16
+
- The `schema` property **must** have a property named `CELDefinition`, which is an array of items.
17
+
- Each item **must** have a property named `expression` that contains the logic of the rule written in CEL. Within the expression, use `object` to reference the resource being evaluated (see example below).
18
+
- Each item **may** have a property named `message`, which specifies what print when the expression is violated.
19
+
20
+
:::tip Online CEL validation
21
+
Ensure the validity of your CEL expressions by testing them against resources using an [online CEL playground](https://playcel.undistro.io/).
22
+
:::
23
+
24
+
#### Example:
25
+
26
+
The following schema requires that resources of kind `ServiceAccount` have the `automountServiceAccountToken` property set to `false`:
In addition to Datree's built-in rules, you can also write your own rules and add them to your policies.
7
7
The custom rule engine is based on [JSON Schema](https://json-schema.org/), so it supports both YAML and JSON declarative syntax.
8
8
9
-
Custom rules can be written directly in **JSON Schema** or in [**Rego**](/custom-rules/rego-support).
9
+
Custom rules can be written directly in **JSON Schema**, in [**Rego**](/custom-rules/rego-support), or in [CEL](/custom-rules/cel-support).
10
10
11
11
:::info Note
12
12
Note that using custom rules is possible only when in [Policy as code](/dashboard/policy-as-code) mode.
@@ -34,7 +34,7 @@ Every custom rule must have the following properties:
34
34
-**identifier** - a unique ID to associate with a policy.
35
35
-**name**[OPTIONAL] - a title that will be shown in Datree's output when a rule fails.
36
36
-**defaultMessageOnFailure**[OPTIONAL] - a message that is shown when the property `policies.name[].rules.messageOnFailure` is empty (unique to each identifier).
37
-
-**schema** - a custom rule logic written in JSON Schema (as YAML) or in [Rego](/custom-rules/rego-support).
37
+
-**schema** - a custom rule logic written in JSON Schema (as YAML), in [Rego](/custom-rules/rego-support), or in [CEL](/custom-rules/cel-support).
38
38
39
39
### Policies file format
40
40
@@ -78,3 +78,4 @@ The provided examples are written in YAML schema, but custom rules can also be s
0 commit comments