Merge pull request #8948 from reasonerjt/empty-project-cve-item-list

The default item list should be empty list,not null
This commit is contained in:
stonezdj(Daojun Zhang) 2019-09-04 18:49:45 +08:00 committed by GitHub
commit 09bb364b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,7 @@ type defaultManager struct{}
func (d *defaultManager) CreateEmpty(projectID int64) error {
l := models.CVEWhitelist{
ProjectID: projectID,
Items: []models.CVEWhitelistItem{},
}
_, err := dao.CreateCVEWhitelist(l)
if err != nil {
@ -66,6 +67,9 @@ func (d *defaultManager) Get(projectID int64) (*models.CVEWhitelist, error) {
log.Debugf("No CVE whitelist found for project %d, returning empty list.", projectID)
return &models.CVEWhitelist{ProjectID: projectID, Items: []models.CVEWhitelistItem{}}, nil
}
if wl.Items == nil {
wl.Items = []models.CVEWhitelistItem{}
}
return wl, err
}