Skip to content

Commit d02a5c7

Browse files
committed
docs: update policy-language
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
1 parent 3d90dee commit d02a5c7

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

docs/docs/policy-language.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,18 +2600,18 @@ comment block containing the YAML document is finished
26002600

26012601
### Annotations
26022602

2603-
| Name | Type | Description |
2604-
| ------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
2605-
| scope | string; one of `package`, `rule`, `document`, `subpackages` | The scope for which the metadata applies. Read more in the [Metadata Scope section below](#metadata-scope). |
2606-
| `id` | string | A unique identifier for the rule, used to track evaluated rules in decision logs. Read more in the [Metadata ID section below](#metadata-id). |
2607-
| `title` | string | A human-readable name for the annotation target. Read more in the [Metadata Title section below](#metadata-title). |
2608-
| `description` | string | A description of the annotation target. Read more in the [Metadata Description section below](#metadata-description). |
2609-
| `related_resources` | list of URLs | A list of URLs pointing to related resources/documentation. Read more in the [Metadata Related Resources section below](#metadata-related_resources). |
2610-
| `authors` | list of strings | A list of authors for the annotation target. Read more in the [Metadata Authors section below](#metadata-authors). |
2611-
| `organizations` | list of strings | A list of organizations related to the annotation target. Read more in the [Metadata Organizations section below](#metadata-organizations). |
2612-
| `schemas` | list of object | A list of associations between value paths and schema definitions. Read more in the [Metadata Schemas section below](#metadata-schemas). |
2613-
| `entrypoint` | boolean | Whether or not the annotation target is to be used as a policy entrypoint. Read more in the [Metadata Entrypoint section below](#metadata-entrypoint). |
2614-
| `custom` | mapping of arbitrary data | A custom mapping of named parameters holding arbitrary data. Read more in the [Metadata Custom section below](#metadata-custom). |
2603+
| Name | Type | Description |
2604+
| ------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2605+
| scope | string; one of `package`, `rule`, `document`, `subpackages` | The scope for which the metadata applies. Read more in the [Metadata Scope section below](#metadata-scope). |
2606+
| `labels` | mapping of key-value pairs | Arbitrary labels attached to a rule, recorded in decision logs when the rule is evaluated. Read more in the [Metadata Labels section below](#metadata-labels). |
2607+
| `title` | string | A human-readable name for the annotation target. Read more in the [Metadata Title section below](#metadata-title). |
2608+
| `description` | string | A description of the annotation target. Read more in the [Metadata Description section below](#metadata-description). |
2609+
| `related_resources` | list of URLs | A list of URLs pointing to related resources/documentation. Read more in the [Metadata Related Resources section below](#metadata-related_resources). |
2610+
| `authors` | list of strings | A list of authors for the annotation target. Read more in the [Metadata Authors section below](#metadata-authors). |
2611+
| `organizations` | list of strings | A list of organizations related to the annotation target. Read more in the [Metadata Organizations section below](#metadata-organizations). |
2612+
| `schemas` | list of object | A list of associations between value paths and schema definitions. Read more in the [Metadata Schemas section below](#metadata-schemas). |
2613+
| `entrypoint` | boolean | Whether or not the annotation target is to be used as a policy entrypoint. Read more in the [Metadata Entrypoint section below](#metadata-entrypoint). |
2614+
| `custom` | mapping of arbitrary data | A custom mapping of named parameters holding arbitrary data. Read more in the [Metadata Custom section below](#metadata-custom). |
26152615

26162616
### Metadata `Scope`
26172617

@@ -2665,19 +2665,19 @@ allow if {
26652665
message := "welcome!" if allow
26662666
```
26672667

2668-
### Metadata `id`
2668+
### Metadata `labels`
26692669

2670-
The `id` annotation is a string value that uniquely identifies a rule. When
2671-
any loaded policy contains rules with `id` annotations (or when external rule
2672-
sources are registered), the IDs of successfully evaluated rules are
2673-
automatically recorded in decision log events.
2674-
2675-
When any module contains a metadata block with an `id` field, annotation
2676-
parsing is enabled automatically (even if `ProcessAnnotation` was not set).
2670+
The `labels` annotation is a map of arbitrary key-value pairs attached to a
2671+
rule (or document). When rules with `labels` are successfully evaluated, their
2672+
label sets are automatically recorded in decision log events under the
2673+
`rule_labels` field. Labels from document-scoped and rule-scoped annotations
2674+
are both collected.
26772675

26782676
```rego
26792677
# METADATA
2680-
# id: allow-admin
2678+
# labels:
2679+
# severity: high
2680+
# team: platform
26812681
allow if input.role == "admin"
26822682
```
26832683

v1/topdown/evaluated_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func TestEvaluatedRuleLabelsScopes(t *testing.T) {
9898
note string
9999
module string
100100
query string
101+
input string
101102
exp []map[string]any
102103
}{
103104
{

0 commit comments

Comments
 (0)