mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 07:10:41 -08:00
* refactor(server): remove Detect endpoint * refactor(library): do not use interface * refactor: add dbtest package * test: add bolt fixtures * feat: support jar scanning * refactor: rename node to npm * refactor: fix lint issues * test(maven): remove some tests * chore(mod): update fanal * docs: update README * chore(mod): update trivy-db * fix(library/drive): add ecosystem * fix: do not display 0 vulnerabilities * refactor(table): split method * Update README.md (#838) * fix(app): increase the default value of timeout (#842) * feat(maven): use go-mvn-version * test(maven): update tests * fix(scan): skip files and dirs before vulnerability detection * fix: display log messages only once per type * docs(README): add file suffixes * chore(mod): update go-mvn-version * feat(log): set go-dep-parser logger * chore(mod): update fanal * docs: update README * docs(README): add java source * test(maven): fix invalid case
88 lines
3.2 KiB
Go
88 lines
3.2 KiB
Go
// Code generated by Wire. DO NOT EDIT.
|
|
|
|
//go:generate wire
|
|
//+build !wireinject
|
|
|
|
package artifact
|
|
|
|
import (
|
|
"context"
|
|
"github.com/aquasecurity/fanal/applier"
|
|
image2 "github.com/aquasecurity/fanal/artifact/image"
|
|
local2 "github.com/aquasecurity/fanal/artifact/local"
|
|
"github.com/aquasecurity/fanal/artifact/remote"
|
|
"github.com/aquasecurity/fanal/cache"
|
|
"github.com/aquasecurity/fanal/image"
|
|
"github.com/aquasecurity/trivy-db/pkg/db"
|
|
"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, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache, timeout time.Duration) (scanner.Scanner, func(), error) {
|
|
applierApplier := applier.NewApplier(localArtifactCache)
|
|
detector := ospkg.Detector{}
|
|
localScanner := local.NewScanner(applierApplier, detector)
|
|
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)
|
|
scannerScanner := scanner.NewScanner(localScanner, artifact)
|
|
return scannerScanner, func() {
|
|
cleanup()
|
|
}, nil
|
|
}
|
|
|
|
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache, timeout time.Duration) (scanner.Scanner, error) {
|
|
applierApplier := applier.NewApplier(localArtifactCache)
|
|
detector := ospkg.Detector{}
|
|
localScanner := local.NewScanner(applierApplier, detector)
|
|
imageImage, err := image.NewArchiveImage(filePath)
|
|
if err != nil {
|
|
return scanner.Scanner{}, err
|
|
}
|
|
artifact := image2.NewArtifact(imageImage, artifactCache)
|
|
scannerScanner := scanner.NewScanner(localScanner, artifact)
|
|
return scannerScanner, nil
|
|
}
|
|
|
|
func initializeFilesystemScanner(ctx context.Context, dir string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache) (scanner.Scanner, func(), error) {
|
|
applierApplier := applier.NewApplier(localArtifactCache)
|
|
detector := ospkg.Detector{}
|
|
localScanner := local.NewScanner(applierApplier, detector)
|
|
artifact := local2.NewArtifact(dir, artifactCache)
|
|
scannerScanner := scanner.NewScanner(localScanner, artifact)
|
|
return scannerScanner, func() {
|
|
}, nil
|
|
}
|
|
|
|
func initializeRepositoryScanner(ctx context.Context, url string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache) (scanner.Scanner, func(), error) {
|
|
applierApplier := applier.NewApplier(localArtifactCache)
|
|
detector := ospkg.Detector{}
|
|
localScanner := local.NewScanner(applierApplier, detector)
|
|
artifact, cleanup, err := remote.NewArtifact(url, artifactCache)
|
|
if err != nil {
|
|
return scanner.Scanner{}, nil, err
|
|
}
|
|
scannerScanner := scanner.NewScanner(localScanner, artifact)
|
|
return scannerScanner, func() {
|
|
cleanup()
|
|
}, nil
|
|
}
|
|
|
|
func initializeVulnerabilityClient() vulnerability.Client {
|
|
config := db.Config{}
|
|
client := vulnerability.NewClient(config)
|
|
return client
|
|
}
|