-
Couldn't load subscription status.
- 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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| --pkg-types | ||
| --quiet | ||
| --redis-tls | ||
| --rego-error-limit | ||
| --removed-pkgs | ||
| --report | ||
| --scanners | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ type ScannerOption struct { | |
| DisableEmbeddedPolicies bool | ||
| DisableEmbeddedLibraries bool | ||
| IncludeDeprecatedChecks bool | ||
| RegoErrorLimit int | ||
|
|
||
| HelmValues []string | ||
| HelmValueFiles []string | ||
|
|
@@ -236,6 +237,10 @@ func initRegoOptions(opt ScannerOption) ([]options.ScannerOption, error) { | |
| rego.WithTrivyVersion(app.Version()), | ||
| } | ||
|
|
||
| if opt.RegoErrorLimit > 0 { | ||
| opts = append(opts, rego.WithRegoErrorLimits(opt.RegoErrorLimit)) | ||
| } | ||
|
Comment on lines
+240
to
+242
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Oh you mean the comparison should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's what I meant. |
||
|
|
||
| policyFS, policyPaths, err := CreatePolicyFS(opt.PolicyPaths) | ||
| if err != nil { | ||
| return nil, err | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.