mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-23 15:37:50 -08:00
chore: add prefix to image errors (#5601)
Signed-off-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
@@ -20,9 +20,9 @@ import (
|
||||
// Standalone
|
||||
//////////////
|
||||
|
||||
// initializeDockerScanner is for container image scanning in standalone mode
|
||||
// initializeImageScanner is for container image scanning in standalone mode
|
||||
// e.g. dockerd, container registry, podman, etc.
|
||||
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache,
|
||||
func initializeImageScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache,
|
||||
localArtifactCache cache.LocalArtifactCache, imageOpt types.ImageOptions, artifactOption artifact.Option) (
|
||||
scanner.Scanner, func(), error) {
|
||||
wire.Build(scanner.StandaloneDockerSet)
|
||||
@@ -67,9 +67,9 @@ func initializeVMScanner(ctx context.Context, filePath string, artifactCache cac
|
||||
// Client/Server
|
||||
/////////////////
|
||||
|
||||
// initializeRemoteDockerScanner is for container image scanning in client/server mode
|
||||
// initializeRemoteImageScanner is for container image scanning in client/server mode
|
||||
// e.g. dockerd, container registry, podman, etc.
|
||||
func initializeRemoteDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache,
|
||||
func initializeRemoteImageScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache,
|
||||
remoteScanOptions client.ScannerOption, imageOpt types.ImageOptions, artifactOption artifact.Option) (
|
||||
scanner.Scanner, func(), error) {
|
||||
wire.Build(scanner.RemoteDockerSet)
|
||||
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
// imageStandaloneScanner initializes a container image scanner in standalone mode
|
||||
// $ trivy image alpine:3.15
|
||||
func imageStandaloneScanner(ctx context.Context, conf ScannerConfig) (scanner.Scanner, func(), error) {
|
||||
s, cleanup, err := initializeDockerScanner(ctx, conf.Target, conf.ArtifactCache, conf.LocalArtifactCache,
|
||||
s, cleanup, err := initializeImageScanner(ctx, conf.Target, conf.ArtifactCache, conf.LocalArtifactCache,
|
||||
conf.ArtifactOption.ImageOption, conf.ArtifactOption)
|
||||
if err != nil {
|
||||
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize a docker scanner: %w", err)
|
||||
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize an image scanner: %w", err)
|
||||
}
|
||||
return s, cleanup, nil
|
||||
}
|
||||
@@ -34,10 +34,10 @@ func archiveStandaloneScanner(ctx context.Context, conf ScannerConfig) (scanner.
|
||||
// $ trivy image --server localhost:4954 alpine:3.15
|
||||
func imageRemoteScanner(ctx context.Context, conf ScannerConfig) (
|
||||
scanner.Scanner, func(), error) {
|
||||
s, cleanup, err := initializeRemoteDockerScanner(ctx, conf.Target, conf.ArtifactCache, conf.ServerOption,
|
||||
s, cleanup, err := initializeRemoteImageScanner(ctx, conf.Target, conf.ArtifactCache, conf.ServerOption,
|
||||
conf.ArtifactOption.ImageOption, conf.ArtifactOption)
|
||||
if err != nil {
|
||||
return scanner.Scanner{}, nil, xerrors.Errorf("unable to initialize the remote docker scanner: %w", err)
|
||||
return scanner.Scanner{}, nil, xerrors.Errorf("unable to initialize a remote image scanner: %w", err)
|
||||
}
|
||||
return s, cleanup, nil
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ import (
|
||||
|
||||
// Injectors from inject.go:
|
||||
|
||||
// initializeDockerScanner is for container image scanning in standalone mode
|
||||
// initializeImageScanner is for container image scanning in standalone mode
|
||||
// e.g. dockerd, container registry, podman, etc.
|
||||
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache, imageOpt types.ImageOptions, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
|
||||
func initializeImageScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache, imageOpt types.ImageOptions, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
|
||||
applierApplier := applier.NewApplier(localArtifactCache)
|
||||
ospkgScanner := ospkg.NewScanner()
|
||||
langpkgScanner := langpkg.NewScanner()
|
||||
@@ -140,9 +140,9 @@ func initializeVMScanner(ctx context.Context, filePath string, artifactCache cac
|
||||
}, nil
|
||||
}
|
||||
|
||||
// initializeRemoteDockerScanner is for container image scanning in client/server mode
|
||||
// initializeRemoteImageScanner is for container image scanning in client/server mode
|
||||
// e.g. dockerd, container registry, podman, etc.
|
||||
func initializeRemoteDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, remoteScanOptions client.ScannerOption, imageOpt types.ImageOptions, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
|
||||
func initializeRemoteImageScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, remoteScanOptions client.ScannerOption, imageOpt types.ImageOptions, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
|
||||
v := _wireValue
|
||||
clientScanner := client.NewScanner(remoteScanOptions, v...)
|
||||
typesImage, cleanup, err := image.NewContainerImage(ctx, imageName, imageOpt)
|
||||
|
||||
@@ -2,6 +2,7 @@ package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/google/go-containerregistry/pkg/name"
|
||||
@@ -50,6 +51,7 @@ func NewContainerImage(ctx context.Context, imageName string, opt types.ImageOpt
|
||||
// Return v1.Image if the image is found
|
||||
return img, cleanup, nil
|
||||
}
|
||||
err = multierror.Prefix(err, fmt.Sprintf("%s error:", src))
|
||||
errs = multierror.Append(errs, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user