Skip to content

Conversation

@festeveira
Copy link

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

Checklist

  • 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.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Signed-off-by: festeveira <f.esteveira@hotmail.com>
…slice

Signed-off-by: festeveira <f.esteveira@hotmail.com>
@festeveira festeveira requested a review from simar7 as a code owner November 21, 2025 02:59
@github-actions github-actions bot added the bug label Nov 21, 2025
@festeveira festeveira changed the title fix: correctly create volumeMounts for each container in GetPodSpec* fix: correctly create volumeMounts for each container in GetPodSpec* functions Nov 21, 2025
@festeveira festeveira changed the title fix: correctly create volumeMounts for each container in GetPodSpec* functions fix: Correctly create volumeMounts for each container in GetPodSpec* functions Nov 21, 2025
daanschipper added a commit to daanschipper/trivy-operator that referenced this pull request Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No vulnerability scan jobs being created due to duplicate volume mounts

1 participant