mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-02 15:14:09 +01:00
fix(cve-whitelist): fix panic in Get
method of whitelist manager
Closes #11951 Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
parent
7bf9888b34
commit
006f9d321a
@ -63,14 +63,17 @@ func (d *defaultManager) Set(projectID int64, list models.CVEWhitelist) error {
|
|||||||
// Get gets the whitelist for given project
|
// Get gets the whitelist for given project
|
||||||
func (d *defaultManager) Get(projectID int64) (*models.CVEWhitelist, error) {
|
func (d *defaultManager) Get(projectID int64) (*models.CVEWhitelist, error) {
|
||||||
wl, err := dao.GetCVEWhitelist(projectID)
|
wl, err := dao.GetCVEWhitelist(projectID)
|
||||||
if wl == nil && err == nil {
|
if err != nil {
|
||||||
log.Debugf("No CVE whitelist found for project %d, returning empty list.", projectID)
|
return nil, err
|
||||||
return &models.CVEWhitelist{ProjectID: projectID, Items: []models.CVEWhitelistItem{}}, nil
|
|
||||||
}
|
}
|
||||||
if wl.Items == nil {
|
|
||||||
|
if wl == nil {
|
||||||
|
log.Debugf("No CVE whitelist found for project %d, returning empty list.", projectID)
|
||||||
|
wl = &models.CVEWhitelist{ProjectID: projectID, Items: []models.CVEWhitelistItem{}}
|
||||||
|
} else if wl.Items == nil {
|
||||||
wl.Items = []models.CVEWhitelistItem{}
|
wl.Items = []models.CVEWhitelistItem{}
|
||||||
}
|
}
|
||||||
return wl, err
|
return wl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSys sets the system level whitelist
|
// SetSys sets the system level whitelist
|
||||||
|
Loading…
Reference in New Issue
Block a user