Skip to content

Commit ffc92a4

Browse files
committed
put len check on parentCiArtifactIds in scan list
1 parent 2126f67 commit ffc92a4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pkg/policyGovernance/security/imageScanning/ImageScanService.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -779,14 +779,16 @@ func (impl ImageScanServiceImpl) fetchLatestArtifactMetadataDeployedOnAllEnvsAcr
779779
}
780780
appEnvToCiArtifactMap[bean3.NewAppEnvMetadata(item.AppId, item.EnvId)] = ciArtifactId
781781
}
782-
parentCiArtifacts, err := impl.ciArtifactRepository.GetByIds(parentCiArtifactIds)
783-
if err != nil {
784-
impl.Logger.Errorw("error in getting artifacts by ids", "ids", parentCiArtifactIds, "err", err)
785-
return nil, nil, err
786-
}
787-
for _, parentCiArtifact := range parentCiArtifacts {
788-
// for linked ci case
789-
ciArtifactIdToScannedMap[parentCiArtifact.Id] = parentCiArtifact.Scanned
782+
if len(parentCiArtifactIds) > 0 {
783+
parentCiArtifacts, err := impl.ciArtifactRepository.GetByIds(parentCiArtifactIds)
784+
if err != nil {
785+
impl.Logger.Errorw("error in getting artifacts by ids", "ids", parentCiArtifactIds, "err", err)
786+
return nil, nil, err
787+
}
788+
for _, parentCiArtifact := range parentCiArtifacts {
789+
// for linked ci case
790+
ciArtifactIdToScannedMap[parentCiArtifact.Id] = parentCiArtifact.Scanned
791+
}
790792
}
791793
return appEnvToCiArtifactMap, ciArtifactIdToScannedMap, nil
792794
}

0 commit comments

Comments
 (0)