mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 07:10:41 -08:00
* refactor: export internal packages * refactor(server): define Server * refactor: fix lint issues * test(integration): fix imports
59 lines
2.1 KiB
Go
59 lines
2.1 KiB
Go
// Code generated by Wire. DO NOT EDIT.
|
|
|
|
//go:generate wire
|
|
//+build !wireinject
|
|
|
|
package client
|
|
|
|
import (
|
|
"context"
|
|
"github.com/aquasecurity/fanal/analyzer"
|
|
image2 "github.com/aquasecurity/fanal/artifact/image"
|
|
"github.com/aquasecurity/fanal/cache"
|
|
"github.com/aquasecurity/fanal/image"
|
|
"github.com/aquasecurity/trivy-db/pkg/db"
|
|
"github.com/aquasecurity/trivy/pkg/rpc/client"
|
|
"github.com/aquasecurity/trivy/pkg/scanner"
|
|
"github.com/aquasecurity/trivy/pkg/types"
|
|
"github.com/aquasecurity/trivy/pkg/vulnerability"
|
|
"time"
|
|
)
|
|
|
|
// Injectors from inject.go:
|
|
|
|
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, disabled []analyzer.Type) (scanner.Scanner, func(), error) {
|
|
scannerScanner := client.NewProtobufClient(url)
|
|
clientScanner := client.NewScanner(customHeaders, scannerScanner)
|
|
dockerOption, err := types.GetDockerOption(timeout)
|
|
if err != nil {
|
|
return scanner.Scanner{}, nil, err
|
|
}
|
|
imageImage, cleanup, err := image.NewDockerImage(ctx, imageName, dockerOption)
|
|
if err != nil {
|
|
return scanner.Scanner{}, nil, err
|
|
}
|
|
artifact := image2.NewArtifact(imageImage, artifactCache, disabled)
|
|
scanner2 := scanner.NewScanner(clientScanner, artifact)
|
|
return scanner2, func() {
|
|
cleanup()
|
|
}, nil
|
|
}
|
|
|
|
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, disabled []analyzer.Type) (scanner.Scanner, error) {
|
|
scannerScanner := client.NewProtobufClient(url)
|
|
clientScanner := client.NewScanner(customHeaders, scannerScanner)
|
|
imageImage, err := image.NewArchiveImage(filePath)
|
|
if err != nil {
|
|
return scanner.Scanner{}, err
|
|
}
|
|
artifact := image2.NewArtifact(imageImage, artifactCache, disabled)
|
|
scanner2 := scanner.NewScanner(clientScanner, artifact)
|
|
return scanner2, nil
|
|
}
|
|
|
|
func initializeVulnerabilityClient() vulnerability.Client {
|
|
config := db.Config{}
|
|
vulnerabilityClient := vulnerability.NewClient(config)
|
|
return vulnerabilityClient
|
|
}
|