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
38 lines
962 B
Go
38 lines
962 B
Go
package artifact
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/aquasecurity/fanal/analyzer"
|
|
"github.com/aquasecurity/fanal/cache"
|
|
"github.com/aquasecurity/trivy/pkg/scanner"
|
|
)
|
|
|
|
func filesystemScanner(ctx context.Context, dir string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
|
_ time.Duration, disabled []analyzer.Type) (scanner.Scanner, func(), error) {
|
|
s, cleanup, err := initializeFilesystemScanner(ctx, dir, ac, lac, disabled)
|
|
if err != nil {
|
|
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize a filesystem scanner: %w", err)
|
|
}
|
|
return s, cleanup, nil
|
|
}
|
|
|
|
// FilesystemRun runs scan on filesystem
|
|
func FilesystemRun(cliCtx *cli.Context) error {
|
|
c, err := NewConfig(cliCtx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// initialize config
|
|
if err = c.Init(); err != nil {
|
|
return xerrors.Errorf("failed to initialize options: %w", err)
|
|
}
|
|
|
|
return run(c, filesystemScanner)
|
|
}
|