Unverified Commit 9f5f8e46 authored by He Weiwei's avatar He Weiwei Committed by GitHub
Browse files

Merge pull request #12077 from heww/fix-issue-11951

fix(cve-whitelist): fix panic in `Get` method of whitelist manager
parents 31a943bb 0d1b9c96
......@@ -63,14 +63,17 @@ func (d *defaultManager) Set(projectID int64, list models.CVEWhitelist) error {
// Get gets the whitelist for given project
func (d *defaultManager) Get(projectID int64) (*models.CVEWhitelist, error) {
wl, err := dao.GetCVEWhitelist(projectID)
if wl == nil && err == nil {
log.Debugf("No CVE whitelist found for project %d, returning empty list.", projectID)
return &models.CVEWhitelist{ProjectID: projectID, Items: []models.CVEWhitelistItem{}}, nil
if err != nil {
return nil, err
}
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{}
}
return wl, err
return wl, nil
}
// SetSys sets the system level whitelist
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment