[go: nahoru, domu]

Skip to content

Commit

Permalink
No sbom_overview when sbom is deleted (#20533)
Browse files Browse the repository at this point in the history
fixes #20529

Signed-off-by: stonezdj <stone.zhang@broadcom.com>
  • Loading branch information
stonezdj committed Jun 3, 2024
1 parent 30767f6 commit 74f4a35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/server/v2.0/handler/assembler/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/server/v2.0/handler/assembler/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 74f4a35

Please sign in to comment.