cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.28.4

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/checks/rule/reject.md

120lines · modecode

1---
2layout: default
3parent: Checks
4grand_parent: Documentation
5---
6
7# rule/reject
8
9This check allows rejecting label or annotations keys and values using regexp
10rules.
11
12## Configuration
13
14Syntax:
15
16```js
17reject "$pattern" {
18 severity = "bug|warning|info"
19 label_keys = true|false
20 label_values = true|false
21 annotation_keys = true|false
22 annotation_values = true|false
23}
24```
25
26- `$pattern` - regexp pattern to reject, this can be templated
27 to reference checked rule fields, see [Configuration](../../configuration.md)
28 for details
29- `severity` - set custom severity for reported issues, defaults to a bug.
30- `label_keys` - if true label keys for recording and alerting rules will
31 be checked.
32- `label_values` - if true label values for recording and alerting rules will
33 be checked.
34- `annotation_keys` - if true annotation keys for alerting rules will be checked.
35- `annotation_values` - if true label values for alerting rules will be checked.
36
37## How to enable it
38
39This check is not enabled by default as it requires explicit configuration
40to work.
41To enable it add one or more `rule {...}` blocks and specify all rejected patterns
42there.
43
44Examples:
45
46Disallow using URLs as label keys or values:
47
48```js
49rule {
50 match {
51 kind = "alerting"
52 }
53
54 reject "https?://.+" {
55 label_keys = true
56 label_values = true
57 }
58}
59```
60
61Disallow spaces in label and annotation keys:
62
63```js
64rule {
65 reject ".* +.*" {
66 annotation_keys = true
67 label_keys = true
68 }
69}
70```
71
72Disallow label and annotation values equal to alert name:
73
74{% raw %}
75```js
76rule {
77 match {
78 kind = "alerting"
79 }
80
81 reject "{{ $alert }}" {
82 annotation_values = true
83 label_values = true
84 }
85}
86```
87{% endraw %}
88
89## How to disable it
90
91You can disable this check globally by adding this config block:
92
93```js
94checks {
95 disabled = ["rule/reject"]
96}
97```
98
99Or you can disable it per rule by adding a comment to it.
100
101`# pint disable rule/reject`
102
103If you want to disable only individual instances of this check
104you can add a more specific comment.
105
106### If `label_keys` or `annotation_keys` is set
107
108`# pint disable rule/reject(key=~'$pattern`)`
109
110Example:
111
112`# pint disable rule/reject(key=~'^https?://.+$')`
113
114### If `label_values` or `annotation_values` is set
115
116`# pint disable promql/reject(val=~'$pattern')`
117
118Example:
119
120`# pint disable rule/reject(val=~'^https?://.+$')`
121