Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Example about aggregate rules seems not to work correctly #1259

Closed
shibataka000 opened this issue Nov 13, 2024 · 5 comments · Fixed by #1260
Closed

Example about aggregate rules seems not to work correctly #1259

shibataka000 opened this issue Nov 13, 2024 · 5 comments · Fixed by #1260
Labels
bug Something isn't working

Comments

@shibataka000
Copy link

Summary

Example about aggregate rules on https://docs.styra.com/regal/custom-rules#aggregate-rules seems not to work correctly.

Description

What happened?

I created a new repository https://github.com/shibataka000/regal-example and copied following custom rules on https://docs.styra.com/regal/custom-rules .

AFAIK, custom rule at-least-one-allow reports error if there is no rule whose name is allow and whose default value is false.

I ran following command.

regal lint .

Regal reports no error although there is no rule whose name is allow and whose default value is false.

What I expected to happen?

I expected that regal reports error about custom rule at-least-one-allow because there is no rule whose name is allow and whose default value is false.

How to reproduce the issue

git clone https://github.com/shibataka000/regal-example
cd regal-example/
regal lint .

Version

$ opa version
Version: 0.70.0
Build Commit: 2ea031ea04e6a8afbc5dd22f656131dc3cfc5a7d
Build Timestamp: 2024-10-31T19:39:52Z
Build Hostname: 799a5774bce7
Go Version: go1.23.1
Platform: linux/amd64
WebAssembly: available

$ regal version
Version:    0.29.0
Go Version: go1.22.5
Platform:   linux/amd64
Commit:     5cb67eaa310ece0a4c670390d95862f9d363c474
Timestamp:  2024-11-12T13:53:27Z
Hostname:   github.actions.local
@shibataka000
Copy link
Author

Please tell me why custom rule at-least-one-allow does not work correctly in my case if someone know.

@anderseknert
Copy link
Member

Hi there! And thanks for an excellent bug report 👍 I've cloned your repo and it does seem like there's an issue with custom aggregate rules. I'll report back as soon as I've found out what it could be.

@anderseknert anderseknert added the bug Something isn't working label Nov 13, 2024
anderseknert added a commit that referenced this issue Nov 13, 2024
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 <anders@styra.com>
@anderseknert
Copy link
Member

That was more involved than I imagined. The issue turned out to be isolated to rules where no aggregated data was the actual violation, like in the example. Rules that actually did aggregate something first would however work as expected. I have a fix up now, and will push a patch release when that's been approved and merged.

@anderseknert
Copy link
Member

Just pushed v0.29.1 to address this. Let me know if you encounter any issues!

@shibataka000
Copy link
Author

Thank you so much!

charlieegan3 pushed a commit to charlieegan3/regal that referenced this issue Jan 6, 2025
)

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 StyraInc#1259

Signed-off-by: Anders Eknert <anders@styra.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants