mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-23 15:37:50 -08:00
* refactor(docker_conf): rename and remove unnecessary options * feat(rpc): define new API * fix(cli): change default timeout * fix(import): fix package names * refactor(vulnerability): remove old mock * refactor(utils): remove un-needed functions * feat(cache): implement cache communicating with a server * refactor(scan): separate scan function as local scanner * test(scanner): add tests for ScanImage * refactor(scan): remove unused options * test(vulnerability): generate mock * refactor(server): split a file * feat(server): implement new RPC server * feat(client): implement new RPC client * fix(cache): use new cache interface * fix(standalone): use new scanner * fix(client): use new scanner * fix(server): pass cache * test(integration): make sure an error is not nil before calling the method * fix(mod): update dependencies * test(integration): ensure the image load finishes * feat(docker): support DOCKER_HOST and DOCKER_CERT_PATH * chore(mod): update dependencies * refactor(rpc): remove old client * feat(server): support old API for backward compatibility * fix(server): check a schema version of JSON cache * fix(rpc): add a version to packages * feat(rpc): add PutImage * test: rename expectations * refactor(cache): rename LayerCache to ImageCache * refactor: rename ImageInfo to ImageReference * fix(applier): pass image_id to ApplyLayer * feat(cache): handle image cache * chore(mod): update dependencies * refactor(server): pass only config * feat(cli): add -removed-pkgs option * refactor(err): wrap errors
68 lines
2.3 KiB
Go
68 lines
2.3 KiB
Go
// Code generated by Wire. DO NOT EDIT.
|
|
|
|
//go:generate wire
|
|
//+build !wireinject
|
|
|
|
package standalone
|
|
|
|
import (
|
|
"context"
|
|
"github.com/aquasecurity/fanal/analyzer"
|
|
"github.com/aquasecurity/fanal/cache"
|
|
"github.com/aquasecurity/fanal/extractor/docker"
|
|
"github.com/aquasecurity/trivy-db/pkg/db"
|
|
"github.com/aquasecurity/trivy/pkg/detector/library"
|
|
"github.com/aquasecurity/trivy/pkg/detector/ospkg"
|
|
"github.com/aquasecurity/trivy/pkg/scanner"
|
|
"github.com/aquasecurity/trivy/pkg/scanner/local"
|
|
"github.com/aquasecurity/trivy/pkg/types"
|
|
"github.com/aquasecurity/trivy/pkg/vulnerability"
|
|
"time"
|
|
)
|
|
|
|
// Injectors from inject.go:
|
|
|
|
func initializeDockerScanner(ctx context.Context, imageName string, layerCache cache.ImageCache, localImageCache cache.LocalImageCache, timeout time.Duration) (scanner.Scanner, error) {
|
|
applier := analyzer.NewApplier(localImageCache)
|
|
detector := ospkg.Detector{}
|
|
driverFactory := library.DriverFactory{}
|
|
libraryDetector := library.NewDetector(driverFactory)
|
|
localScanner := local.NewScanner(applier, detector, libraryDetector)
|
|
dockerOption, err := types.GetDockerOption(timeout)
|
|
if err != nil {
|
|
return scanner.Scanner{}, err
|
|
}
|
|
extractor, err := docker.NewDockerExtractor(ctx, imageName, dockerOption)
|
|
if err != nil {
|
|
return scanner.Scanner{}, err
|
|
}
|
|
config := analyzer.New(extractor, layerCache)
|
|
scannerScanner := scanner.NewScanner(localScanner, config)
|
|
return scannerScanner, nil
|
|
}
|
|
|
|
func initializeArchiveScanner(ctx context.Context, filePath string, layerCache cache.ImageCache, localImageCache cache.LocalImageCache, timeout time.Duration) (scanner.Scanner, error) {
|
|
applier := analyzer.NewApplier(localImageCache)
|
|
detector := ospkg.Detector{}
|
|
driverFactory := library.DriverFactory{}
|
|
libraryDetector := library.NewDetector(driverFactory)
|
|
localScanner := local.NewScanner(applier, detector, libraryDetector)
|
|
dockerOption, err := types.GetDockerOption(timeout)
|
|
if err != nil {
|
|
return scanner.Scanner{}, err
|
|
}
|
|
extractor, err := docker.NewDockerArchiveExtractor(ctx, filePath, dockerOption)
|
|
if err != nil {
|
|
return scanner.Scanner{}, err
|
|
}
|
|
config := analyzer.New(extractor, layerCache)
|
|
scannerScanner := scanner.NewScanner(localScanner, config)
|
|
return scannerScanner, nil
|
|
}
|
|
|
|
func initializeVulnerabilityClient() vulnerability.Client {
|
|
config := db.Config{}
|
|
client := vulnerability.NewClient(config)
|
|
return client
|
|
}
|