refactor: rename scanner to service (#8584)

This commit is contained in:
Teppei Fukuda
2025-03-24 03:47:03 +04:00
committed by GitHub
parent de7eb13938
commit c80310d769
46 changed files with 357 additions and 343 deletions

View File

@@ -12,97 +12,100 @@ import (
"github.com/aquasecurity/trivy/pkg/fanal/artifact"
"github.com/aquasecurity/trivy/pkg/fanal/types"
"github.com/aquasecurity/trivy/pkg/rpc/client"
"github.com/aquasecurity/trivy/pkg/scanner"
"github.com/aquasecurity/trivy/pkg/scan"
)
//////////////
// Standalone
//////////////
// initializeImageScanner is for container image scanning in standalone mode
// initializeImageScanService is for container image scanning in standalone mode
// e.g. dockerd, container registry, podman, etc.
func initializeImageScanner(ctx context.Context, imageName string, imageOpt types.ImageOptions, cacheOptions cache.Options, artifactOption artifact.Option) (
scanner.Scanner, func(), error) {
wire.Build(scanner.StandaloneDockerSet)
return scanner.Scanner{}, nil, nil
func initializeImageScanService(ctx context.Context, imageName string, imageOpt types.ImageOptions, cacheOptions cache.Options, artifactOption artifact.Option) (
scan.Service, func(), error) {
wire.Build(scan.StandaloneDockerSet)
return scan.Service{}, nil, nil
}
// initializeArchiveScanner is for container image archive scanning in standalone mode
// initializeArchiveScanService is for container image archive scanning in standalone mode
// e.g. docker save -o alpine.tar alpine:3.15
func initializeArchiveScanner(ctx context.Context, filePath string, cacheOptions cache.Options, artifactOption artifact.Option) (
scanner.Scanner, func(), error) {
wire.Build(scanner.StandaloneArchiveSet)
return scanner.Scanner{}, nil, nil
func initializeArchiveScanService(ctx context.Context, filePath string, cacheOptions cache.Options, artifactOption artifact.Option) (
scan.Service, func(), error) {
wire.Build(scan.StandaloneArchiveSet)
return scan.Service{}, nil, nil
}
// initializeFilesystemScanner is for filesystem scanning in standalone mode
func initializeFilesystemScanner(ctx context.Context, path string, cacheOptions cache.Options, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
wire.Build(scanner.StandaloneFilesystemSet)
return scanner.Scanner{}, nil, nil
// initializeFilesystemScanService is for filesystem scanning in standalone mode
func initializeFilesystemScanService(ctx context.Context, path string, cacheOptions cache.Options, artifactOption artifact.Option) (scan.Service, func(), error) {
wire.Build(scan.StandaloneFilesystemSet)
return scan.Service{}, nil, nil
}
func initializeRepositoryScanner(ctx context.Context, url string, cacheOptions cache.Options, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
wire.Build(scanner.StandaloneRepositorySet)
return scanner.Scanner{}, nil, nil
// initializeRepositoryScanService is for repository scanning in standalone mode
func initializeRepositoryScanService(ctx context.Context, url string, cacheOptions cache.Options, artifactOption artifact.Option) (scan.Service, func(), error) {
wire.Build(scan.StandaloneRepositorySet)
return scan.Service{}, nil, nil
}
func initializeSBOMScanner(ctx context.Context, filePath string, cacheOptions cache.Options, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
wire.Build(scanner.StandaloneSBOMSet)
return scanner.Scanner{}, nil, nil
// initializeSBOMScanService is for sbom scanning in standalone mode
func initializeSBOMScanService(ctx context.Context, filePath string, cacheOptions cache.Options, artifactOption artifact.Option) (scan.Service, func(), error) {
wire.Build(scan.StandaloneSBOMSet)
return scan.Service{}, nil, nil
}
func initializeVMScanner(ctx context.Context, filePath string, cacheOptions cache.Options, artifactOption artifact.Option) (
scanner.Scanner, func(), error) {
wire.Build(scanner.StandaloneVMSet)
return scanner.Scanner{}, nil, nil
// initializeVMScanService is for vm scanning in standalone mode
func initializeVMScanService(ctx context.Context, filePath string, cacheOptions cache.Options, artifactOption artifact.Option) (
scan.Service, func(), error) {
wire.Build(scan.StandaloneVMSet)
return scan.Service{}, nil, nil
}
/////////////////
// Client/Server
/////////////////
// initializeRemoteImageScanner is for container image scanning in client/server mode
// initializeRemoteImageScanService is for container image scanning in client/server mode
// e.g. dockerd, container registry, podman, etc.
func initializeRemoteImageScanner(ctx context.Context, imageName string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ScannerOption, imageOpt types.ImageOptions, artifactOption artifact.Option) (
scanner.Scanner, func(), error) {
wire.Build(scanner.RemoteDockerSet)
return scanner.Scanner{}, nil, nil
func initializeRemoteImageScanService(ctx context.Context, imageName string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ServiceOption, imageOpt types.ImageOptions, artifactOption artifact.Option) (
scan.Service, func(), error) {
wire.Build(scan.RemoteDockerSet)
return scan.Service{}, nil, nil
}
// initializeRemoteArchiveScanner is for container image archive scanning in client/server mode
// initializeRemoteArchiveScanService is for container image archive scanning in client/server mode
// e.g. docker save -o alpine.tar alpine:3.15
func initializeRemoteArchiveScanner(ctx context.Context, filePath string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ScannerOption, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
wire.Build(scanner.RemoteArchiveSet)
return scanner.Scanner{}, nil, nil
func initializeRemoteArchiveScanService(ctx context.Context, filePath string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ServiceOption, artifactOption artifact.Option) (scan.Service, func(), error) {
wire.Build(scan.RemoteArchiveSet)
return scan.Service{}, nil, nil
}
// initializeRemoteFilesystemScanner is for filesystem scanning in client/server mode
func initializeRemoteFilesystemScanner(ctx context.Context, path string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ScannerOption, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
wire.Build(scanner.RemoteFilesystemSet)
return scanner.Scanner{}, nil, nil
// initializeRemoteFilesystemScanService is for filesystem scanning in client/server mode
func initializeRemoteFilesystemScanService(ctx context.Context, path string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ServiceOption, artifactOption artifact.Option) (scan.Service, func(), error) {
wire.Build(scan.RemoteFilesystemSet)
return scan.Service{}, nil, nil
}
// initializeRemoteRepositoryScanner is for repository scanning in client/server mode
func initializeRemoteRepositoryScanner(ctx context.Context, url string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ScannerOption, artifactOption artifact.Option) (
scanner.Scanner, func(), error) {
wire.Build(scanner.RemoteRepositorySet)
return scanner.Scanner{}, nil, nil
// initializeRemoteRepositoryScanService is for repository scanning in client/server mode
func initializeRemoteRepositoryScanService(ctx context.Context, url string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ServiceOption, artifactOption artifact.Option) (
scan.Service, func(), error) {
wire.Build(scan.RemoteRepositorySet)
return scan.Service{}, nil, nil
}
// initializeRemoteSBOMScanner is for sbom scanning in client/server mode
func initializeRemoteSBOMScanner(ctx context.Context, path string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ScannerOption, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
wire.Build(scanner.RemoteSBOMSet)
return scanner.Scanner{}, nil, nil
// initializeRemoteSBOMScanService is for sbom scanning in client/server mode
func initializeRemoteSBOMScanService(ctx context.Context, path string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ServiceOption, artifactOption artifact.Option) (scan.Service, func(), error) {
wire.Build(scan.RemoteSBOMSet)
return scan.Service{}, nil, nil
}
// initializeRemoteVMScanner is for vm scanning in client/server mode
func initializeRemoteVMScanner(ctx context.Context, path string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ScannerOption, artifactOption artifact.Option) (scanner.Scanner, func(), error) {
wire.Build(scanner.RemoteVMSet)
return scanner.Scanner{}, nil, nil
// initializeRemoteVMScanService is for vm scanning in client/server mode
func initializeRemoteVMScanService(ctx context.Context, path string, remoteCacheOptions cache.RemoteOptions,
remoteScanOptions client.ServiceOption, artifactOption artifact.Option) (scan.Service, func(), error) {
wire.Build(scan.RemoteVMSet)
return scan.Service{}, nil, nil
}