-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Aggregates Collection and Usage (#323)
* Implement aggregates feature: #282 Co-authored-by: Sebastian Esponda <842946+sesponda@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
222 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package mypolicy1.public | ||
|
||
my_policy_1 := true |
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,3 @@ | ||
package mypolicy2.public | ||
|
||
export := [] |
20 changes: 20 additions & 0 deletions
20
e2e/testdata/aggregates/rules/custom_rules_using_aggregates.rego
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,20 @@ | ||
# METADATA | ||
# description: Collect data in aggregates and validate it | ||
package custom.regal.rules.testcase["aggregates"] | ||
|
||
import future.keywords | ||
import data.regal.result | ||
|
||
aggregate contains entry if { | ||
entry := { "file" : input.regal.file.name } | ||
} | ||
|
||
report contains violation if { | ||
not two_files_processed | ||
violation := result.fail(rego.metadata.chain(), {}) | ||
} | ||
|
||
two_files_processed { | ||
files := [x | x = input.aggregate[_].file] | ||
count(files) == 2 | ||
} |
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