Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rule: if-object-literal #822

Closed
anderseknert opened this issue Jun 10, 2024 · 1 comment · Fixed by #835
Closed

Rule: if-object-literal #822

anderseknert opened this issue Jun 10, 2024 · 1 comment · Fixed by #835

Comments

@anderseknert
Copy link
Member

Came across this old issue in the OPA backlog: open-policy-agent/opa#5294
And since that's unlikely to be fixed in OPA, we should at least make sure Regal flags it.

package policy

import rego.v1

allow if {input.message: "world"}

Note that we currently have the if-empty-object rule to cover the case OPA previously would fail for being an empty rule body.. but doesn't do anymore. While we could retrofit that rule to cover any object following an if, we'd have to do so much work around the docs, redirects and whatnot, that it's probably a better option to add a new rule that checks for if followed by a non-empty object.

Question is if there is ever a valid if { ..object.. } case? I can't think of one now, but happy to be proven wrong.

@anderseknert anderseknert changed the title Rule: if-object Rule: if-object-literal Jun 11, 2024
@anderseknert
Copy link
Member Author

Here's how we can do it: add the new if-object-literal rule, and when we do, keep the if-empty-object rule around but make it disabled by default + update its docs to say that it's been replaced by if-object-literal. But if people have enabled it manually in configuration, it'll keep working as before.

anderseknert added a commit that referenced this issue Jun 13, 2024
This replaces `if-empty-object`, and covers any object literal.

Fixes #822

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Jun 13, 2024
This replaces `if-empty-object`, and covers any object literal.

Fixes #822

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Jun 13, 2024
This replaces `if-empty-object`, and covers any object literal.

Fixes #822

Signed-off-by: Anders Eknert <anders@styra.com>
srenatus pushed a commit to srenatus/regal that referenced this issue Oct 1, 2024
This replaces `if-empty-object`, and covers any object literal.

Fixes StyraInc#822

Signed-off-by: Anders Eknert <anders@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant