mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 04:05:40 +01:00
fix nil pointer in vulnerability/details api
This commit is contained in:
parent
283792e7c3
commit
d31a25317e
@ -762,11 +762,13 @@ func (ra *RepositoryAPI) VulnerabilityDetails() {
|
|||||||
ra.HandleForbidden(ra.SecurityCtx.GetUsername())
|
ra.HandleForbidden(ra.SecurityCtx.GetUsername())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
res := []*models.VulnerabilityItem{}
|
||||||
overview, err := dao.GetImgScanOverview(digest)
|
overview, err := dao.GetImgScanOverview(digest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ra.HandleInternalServerError(fmt.Sprintf("failed to get the scan overview, error: %v", err))
|
ra.HandleInternalServerError(fmt.Sprintf("failed to get the scan overview, error: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if overview != nil {
|
||||||
clairClient := clair.NewClient(config.ClairEndpoint(), nil)
|
clairClient := clair.NewClient(config.ClairEndpoint(), nil)
|
||||||
log.Debugf("The key for getting details: %s", overview.DetailsKey)
|
log.Debugf("The key for getting details: %s", overview.DetailsKey)
|
||||||
details, err := clairClient.GetResult(overview.DetailsKey)
|
details, err := clairClient.GetResult(overview.DetailsKey)
|
||||||
@ -774,7 +776,9 @@ func (ra *RepositoryAPI) VulnerabilityDetails() {
|
|||||||
ra.HandleInternalServerError(fmt.Sprintf("Failed to get scan details from Clair, error: %v", err))
|
ra.HandleInternalServerError(fmt.Sprintf("Failed to get scan details from Clair, error: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ra.Data["json"] = transformVulnerabilities(details)
|
res = transformVulnerabilities(details)
|
||||||
|
}
|
||||||
|
ra.Data["json"] = res
|
||||||
ra.ServeJSON()
|
ra.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user