-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(misconf): Add support for configurable Rego error limit #9657
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
base: main
Are you sure you want to change the base?
Conversation
| ConfigName: "rego.error-limit", | ||
| Usage: "maximum number of compile errors allowed during Rego policy evaluation", | ||
| TelemetrySafe: true, | ||
| Default: ast.CompileErrorLimitDefault, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikpivkin Should we set this to a high amount? Default is 10 by OPA. Some thoughts below.
Pros: If we set this to a higher amount most users won't need to change anything in case they are using a older trivy version with a newer checks bundle.
Cons: It will silently hide any errors and may have unforeseen side effects post compilation. We do remove uncompilable checks prior to evaluation but since we are overriding the compilation to go through without any error limits, we may end up in an unexpected state.
It will also let users use older versions for a longer period of time by simply them not noticing any breakage due to a higher allowable error limit. This may make them comfortable using older trivy versions for even longer as they may have no desire to update, for instance to get new checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting it to 10 seems fine — it preserves OPA’s default behavior, avoids silently hiding too many errors, and reduces the risk of unforeseen issues while still being reasonable for most users.
@knqyf263 @DmitriyLewen is this correct? My PR involves no changes related to the changes that are mentioned in this comment. |
Sorry I missed it. I deleted the apidiff comments for now. After rebasing the main branch and pushing again, it should be correctly detected. |
| if opt.RegoErrorLimit > 0 { | ||
| opts = append(opts, rego.WithRegoErrorLimits(opt.RegoErrorLimit)) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to allow setting an error limit equal to 0 for strictness?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you mean the comparison should be >=0 if no errors are allowable? If so, I think that's a fair point and I can change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I meant.
|
I think we should add an integration test for this. |
Description
feat(misconf): Add support for configurable Rego error limit
Checklist