Security MR widget shows incorrect image name when `CS_DEFAULT_BRANCH_IMAGE` is set
Summary
In Container Scanning(CS) when CS_IMAGE and CS_DEFAULT_BRANCH_IMAGE are configured, in the MR's vulnerability(vuln) widget, the finding location references the CS_DEFAULT_BRANCH_IMAGE when it should reference the CS_IMAGE since it is where the vuln is detected.
Context of how CS_DEFAULT_BRANCH_IMAGE logic works
Steps to reproduce
- Start a CS with
CS_IMAGE=peerflix-alpine:latestfor thedefault branchiemain - Dismiss all vulnerabilities
- Create an MR with
CS_IMAGE=latex-alpine:latestandCS_DEFAULT_BRANCH_IMAGE=peerflix-alpine:latest- Note that in the vuln widget, vuln location is
peerflix-alpine:latestwhen it was actually detected inlatex-alpine:latest
- Note that in the vuln widget, vuln location is
- Created another MR with
CS_IMAGE=latex-alpine:latestandCS_DEFAULT_BRANCH_IMAGEis not set.- Note that in the vuln widget, vuln location is
latex-alpine:latestwhich is where the vuln is actually detected.
- Note that in the vuln widget, vuln location is
Example Project
https://gitlab.com/gitlab-org/secure/tests/smtan-subgroup/test-cs-default-branch-image
What is the current bug behavior?
MR's vuln widget is displaying vuln location as CS_DEFAULT_BRANCH_IMAGE
What is the expected correct behavior?
MR's vuln widget should display vuln location as CS_IMAGE
Relevant logs and/or screenshots
Screenshot taken from the example project's MR
CS_IMAGE=latex-alpineCS_DEFAULT_BRANCH_IMAGE=peerflix-alpine- Currently vuln image location is
peerflix-alpine - Expected vuln image location to be
latex-alpine
Possible fixes
Referenced from this comment:
I think the issue is when we construct the
finding_nameinGitlab::Ci::Parsers::Security::Commonwherelocation.fingerprint_pathinGitlab::Ci::Reports::Security::Locations::ContainerScanningusesdefault_branch_image. We can fix this by taking theimageinstead ofdefault_branch_imagewhen constructingfinding_namefor container scanning reports.🤔
