mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
Merge pull request #2608 from reasonerjt/clair-integration
fix nil pointer in vulnerability/details api
This commit is contained in:
commit
6e0f274c07
@ -762,19 +762,23 @@ 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
|
||||||
}
|
}
|
||||||
clairClient := clair.NewClient(config.ClairEndpoint(), nil)
|
if overview != nil {
|
||||||
log.Debugf("The key for getting details: %s", overview.DetailsKey)
|
clairClient := clair.NewClient(config.ClairEndpoint(), nil)
|
||||||
details, err := clairClient.GetResult(overview.DetailsKey)
|
log.Debugf("The key for getting details: %s", overview.DetailsKey)
|
||||||
if err != nil {
|
details, err := clairClient.GetResult(overview.DetailsKey)
|
||||||
ra.HandleInternalServerError(fmt.Sprintf("Failed to get scan details from Clair, error: %v", err))
|
if err != nil {
|
||||||
return
|
ra.HandleInternalServerError(fmt.Sprintf("Failed to get scan details from Clair, error: %v", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
res = transformVulnerabilities(details)
|
||||||
}
|
}
|
||||||
ra.Data["json"] = transformVulnerabilities(details)
|
ra.Data["json"] = res
|
||||||
ra.ServeJSON()
|
ra.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user