mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
feat(cve): graphql: paginate returned CVEs for a given image (#1136)
Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
@@ -9,8 +9,9 @@ import (
|
||||
type CveInfoMock struct {
|
||||
GetImageListForCVEFn func(repo, cveID string) ([]common.TagInfo, error)
|
||||
GetImageListWithCVEFixedFn func(repo, cveID string) ([]common.TagInfo, error)
|
||||
GetCVEListForImageFn func(image string) (map[string]cvemodel.CVE, error)
|
||||
GetCVEListForImageFn func(image string, pageInput cveinfo.PageInput) ([]cvemodel.CVE, cveinfo.PageInfo, error)
|
||||
GetCVESummaryForImageFn func(image string) (cveinfo.ImageCVESummary, error)
|
||||
CompareSeveritiesFn func(severity1, severity2 string) int
|
||||
UpdateDBFn func() error
|
||||
}
|
||||
|
||||
@@ -30,12 +31,16 @@ func (cveInfo CveInfoMock) GetImageListWithCVEFixed(repo, cveID string) ([]commo
|
||||
return []common.TagInfo{}, nil
|
||||
}
|
||||
|
||||
func (cveInfo CveInfoMock) GetCVEListForImage(image string) (map[string]cvemodel.CVE, error) {
|
||||
func (cveInfo CveInfoMock) GetCVEListForImage(image string, pageInput cveinfo.PageInput) (
|
||||
[]cvemodel.CVE,
|
||||
cveinfo.PageInfo,
|
||||
error,
|
||||
) {
|
||||
if cveInfo.GetCVEListForImageFn != nil {
|
||||
return cveInfo.GetCVEListForImageFn(image)
|
||||
return cveInfo.GetCVEListForImageFn(image, pageInput)
|
||||
}
|
||||
|
||||
return map[string]cvemodel.CVE{}, nil
|
||||
return []cvemodel.CVE{}, cveinfo.PageInfo{}, nil
|
||||
}
|
||||
|
||||
func (cveInfo CveInfoMock) GetCVESummaryForImage(image string) (cveinfo.ImageCVESummary, error) {
|
||||
@@ -46,6 +51,14 @@ func (cveInfo CveInfoMock) GetCVESummaryForImage(image string) (cveinfo.ImageCVE
|
||||
return cveinfo.ImageCVESummary{}, nil
|
||||
}
|
||||
|
||||
func (cveInfo CveInfoMock) CompareSeverities(severity1, severity2 string) int {
|
||||
if cveInfo.CompareSeveritiesFn != nil {
|
||||
return cveInfo.CompareSeveritiesFn(severity1, severity2)
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (cveInfo CveInfoMock) UpdateDB() error {
|
||||
if cveInfo.UpdateDBFn != nil {
|
||||
return cveInfo.UpdateDBFn()
|
||||
|
||||
Reference in New Issue
Block a user