@@ -55,6 +55,7 @@ See the [adopters](/docs/adopters.md) file for more Regal users.
55
55
### Download Regal
56
56
57
57
** MacOS and Linux**
58
+
58
59
``` shell
59
60
brew install styrainc/packages/regal
60
61
```
@@ -68,40 +69,47 @@ for a list of package repositories which distribute Regal.
68
69
Manual installation commands:
69
70
70
71
** MacOS (Apple Silicon)**
72
+
71
73
``` shell
72
74
curl -L -o regal " https://github.com/StyraInc/regal/releases/latest/download/regal_Darwin_arm64"
73
75
```
74
76
75
77
** MacOS (x86_64)**
78
+
76
79
``` shell
77
80
curl -L -o regal " https://github.com/StyraInc/regal/releases/latest/download/regal_Darwin_x86_64"
78
81
```
79
82
80
83
** Linux (x86_64)**
84
+
81
85
``` shell
82
86
curl -L -o regal " https://github.com/StyraInc/regal/releases/latest/download/regal_Linux_x86_64"
83
87
chmod +x regal
84
88
```
85
89
86
90
** Windows**
91
+
87
92
``` shell
88
93
curl.exe -L -o regal.exe " https://github.com/StyraInc/regal/releases/latest/download/regal_Windows_x86_64.exe"
89
94
```
90
95
91
96
** Docker**
97
+
92
98
``` shell
93
99
docker pull ghcr.io/styrainc/regal:latest
94
100
```
95
101
96
102
See all versions, and checksum files, at the Regal [ releases] ( https://github.com/StyraInc/regal/releases/ ) page, and
97
103
published Docker images at the [ packages] ( https://github.com/StyraInc/regal/pkgs/container/regal ) page.
104
+
98
105
</details >
99
106
100
107
### Try it out!
101
108
102
109
First, author some Rego!
103
110
104
111
** policy/authz.rego**
112
+
105
113
``` rego
106
114
package authz
107
115
@@ -122,8 +130,10 @@ Next, run `regal lint` pointed at one or more files or directories to have them
122
130
``` shell
123
131
regal lint policy/
124
132
```
133
+
125
134
<!-- markdownlint-capture -->
126
135
<!-- markdownlint-disable MD010 -->
136
+
127
137
``` text
128
138
Rule: non-raw-regex-pattern
129
139
Description: Use raw strings for regex patterns
@@ -148,6 +158,7 @@ Documentation: https://docs.styra.com/regal/rules/style/prefer-snake-case
148
158
149
159
1 file linted. 3 violations found.
150
160
```
161
+
151
162
<!-- markdownlint-restore -->
152
163
<br />
153
164
@@ -198,8 +209,8 @@ The following rules are currently available:
198
209
199
210
<!-- RULES_TABLE_START -->
200
211
201
- | Category | Title | Description |
202
- | ------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
212
+ | Category | Title | Description |
213
+ | ----------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
203
214
| bugs | [ annotation-without-metadata] ( https://docs.styra.com/regal/rules/bugs/annotation-without-metadata ) | Annotation without metadata |
204
215
| bugs | [ argument-always-wildcard] ( https://docs.styra.com/regal/rules/bugs/argument-always-wildcard ) | Argument is always a wildcard |
205
216
| bugs | [ constant-condition] ( https://docs.styra.com/regal/rules/bugs/constant-condition ) | Constant condition |
@@ -298,7 +309,7 @@ By default, all rules except for those in the `custom` category are currently **
298
309
299
310
Most Regal rules will use data only from a single file at a time, with no consideration for other files. A few rules
300
311
however require data from multiple files, and will therefore collect, or aggregate, data from all files provided for
301
- linting. These rules are called * aggregate rules * , and will only be run when there is more than one file to lint, such
312
+ linting. These rules are called _ aggregate rules _ , and will only be run when there is more than one file to lint, such
302
313
as when linting a directory or a whole policy repository. One example of such a rule is the ` prefer-package-imports `
303
314
rule, which will aggregate package names and imports from all provided policies in order to determine if any imports
304
315
are pointing to rules or functions rather than packages. You normally won't need to care about this distinction other
@@ -327,14 +338,15 @@ A custom configuration file may be used to override the [default configuration](
327
338
options provided by Regal. The most common use case for this is to change the severity level of a rule. These three
328
339
levels are available:
329
340
330
- - ` ignore ` — disable the rule entirely
341
+ - ` ignore ` — disable the rule entirely
331
342
- ` warning ` — report the violation without changing the exit code of the lint command
332
- - ` error ` — report the violation and have the lint command exit with a non-zero exit code (default)
343
+ - ` error ` — report the violation and have the lint command exit with a non-zero exit code (default)
333
344
334
345
Additionally, some rules may have configuration options of their own. See the documentation page for a rule to learn
335
346
more about it.
336
347
337
348
** .regal/config.yaml**
349
+
338
350
``` yaml
339
351
rules :
340
352
style :
@@ -354,16 +366,16 @@ rules:
354
366
# in this example, test files are ignored
355
367
ignore :
356
368
files :
357
- - " *_test.rego"
369
+ - " *_test.rego"
358
370
custom :
359
371
# custom rule configuration
360
372
naming-convention :
361
373
level : error
362
374
conventions :
363
- # ensure all package names start with "acmecorp" or "system"
364
- - pattern : ' ^acmecorp\.[a-z_\.]+$|^system\.[a-z_\.]+$'
365
- targets :
366
- - package
375
+ # ensure all package names start with "acmecorp" or "system"
376
+ - pattern : ' ^acmecorp\.[a-z_\.]+$|^system\.[a-z_\.]+$'
377
+ targets :
378
+ - package
367
379
368
380
capabilities :
369
381
from :
@@ -379,14 +391,14 @@ capabilities:
379
391
ignore :
380
392
# files can be excluded from all lint rules according to glob-patterns
381
393
files :
382
- - file1.rego
383
- - " *_tmp.rego"
394
+ - file1.rego
395
+ - " *_tmp.rego"
384
396
385
397
project :
386
398
roots :
387
- # declares the 'main' and 'lib/jwt' directories as project roots
388
- - main
389
- - lib/jwt
399
+ # declares the 'main' and 'lib/jwt' directories as project roots
400
+ - main
401
+ - lib/jwt
390
402
` ` `
391
403
392
404
Regal will automatically search for a configuration file (` .regal/config.yaml`) in the current directory, and if not
@@ -477,10 +489,10 @@ rules:
477
489
level: error
478
490
ignore:
479
491
files:
480
- # ignore line length in test files to accommodate messy test data
481
- - "*_test.rego"
482
- # specific file used only for testing
483
- - "scratch.rego"
492
+ # ignore line length in test files to accommodate messy test data
493
+ - "*_test.rego"
494
+ # specific file used only for testing
495
+ - "scratch.rego"
484
496
` ` `
485
497
486
498
# ## Ignoring Files Globally
@@ -495,8 +507,8 @@ If you want to ignore certain files for all rules, you can use the global ignore
495
507
` ` ` yaml
496
508
ignore:
497
509
files:
498
- - file1.rego
499
- - "*_tmp.rego"
510
+ - file1.rego
511
+ - "*_tmp.rego"
500
512
` ` `
501
513
502
514
# ## Inline Ignore Directives
@@ -554,19 +566,19 @@ To provide an example, consider the
554
566
that a file declaring a `package` path like `policy.permissions.users` should also be located in a directory structure
555
567
that mirrors that package, i.e. `policy/permissions/users`. When a violation against this rule is reported, the
556
568
` regal fix` command, or its equivalent [Code Action](#regal-language-server) in editors, may when invoked remediate the
557
- issue by moving the file to the correct location. But where should the `policy/permissions/users` directory *itself*
569
+ issue by moving the file to the correct location. But where should the `policy/permissions/users` directory _itself_
558
570
reside?
559
571
560
572
Normally, the answer to that question would be the **project**, or **workspace** root. But if the file was found
561
- in a subdirectory containing a **bundle**, the directory naturally belongs under that *bundle 's root* instead. The
573
+ in a subdirectory containing a **bundle**, the directory naturally belongs under that _bundle 's root_ instead. The
562
574
` roots` configuration option under the top-level `project` object allows you to tell Regal where these roots are,
563
575
and have features like the `directory-package-mismatch` fixer work as you'd expect.
564
576
565
577
` ` ` yaml
566
578
project:
567
579
roots:
568
- - bundle1
569
- - bundle2
580
+ - bundle1
581
+ - bundle2
570
582
` ` `
571
583
572
584
The configuration file is not the only way Regal may determine project roots. Other ways include :
@@ -620,18 +632,18 @@ capabilities:
620
632
version: v0.58.0
621
633
minus:
622
634
builtins:
623
- # exclude rules that depend on the http.send built-in function
624
- - name: http.send
635
+ # exclude rules that depend on the http.send built-in function
636
+ - name: http.send
625
637
plus:
626
638
builtins:
627
- # make Regal aware of a custom "ldap.query" function
628
- - name: ldap.query
629
- type: function
630
- decl:
631
- args:
632
- - type: string
633
- result:
634
- type: object
639
+ # make Regal aware of a custom "ldap.query" function
640
+ - name: ldap.query
641
+ type: function
642
+ decl:
643
+ args:
644
+ - type: string
645
+ result:
646
+ type: object
635
647
` ` `
636
648
637
649
# ## Loading Capabilities from URLs
@@ -650,9 +662,9 @@ capabilities:
650
662
651
663
Regal includes capabilities files for the following engines :
652
664
653
- | Engine | Website | Description |
654
- |--------| ---------| -------------|
655
- | `opa` | [OPA website](https://www.openpolicyagent.org/) | Open Policy Agent |
665
+ | Engine | Website | Description |
666
+ | ------ | -- ------------------------------------------------------------- | -------------------- |
667
+ | `opa` | [OPA website](https://www.openpolicyagent.org/) | Open Policy Agent |
656
668
| `eopa` | [Enterprise OPA website](https://www.styra.com/enterprise-opa/) | Styra Enterprise OPA |
657
669
658
670
# # Exit Codes
@@ -775,7 +787,8 @@ See the [Editor Support](/docs/editor-support.md) page for information about Reg
775
787
by Charlie Egan ([@charlieegan3](https://github.com/charlieegan3))
776
788
- [Linting Rego with... Rego!](https://www.styra.com/blog/linting-rego-with-rego/) by Anders Eknert ([@anderseknert](https://github.com/anderseknert))
777
789
- [Regal : Rego(OPA)用リンタの導入手順](https://zenn.dev/erueru_tech/articles/6cfb886d92858a) by Jun Fujita ([@erueru-tech](https://github.com/erueru-tech))
778
- - [Regal を使って Rego を Lint する](https://tech.dentsusoken.com/entry/2024/12/05/Regal_%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6_Rego_%E3%82%92_Lint_%E3%81%99%E3%82%8B) by Shibata Takao ([@shibata.takao](https://shodo.ink/@shibata.takao/))
790
+ - [Regal を使って Rego を Lint する](https://tech.dentsusoken.com/entry/2024/12/05/Regal_%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6_Rego_%E3%82%92_Lint_%E3%81%99%E3%82%8B)
791
+ by Shibata Takao ([@shibata.takao](https://shodo.ink/@shibata.takao/))
779
792
780
793
# # Status
781
794
0 commit comments