-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix custom rules that report on the absence of aggregates (#1260)
While custom aggregate rules would largely work before, those that report on the absence of data (like a rule named "allow") did not work. This as the aggregator sent nothing back in those caes — and contrary to the built-in rules, Regal had then no way of knowing in the next step that the aggregate report rules should be called even with no data. I'm not super happy about the way we communicate this back to the Go side, but there's a lot I'm not happy about with regards to how aggregate data is shuffled back and forth. Some effort to fix that will however have to wait until later. Fixes #1259 Signed-off-by: Anders Eknert <[email protected]>
- Loading branch information
1 parent
0c6e8ed
commit 743a65b
Showing
4 changed files
with
77 additions
and
3 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
21 changes: 21 additions & 0 deletions
21
e2e/testdata/aggregates/custom/regal/rules/testcase/empty_aggregate/empty_aggregate.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,21 @@ | ||
# METADATA | ||
# description: | | ||
# Test to ensure a custom rule that aggregated no data is still reported | ||
# related_resources: | ||
# - description: issue | ||
# ref: https://github.com/StyraInc/regal/issues/1259 | ||
package custom.regal.rules.testcase.empty_aggregates | ||
|
||
import rego.v1 | ||
|
||
import data.regal.result | ||
|
||
aggregate contains result.aggregate(rego.metadata.chain(), {}) if { | ||
input.nope | ||
} | ||
|
||
aggregate_report contains violation if { | ||
count(input.aggregate) == 0 | ||
|
||
violation := result.fail(rego.metadata.chain(), {}) | ||
} |
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