No sbom_overview when sbom is deleted (#20533)

fixes #20529

Signed-off-by: stonezdj <stone.zhang@broadcom.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2024-06-03 13:38:30 +08:00 committed by GitHub
parent 30767f6612
commit 74f4a358f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -97,6 +97,10 @@ func (assembler *ScanReportAssembler) Assemble(ctx context.Context) error {
log.Warningf("get scan summary of artifact %s@%s for %s failed, error:%v", artifact.RepositoryName, artifact.Digest, v1.MimeTypeSBOMReport, err)
}
if len(overview) == 0 {
// only fetch the sbom overview from execution when the overview is empty and the artifact has child references ( image index, cnab etc)
if len(artifact.References) == 0 {
continue
}
log.Warningf("overview is empty, retrieve sbom status from execution")
// Get latest execution with digest, repository, and scan type is sbom, the status is the scan status
query := q.New(

View File

@ -128,7 +128,7 @@ func (suite *VulAssemblerTestSuite) TestAssembleSBOMOverviewImageIndex() {
var artifact model.Artifact
err := assembler.WithArtifacts(&artifact).Assemble(context.TODO())
suite.Nil(err)
suite.Equal(artifact.SBOMOverView["scan_status"], "Error")
suite.Nil(artifact.SBOMOverView["scan_status"])
mock.OnAnything(exeMgr, "List").Return(nil, nil).Once()
var artifact2 model.Artifact