trivy-operator
trivy-operator copied to clipboard
fix: When getting pod spec for a scan job correctly check presence of reused reports before adding LabelReusedReport label
Description
This PR fixes an issue in the logic that determines when to add LabelReusedReport label to a scan job PodSpec. Previously, the code only checked whether the number of reused reports was greater than 0. This caused issues when the workload was composed of several images and at least one of the images had a corresponding ClusterSbomReport; if one of the remaining images did not have a corresponding ClusterSbomReport, the label was being wrongly added, causing sbom reports to not written to the kubernetes API.
The label's existence is later checked here.
I have tested this change in my environment and it seemed to fix the related issue.
Related issues
- Close #2812
Checklist
- [X] I've read the guidelines for contributing to this repository.
- [ ] I've added tests that prove my fix is effective or that my feature works.
- [X] I've updated the documentation with the relevant information (if needed).
- [X] I've added usage information (if the PR introduces new options)
- [X] I've included a "before" and "after" example to the description (if the PR is a user interface change).