trivy-operator icon indicating copy to clipboard operation
trivy-operator copied to clipboard

fix: Correctly create volumeMounts for each container in GetPodSpec* functions

Open festeveira opened this issue 3 months ago • 0 comments

Description

This PR resolves an issue in the GetPodSpec* functions of the Trivy plugin where initContainers and containers unintentionally share the same underlying volumeMounts slice. Because the slice reference is reused across multiple containers, modifications made for one container can bleed into others. As a result, some containers end up with duplicate customVolumesMount, which blocks jobs from being created or SBOM-related mounts that should not apply to them.

The fix ensures that each initContainer and container receives its own properly constructed volumeMounts slice, preventing cross-contamination and producing accurate, container-specific configurations.

I have tested this change in my environment and it seemed to fix the related issue.

Related issues

  • Close #2818

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).

festeveira avatar Nov 21 '25 02:11 festeveira