feat(cve): implemented trivy image scan for multiarch images (#1510)

Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
This commit is contained in:
LaurentiuNiculae
2023-07-06 11:36:26 +03:00
committed by GitHub
parent 96d9d318df
commit 0a04b2a4ed
32 changed files with 1617 additions and 370 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ type Annotation struct {
Value string `json:"value"`
}
type FixedTags struct {
type ImageListWithCVEFixedResponse struct {
Errors []ErrorGQL `json:"errors"`
ImageListWithCVEFixed `json:"data"`
}
+21 -1
View File
@@ -4,6 +4,7 @@ import (
"strings"
"time"
"github.com/opencontainers/go-digest"
ispec "github.com/opencontainers/image-spec/specs-go/v1"
zerr "zotregistry.io/zot/errors"
@@ -101,7 +102,7 @@ func GetRepoRefference(repo string) (string, string, bool, error) {
repoName, tag, found := strings.Cut(repo, ":")
if !found {
return "", "", false, zerr.ErrInvalidRepoTagFormat
return "", "", false, zerr.ErrInvalidRepoRefFormat
}
return repoName, tag, true, nil
@@ -109,3 +110,22 @@ func GetRepoRefference(repo string) (string, string, bool, error) {
return repoName, digest, false, nil
}
// GetFullImageName returns the formated string for the given repo/tag or repo/digest.
func GetFullImageName(repo, ref string) string {
if IsTag(ref) {
return repo + ":" + ref
}
return repo + "@" + ref
}
func IsDigest(ref string) bool {
_, err := digest.Parse(ref)
return err == nil
}
func IsTag(ref string) bool {
return !IsDigest(ref)
}