-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recommend using `import rego.v1`. Also: * Ignore `import future` rules when `rego.v1` rule in capabilities * Update the documentation for all rules to use the `rego.v1` import * Update all Rego used in tests to use `rego.v1` import Signed-off-by: Anders Eknert <[email protected]>
- Loading branch information
1 parent
c911cb8
commit bc27c76
Showing
51 changed files
with
309 additions
and
165 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
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 |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
# schemas: | ||
# - input: schema.regal.ast | ||
package regal | ||
|
||
import rego.v1 |
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,21 @@ | ||
# METADATA | ||
# description: Use `import rego.v1` | ||
package regal.rules.imports["use-rego-v1"] | ||
|
||
import rego.v1 | ||
|
||
import data.regal.ast | ||
import data.regal.capabilities | ||
import data.regal.result | ||
|
||
# METADATA | ||
# description: Missing capability for `import rego.v1` | ||
# custom: | ||
# severity: warning | ||
notices contains result.notice(rego.metadata.chain()) if not capabilities.has_rego_v1_feature | ||
|
||
report contains violation if { | ||
not ast.imports_has_path(ast.imports, ["rego", "v1"]) | ||
|
||
violation := result.fail(rego.metadata.chain(), result.location(input["package"])) | ||
} |
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,37 @@ | ||
package regal.rules.imports["use-rego-v1_test"] | ||
|
||
import rego.v1 | ||
|
||
import data.regal.capabilities | ||
import data.regal.config | ||
import data.regal.rules.imports["use-rego-v1"] as rule | ||
|
||
test_fail_missing_rego_v1_import if { | ||
r := rule.report with input as regal.parse_module("policy.rego", `package policy | ||
import future.keywords | ||
foo if not bar | ||
`) | ||
with data.internal.combined_config as {"capabilities": capabilities.provided} | ||
r == {{ | ||
"category": "imports", | ||
"description": "Use `import rego.v1`", | ||
"related_resources": [{ | ||
"description": "documentation", | ||
"ref": config.docs.resolve_url("$baseUrl/$category/use-rego-v1", "imports"), | ||
}], | ||
"title": "use-rego-v1", | ||
"location": {"col": 1, "file": "policy.rego", "row": 1, "text": "package policy"}, | ||
"level": "error", | ||
}} | ||
} | ||
|
||
test_success_rego_v1_import if { | ||
r := rule.report with input as regal.parse_module("policy.rego", `package policy | ||
import rego.v1 | ||
foo if not bar | ||
`) | ||
with data.internal.combined_config as {"capabilities": capabilities.provided} | ||
r == set() | ||
} |
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
```rego | ||
package policy | ||
import future.keywords.if | ||
import rego.v1 | ||
allow if {} | ||
``` | ||
|
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.