-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use Regal for Rego linting (#881)
This PR introduces [Regal](https://github.com/styrainc/regal) for linting the example policies in this project. The Rego found there is generally in a good shape, and the fixes done as part of this are mostly related to style. The code has been updated to conformance against the following rules: * [line-length](https://docs.styra.com/regal/rules/style/line-length) * [use-assignment-operator](https://docs.styra.com/regal/rules/style/use-assignment-operator) * [use-some-for-output-vars](https://docs.styra.com/regal/rules/idiomatic/use-some-for-output-vars) * [prefer-snake-case](https://docs.styra.com/regal/rules/style/prefer-snake-case) * [print-or-trace-call](https://docs.styra.com/regal/rules/testing/print-or-trace-call) A few rules are also ignored for now (`.regal/config.yaml`) and I'll leave it up to the maintainers to decide whether more rules should be enabled later. The PR also adds Regal to CI to lint any Rego introduced or changed in future PRs. For more information about Regal and its rules, see the [documentation](https://docs.styra.com/regal) for the project. Signed-off-by: Anders Eknert <anders@styra.com>
- Loading branch information
1 parent
e082ab6
commit 14e95ad
Showing
28 changed files
with
107 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
rules: | ||
idiomatic: | ||
no-defined-entrypoint: | ||
level: ignore | ||
imports: | ||
prefer-package-imports: | ||
level: error | ||
ignore-import-paths: | ||
- data.services | ||
style: | ||
line-length: | ||
non-breakable-word-threshold: 80 | ||
opa-fmt: | ||
level: ignore | ||
prefer-some-in-iteration: | ||
level: ignore | ||
testing: | ||
test-outside-test-package: | ||
level: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package main | ||
|
||
deny[msg] { | ||
expectedSHAS256 := "sha256:d7ec60cf8390612b360c857688b383068b580d9a6ab78417c9493170ad3f1616" | ||
input.metadata.component.version != expectedSHAS256 | ||
msg := sprintf("current SHA256 %s is not equal to expected SHA256 %s", [input.metadata.component.version, expectedSHAS256]) | ||
expected_shas256 := "sha256:d7ec60cf8390612b360c857688b383068b580d9a6ab78417c9493170ad3f1616" | ||
input.metadata.component.version != expected_shas256 | ||
msg := sprintf( | ||
"current SHA256 %s is not equal to expected SHA256 %s", [input.metadata.component.version, expected_shas256] | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package main | ||
|
||
any_git_ignored { | ||
entry := input[o] | ||
entry := input[_] | ||
|
||
entry.Kind == "Path" | ||
entry.Value == ".git" | ||
} | ||
|
||
deny[msg] { | ||
not any_git_ignored | ||
msg = ".git directories should be ignored" | ||
msg := ".git directories should be ignored" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.