mirror of
https://github.com/goharbor/harbor
synced 2025-04-22 12:49:51 +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) {
|
func (c *controller) SecuritySummary(ctx context.Context, projectID int64, options ...Option) (*secHubModel.Summary, error) {
|
||||||
opts := newOptions(options...)
|
opts := newOptions(options...)
|
||||||
scannerUUID, err := c.scannerMgr.DefaultScannerUUID(ctx)
|
scannerUUID, err := c.scannerMgr.DefaultScannerUUID(ctx)
|
||||||
if err != nil {
|
if len(scannerUUID) == 0 || err != nil {
|
||||||
return nil, err
|
return &secHubModel.Summary{}, nil
|
||||||
}
|
}
|
||||||
sum, err := c.secHubMgr.Summary(ctx, scannerUUID, projectID, nil)
|
sum, err := c.secHubMgr.Summary(ctx, scannerUUID, projectID, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -152,5 +152,8 @@ func (bm *basicManager) DefaultScannerUUID(ctx context.Context) (string, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
if reg == nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
return reg.UUID, nil
|
return reg.UUID, nil
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,8 @@ func (s *securityAPI) ListVulnerabilities(ctx context.Context, params securityMo
|
|||||||
return s.SendError(ctx, err)
|
return s.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
scannerUUID, err := scanner.Mgr.DefaultScannerUUID(ctx)
|
scannerUUID, err := scanner.Mgr.DefaultScannerUUID(ctx)
|
||||||
if err != nil {
|
if err != nil || len(scannerUUID) == 0 {
|
||||||
return s.SendError(ctx, err)
|
return securityModel.NewListVulnerabilitiesOK().WithPayload([]*models.VulnerabilityItem{}).WithXTotalCount(0)
|
||||||
}
|
}
|
||||||
cnt, err := s.controller.CountVuls(ctx, scannerUUID, 0, *params.TuneCount, query)
|
cnt, err := s.controller.CountVuls(ctx, scannerUUID, 0, *params.TuneCount, query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user