mirror of
https://github.com/goharbor/harbor
synced 2025-04-16 17:18:58 +00:00
Return empty result when no scanner configured (#19577)
fixes #19534 Signed-off-by: stonezdj <daojunz@vmware.com>
This commit is contained in:
parent
08cb0803a8
commit
307a3121aa
|
@ -86,8 +86,8 @@ func NewController() Controller {
|
|||
func (c *controller) SecuritySummary(ctx context.Context, projectID int64, options ...Option) (*secHubModel.Summary, error) {
|
||||
opts := newOptions(options...)
|
||||
scannerUUID, err := c.scannerMgr.DefaultScannerUUID(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if len(scannerUUID) == 0 || err != nil {
|
||||
return &secHubModel.Summary{}, nil
|
||||
}
|
||||
sum, err := c.secHubMgr.Summary(ctx, scannerUUID, projectID, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -152,5 +152,8 @@ func (bm *basicManager) DefaultScannerUUID(ctx context.Context) (string, error)
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if reg == nil {
|
||||
return "", nil
|
||||
}
|
||||
return reg.UUID, nil
|
||||
}
|
||||
|
|
|
@ -108,8 +108,8 @@ func (s *securityAPI) ListVulnerabilities(ctx context.Context, params securityMo
|
|||
return s.SendError(ctx, err)
|
||||
}
|
||||
scannerUUID, err := scanner.Mgr.DefaultScannerUUID(ctx)
|
||||
if err != nil {
|
||||
return s.SendError(ctx, err)
|
||||
if err != nil || len(scannerUUID) == 0 {
|
||||
return securityModel.NewListVulnerabilitiesOK().WithPayload([]*models.VulnerabilityItem{}).WithXTotalCount(0)
|
||||
}
|
||||
cnt, err := s.controller.CountVuls(ctx, scannerUUID, 0, *params.TuneCount, query)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user