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

Add flag to set the maximum error behavior regardless of findings level #1403

Open
jalseth opened this issue Feb 9, 2025 · 5 comments
Open
Labels
good first issue Good for newcomers tooling

Comments

@jalseth
Copy link

jalseth commented Feb 9, 2025

I'd like a flag that lets me set the maximum error behavior, eg treat all errors found as warnings and exit with status code 0. This makes it easier to slowly improve a repo's Rego policies over time without requiring 100% up front effort.

Intended use scenario is to run Regal twice per PR, once in warning-only mode with all checks enabled, once in normal mode with only certain categories enabled. For example:

$ regal lint --warn-only --format github <policy_dir>
$ regal lint --disable-all --enable-category bugs --format github <policy_dir>

Over time, more categories would be treated as blocking rather than warnings.

@anderseknert
Copy link
Member

Huh, that's a surprise. I guess we never really used that ourselves. I'll have that fixed.

@anderseknert
Copy link
Member

Or wait, no. The --fail-level flag

set level at which to fail with a non-zero exit code (error, warning) (default "error")

So setting it to warning means "treat warnings as errors". If you want warnings to be treated as warnings and not impact the exit code, just leave it at the default error level. Or am I missing something? :)

@jalseth
Copy link
Author

jalseth commented Feb 9, 2025

Oh, I misunderstood the flag then. I was looking for a flag for "set the maximum error level to warning" without having to maintain a YAML for all of the rules, manually setting them to warning instead of error.

Let's change this to a FR then.

@jalseth jalseth changed the title Exit code is non-zero even with fail-level set to warning Add flag to set the maximum error behavior regardless of findings level Feb 9, 2025
@anderseknert
Copy link
Member

anderseknert commented Feb 9, 2025

You can set the default level to warning to achieve something like that, I think:

rules:
  default:
    level: warning
$ regal lint --format github <policy_dir>
$ regal lint --fail-level warning --disable-all --enable-category bugs --format github <policy_dir>

I'm not opposed to having a flag toggle the default setting outside of conf though.

@jalseth
Copy link
Author

jalseth commented Feb 9, 2025

That is simple enough, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers tooling
Projects
None yet
Development

No branches or pull requests

2 participants