-
Notifications
You must be signed in to change notification settings - Fork 259
feat: allow to remove fields from vulnerability reports and omit empty fields #2854
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
be96b31 to
9251aa4
Compare
|
Hi @sathieu |
9251aa4 to
25fc308
Compare
pkg/plugins/trivy/config.go
Outdated
| value := !strings.HasPrefix(field, "-") | ||
| field = strings.TrimPrefix(field, "-") |
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.
i think we should run strings.TrimSpace before these calls to support a case -PublishedDate.
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.
also it'd be great to have a test for this case.
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.
Added strings.TrimSpace before removing prefix, with various tests: " -Resource,- InstalledVersion, - FixedVersion, - PublishedDate,[...]"
pkg/plugins/trivy/config_test.go
Outdated
| FixedVersion: true, | ||
| PublishedDate: true, | ||
| LastModifiedDate: true, | ||
| Severity: true, |
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.
there is a concern about Severity. it may affect on Summary.
so I suggest don't allow to exclude it. because I don't know a case when we need to exclude Severity. may be I miss something
WDYT?
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.
Severity is now always kept (also in CRD, no omitempty).
pkg/vulnerabilityreport/io.go
Outdated
| Title bool | ||
| PrimaryLink bool | ||
| Score bool | ||
| PURL bool |
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.
about PURL.
It seems PURL is too common name, because actually we can manage PkgPURL only, can't we?
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.
Changed to PkgPURL. Thanks
|
@sathieu Thank you very much for your effort and for submitting this PR — it’s greatly appreciated. I’ve left a few inline comments to discuss some ideas. I also have a small concern regarding backward compatibility. In particular, clients that previously relied on the presence of certain fields (even when they were empty) now need to be prepared for those fields to be omitted entirely. Specifically, the handling of nil vs empty slices has changed: This is likely not a critical issue, but it would be good to get feedback from the community and confirm that this change won’t cause unexpected behavior for existing consumers. |
25fc308 to
caa0cb0
Compare
sathieu
left a comment
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.
pkg/plugins/trivy/config.go
Outdated
| value := !strings.HasPrefix(field, "-") | ||
| field = strings.TrimPrefix(field, "-") |
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.
Added strings.TrimSpace before removing prefix, with various tests: " -Resource,- InstalledVersion, - FixedVersion, - PublishedDate,[...]"
pkg/plugins/trivy/config_test.go
Outdated
| FixedVersion: true, | ||
| PublishedDate: true, | ||
| LastModifiedDate: true, | ||
| Severity: true, |
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.
Severity is now always kept (also in CRD, no omitempty).
pkg/vulnerabilityreport/io.go
Outdated
| Title bool | ||
| PrimaryLink bool | ||
| Score bool | ||
| PURL bool |
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.
Changed to PkgPURL. Thanks
caa0cb0 to
8da4c79
Compare
Description
I propose two changes to limit the problems of etcd max size reached (#757):
Before:
After first commit (and
trivy.additionalVulnerabilityReportFields=-Resource,-InstalledVersion,-FixedVersion,-PublishedDate,-LastModifiedDate,-Title,-PrimaryLink,-Score,-PURL):After both commits (and
trivy.additionalVulnerabilityReportFields=-<same>):Notes:
Related issues
Checklist