mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 07:10:41 -08:00
feat: added insecure tls skip to scan git repo (#1528)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
2
go.mod
2
go.mod
@@ -7,7 +7,7 @@ require (
|
|||||||
github.com/Masterminds/sprig v2.22.0+incompatible
|
github.com/Masterminds/sprig v2.22.0+incompatible
|
||||||
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46
|
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46
|
||||||
github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986
|
github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986
|
||||||
github.com/aquasecurity/fanal v0.0.0-20220110143207-7b717a949850
|
github.com/aquasecurity/fanal v0.0.0-20220111120722-2a1f5245bf89
|
||||||
github.com/aquasecurity/go-dep-parser v0.0.0-20211224170007-df43bca6b6ff
|
github.com/aquasecurity/go-dep-parser v0.0.0-20211224170007-df43bca6b6ff
|
||||||
github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce
|
github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce
|
||||||
github.com/aquasecurity/go-npm-version v0.0.0-20201110091526-0b796d180798
|
github.com/aquasecurity/go-npm-version v0.0.0-20201110091526-0b796d180798
|
||||||
|
|||||||
12
go.sum
12
go.sum
@@ -222,8 +222,8 @@ github.com/aquasecurity/cfsec v0.2.2 h1:hq6MZlg7XFZsrerCv297N4HRlnJM7K6LLd/l/xCz
|
|||||||
github.com/aquasecurity/cfsec v0.2.2/go.mod h1:sUELRJqIPXTOZiHUx7TzyyFFzuk0W22IG6IWAoV8T6U=
|
github.com/aquasecurity/cfsec v0.2.2/go.mod h1:sUELRJqIPXTOZiHUx7TzyyFFzuk0W22IG6IWAoV8T6U=
|
||||||
github.com/aquasecurity/defsec v0.0.37 h1:zdZndlKrW257b8VLK1UwfmXiyPuDrNA+wzBilHRk1LA=
|
github.com/aquasecurity/defsec v0.0.37 h1:zdZndlKrW257b8VLK1UwfmXiyPuDrNA+wzBilHRk1LA=
|
||||||
github.com/aquasecurity/defsec v0.0.37/go.mod h1:csaBEcJ3AKy44expnW0dCANEZcS/c1vcJjwBCbnKWBM=
|
github.com/aquasecurity/defsec v0.0.37/go.mod h1:csaBEcJ3AKy44expnW0dCANEZcS/c1vcJjwBCbnKWBM=
|
||||||
github.com/aquasecurity/fanal v0.0.0-20220110143207-7b717a949850 h1:lCw+lxqHW5vwpVU06PtGPYOrRkI5LQcHvyo0PjtjUnI=
|
github.com/aquasecurity/fanal v0.0.0-20220111120722-2a1f5245bf89 h1:gPYH1Xl7keAT1IX4bvaGs2eL/s00vgoA4YQBu8MJHvM=
|
||||||
github.com/aquasecurity/fanal v0.0.0-20220110143207-7b717a949850/go.mod h1:/tcr4GyWmxkMkX2m9WZIeCYb6Wwn15+ApxjiNbO9aUk=
|
github.com/aquasecurity/fanal v0.0.0-20220111120722-2a1f5245bf89/go.mod h1:JczvQizYzz3boiVSFhBrOfVorWe2ldN0w5c4s7650ro=
|
||||||
github.com/aquasecurity/go-dep-parser v0.0.0-20211224170007-df43bca6b6ff h1:JCKEV3TgUNh9fn+8hXyIdsF9yErA0rUbCkgt2flRKt4=
|
github.com/aquasecurity/go-dep-parser v0.0.0-20211224170007-df43bca6b6ff h1:JCKEV3TgUNh9fn+8hXyIdsF9yErA0rUbCkgt2flRKt4=
|
||||||
github.com/aquasecurity/go-dep-parser v0.0.0-20211224170007-df43bca6b6ff/go.mod h1:8fJ//Ob6/03lxbn4xa1F+G/giVtiVLxnZNpBp5xOxNk=
|
github.com/aquasecurity/go-dep-parser v0.0.0-20211224170007-df43bca6b6ff/go.mod h1:8fJ//Ob6/03lxbn4xa1F+G/giVtiVLxnZNpBp5xOxNk=
|
||||||
github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce h1:QgBRgJvtEOBtUXilDb1MLi1p1MWoyFDXAu5DEUl5nwM=
|
github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce h1:QgBRgJvtEOBtUXilDb1MLi1p1MWoyFDXAu5DEUl5nwM=
|
||||||
@@ -262,8 +262,8 @@ github.com/aws/aws-sdk-go v1.25.11/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi
|
|||||||
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||||
github.com/aws/aws-sdk-go v1.27.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
github.com/aws/aws-sdk-go v1.27.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||||
github.com/aws/aws-sdk-go v1.31.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
|
github.com/aws/aws-sdk-go v1.31.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
|
||||||
github.com/aws/aws-sdk-go v1.42.0 h1:BMZws0t8NAhHFsfnT3B40IwD13jVDG5KerlRksctVIw=
|
github.com/aws/aws-sdk-go v1.42.30 h1:GvzWHwAdE5ZQ9UOcq0lX+PTzVJ4+sm1DjYrk6nUSTgA=
|
||||||
github.com/aws/aws-sdk-go v1.42.0/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
|
github.com/aws/aws-sdk-go v1.42.30/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc=
|
||||||
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
||||||
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
||||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||||
@@ -1753,12 +1753,12 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
|
|||||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 h1:DZshvxDdVoeKIbudAdFEKi+f70l51luSy/7b76ibTY0=
|
|
||||||
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=
|
||||||
|
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/oauth2 v0.0.0-20180724155351-3d292e4d0cdc/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180724155351-3d292e4d0cdc/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
|||||||
@@ -285,6 +285,12 @@ var (
|
|||||||
EnvVars: []string{"TRIVY_TRACE"},
|
EnvVars: []string{"TRIVY_TRACE"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
insecureFlag = cli.BoolFlag{
|
||||||
|
Name: "insecure",
|
||||||
|
Usage: "allow insecure server connections when using SSL",
|
||||||
|
EnvVars: []string{"TRIVY_INSECURE"},
|
||||||
|
}
|
||||||
|
|
||||||
// Global flags
|
// Global flags
|
||||||
globalFlags = []cli.Flag{
|
globalFlags = []cli.Flag{
|
||||||
&quietFlag,
|
&quietFlag,
|
||||||
@@ -402,6 +408,7 @@ func NewImageCommand() *cli.Command {
|
|||||||
&listAllPackages,
|
&listAllPackages,
|
||||||
&cacheBackendFlag,
|
&cacheBackendFlag,
|
||||||
&offlineScan,
|
&offlineScan,
|
||||||
|
&insecureFlag,
|
||||||
stringSliceFlag(skipFiles),
|
stringSliceFlag(skipFiles),
|
||||||
stringSliceFlag(skipDirs),
|
stringSliceFlag(skipDirs),
|
||||||
},
|
},
|
||||||
@@ -508,6 +515,7 @@ func NewRepositoryCommand() *cli.Command {
|
|||||||
&ignorePolicy,
|
&ignorePolicy,
|
||||||
&listAllPackages,
|
&listAllPackages,
|
||||||
&offlineScan,
|
&offlineScan,
|
||||||
|
&insecureFlag,
|
||||||
stringSliceFlag(skipFiles),
|
stringSliceFlag(skipFiles),
|
||||||
stringSliceFlag(skipDirs),
|
stringSliceFlag(skipDirs),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package artifact
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@@ -15,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func filesystemScanner(ctx context.Context, dir string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
func filesystemScanner(ctx context.Context, dir string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
||||||
_ time.Duration, artifactOpt artifact.Option, scannerOpt config.ScannerOption) (scanner.Scanner, func(), error) {
|
_ bool, artifactOpt artifact.Option, scannerOpt config.ScannerOption) (scanner.Scanner, func(), error) {
|
||||||
s, cleanup, err := initializeFilesystemScanner(ctx, dir, ac, lac, artifactOpt, scannerOpt)
|
s, cleanup, err := initializeFilesystemScanner(ctx, dir, ac, lac, artifactOpt, scannerOpt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize a filesystem scanner: %w", err)
|
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize a filesystem scanner: %w", err)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package artifact
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@@ -12,11 +11,12 @@ import (
|
|||||||
"github.com/aquasecurity/fanal/artifact"
|
"github.com/aquasecurity/fanal/artifact"
|
||||||
"github.com/aquasecurity/fanal/cache"
|
"github.com/aquasecurity/fanal/cache"
|
||||||
"github.com/aquasecurity/trivy/pkg/scanner"
|
"github.com/aquasecurity/trivy/pkg/scanner"
|
||||||
|
"github.com/aquasecurity/trivy/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func archiveScanner(ctx context.Context, input string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
func archiveScanner(ctx context.Context, input string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
||||||
timeout time.Duration, artifactOpt artifact.Option, scannerOpt config.ScannerOption) (scanner.Scanner, func(), error) {
|
_ bool, artifactOpt artifact.Option, scannerOpt config.ScannerOption) (scanner.Scanner, func(), error) {
|
||||||
s, err := initializeArchiveScanner(ctx, input, ac, lac, timeout, artifactOpt, scannerOpt)
|
s, err := initializeArchiveScanner(ctx, input, ac, lac, artifactOpt, scannerOpt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize the archive scanner: %w", err)
|
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize the archive scanner: %w", err)
|
||||||
}
|
}
|
||||||
@@ -24,8 +24,12 @@ func archiveScanner(ctx context.Context, input string, ac cache.ArtifactCache, l
|
|||||||
}
|
}
|
||||||
|
|
||||||
func dockerScanner(ctx context.Context, imageName string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
func dockerScanner(ctx context.Context, imageName string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
||||||
timeout time.Duration, artifactOpt artifact.Option, scannerOpt config.ScannerOption) (scanner.Scanner, func(), error) {
|
insecure bool, artifactOpt artifact.Option, scannerOpt config.ScannerOption) (scanner.Scanner, func(), error) {
|
||||||
s, cleanup, err := initializeDockerScanner(ctx, imageName, ac, lac, timeout, artifactOpt, scannerOpt)
|
dockerOpt, err := types.GetDockerOption(insecure)
|
||||||
|
if err != nil {
|
||||||
|
return scanner.Scanner{}, nil, err
|
||||||
|
}
|
||||||
|
s, cleanup, err := initializeDockerScanner(ctx, imageName, ac, lac, dockerOpt, artifactOpt, scannerOpt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize a docker scanner: %w", err)
|
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize a docker scanner: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,26 +5,26 @@ package artifact
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/wire"
|
"github.com/google/wire"
|
||||||
|
|
||||||
"github.com/aquasecurity/fanal/analyzer/config"
|
"github.com/aquasecurity/fanal/analyzer/config"
|
||||||
"github.com/aquasecurity/fanal/artifact"
|
"github.com/aquasecurity/fanal/artifact"
|
||||||
"github.com/aquasecurity/fanal/cache"
|
"github.com/aquasecurity/fanal/cache"
|
||||||
|
"github.com/aquasecurity/fanal/types"
|
||||||
"github.com/aquasecurity/trivy/pkg/result"
|
"github.com/aquasecurity/trivy/pkg/result"
|
||||||
"github.com/aquasecurity/trivy/pkg/scanner"
|
"github.com/aquasecurity/trivy/pkg/scanner"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache,
|
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache,
|
||||||
localArtifactCache cache.LocalArtifactCache, timeout time.Duration, artifactOption artifact.Option,
|
localArtifactCache cache.LocalArtifactCache, dockerOpt types.DockerOption, artifactOption artifact.Option,
|
||||||
configScannerOption config.ScannerOption) (scanner.Scanner, func(), error) {
|
configScannerOption config.ScannerOption) (scanner.Scanner, func(), error) {
|
||||||
wire.Build(scanner.StandaloneDockerSet)
|
wire.Build(scanner.StandaloneDockerSet)
|
||||||
return scanner.Scanner{}, nil, nil
|
return scanner.Scanner{}, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache,
|
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache,
|
||||||
localArtifactCache cache.LocalArtifactCache, timeout time.Duration, artifactOption artifact.Option,
|
localArtifactCache cache.LocalArtifactCache, artifactOption artifact.Option,
|
||||||
configScannerOption config.ScannerOption) (scanner.Scanner, error) {
|
configScannerOption config.ScannerOption) (scanner.Scanner, error) {
|
||||||
wire.Build(scanner.StandaloneArchiveSet)
|
wire.Build(scanner.StandaloneArchiveSet)
|
||||||
return scanner.Scanner{}, nil
|
return scanner.Scanner{}, nil
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package artifact
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@@ -16,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func repositoryScanner(ctx context.Context, dir string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
func repositoryScanner(ctx context.Context, dir string, ac cache.ArtifactCache, lac cache.LocalArtifactCache,
|
||||||
_ time.Duration, artifactOpt artifact.Option, scannerOpt config.ScannerOption) (scanner.Scanner, func(), error) {
|
_ bool, artifactOpt artifact.Option, scannerOpt config.ScannerOption) (scanner.Scanner, func(), error) {
|
||||||
s, cleanup, err := initializeRepositoryScanner(ctx, dir, ac, lac, artifactOpt, scannerOpt)
|
s, cleanup, err := initializeRepositoryScanner(ctx, dir, ac, lac, artifactOpt, scannerOpt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize a filesystem scanner: %w", err)
|
return scanner.Scanner{}, func() {}, xerrors.Errorf("unable to initialize a filesystem scanner: %w", err)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@@ -27,7 +26,7 @@ const defaultPolicyNamespace = "appshield"
|
|||||||
var errSkipScan = errors.New("skip subsequent processes")
|
var errSkipScan = errors.New("skip subsequent processes")
|
||||||
|
|
||||||
// InitializeScanner defines the initialize function signature of scanner
|
// InitializeScanner defines the initialize function signature of scanner
|
||||||
type InitializeScanner func(context.Context, string, cache.ArtifactCache, cache.LocalArtifactCache, time.Duration,
|
type InitializeScanner func(context.Context, string, cache.ArtifactCache, cache.LocalArtifactCache, bool,
|
||||||
artifact.Option, config.ScannerOption) (scanner.Scanner, func(), error)
|
artifact.Option, config.ScannerOption) (scanner.Scanner, func(), error)
|
||||||
|
|
||||||
// InitCache defines cache initializer
|
// InitCache defines cache initializer
|
||||||
@@ -204,11 +203,12 @@ func scan(ctx context.Context, opt Option, initializeScanner InitializeScanner,
|
|||||||
DisabledAnalyzers: disabledAnalyzers(opt),
|
DisabledAnalyzers: disabledAnalyzers(opt),
|
||||||
SkipFiles: opt.SkipFiles,
|
SkipFiles: opt.SkipFiles,
|
||||||
SkipDirs: opt.SkipDirs,
|
SkipDirs: opt.SkipDirs,
|
||||||
|
InsecureSkipTLS: opt.Insecure,
|
||||||
Offline: opt.OfflineScan,
|
Offline: opt.OfflineScan,
|
||||||
Quiet: opt.Quiet,
|
Quiet: opt.Quiet,
|
||||||
}
|
}
|
||||||
|
|
||||||
s, cleanup, err := initializeScanner(ctx, target, cacheClient, cacheClient, opt.Timeout, artifactOpt, configScannerOptions)
|
s, cleanup, err := initializeScanner(ctx, target, cacheClient, cacheClient, opt.Insecure, artifactOpt, configScannerOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return pkgReport.Report{}, xerrors.Errorf("unable to initialize a scanner: %w", err)
|
return pkgReport.Report{}, xerrors.Errorf("unable to initialize a scanner: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by Wire. DO NOT EDIT.
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
//go:generate wire
|
//go:generate go run github.com/google/wire/cmd/wire
|
||||||
//go:build !wireinject
|
//go:build !wireinject
|
||||||
// +build !wireinject
|
// +build !wireinject
|
||||||
|
|
||||||
@@ -16,26 +16,21 @@ import (
|
|||||||
"github.com/aquasecurity/fanal/artifact/remote"
|
"github.com/aquasecurity/fanal/artifact/remote"
|
||||||
"github.com/aquasecurity/fanal/cache"
|
"github.com/aquasecurity/fanal/cache"
|
||||||
"github.com/aquasecurity/fanal/image"
|
"github.com/aquasecurity/fanal/image"
|
||||||
|
"github.com/aquasecurity/fanal/types"
|
||||||
"github.com/aquasecurity/trivy-db/pkg/db"
|
"github.com/aquasecurity/trivy-db/pkg/db"
|
||||||
"github.com/aquasecurity/trivy/pkg/detector/ospkg"
|
"github.com/aquasecurity/trivy/pkg/detector/ospkg"
|
||||||
"github.com/aquasecurity/trivy/pkg/result"
|
"github.com/aquasecurity/trivy/pkg/result"
|
||||||
"github.com/aquasecurity/trivy/pkg/scanner"
|
"github.com/aquasecurity/trivy/pkg/scanner"
|
||||||
"github.com/aquasecurity/trivy/pkg/scanner/local"
|
"github.com/aquasecurity/trivy/pkg/scanner/local"
|
||||||
"github.com/aquasecurity/trivy/pkg/types"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Injectors from inject.go:
|
// Injectors from inject.go:
|
||||||
|
|
||||||
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache, timeout time.Duration, artifactOption artifact.Option, configScannerOption config.ScannerOption) (scanner.Scanner, func(), error) {
|
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache, dockerOpt types.DockerOption, artifactOption artifact.Option, configScannerOption config.ScannerOption) (scanner.Scanner, func(), error) {
|
||||||
applierApplier := applier.NewApplier(localArtifactCache)
|
applierApplier := applier.NewApplier(localArtifactCache)
|
||||||
detector := ospkg.Detector{}
|
detector := ospkg.Detector{}
|
||||||
localScanner := local.NewScanner(applierApplier, detector)
|
localScanner := local.NewScanner(applierApplier, detector)
|
||||||
dockerOption, err := types.GetDockerOption(timeout)
|
typesImage, cleanup, err := image.NewDockerImage(ctx, imageName, dockerOpt)
|
||||||
if err != nil {
|
|
||||||
return scanner.Scanner{}, nil, err
|
|
||||||
}
|
|
||||||
typesImage, cleanup, err := image.NewDockerImage(ctx, imageName, dockerOption)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scanner.Scanner{}, nil, err
|
return scanner.Scanner{}, nil, err
|
||||||
}
|
}
|
||||||
@@ -50,7 +45,7 @@ func initializeDockerScanner(ctx context.Context, imageName string, artifactCach
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache, timeout time.Duration, artifactOption artifact.Option, configScannerOption config.ScannerOption) (scanner.Scanner, error) {
|
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache, localArtifactCache cache.LocalArtifactCache, artifactOption artifact.Option, configScannerOption config.ScannerOption) (scanner.Scanner, error) {
|
||||||
applierApplier := applier.NewApplier(localArtifactCache)
|
applierApplier := applier.NewApplier(localArtifactCache)
|
||||||
detector := ospkg.Detector{}
|
detector := ospkg.Detector{}
|
||||||
localScanner := local.NewScanner(applierApplier, detector)
|
localScanner := local.NewScanner(applierApplier, detector)
|
||||||
|
|||||||
@@ -5,27 +5,27 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/wire"
|
"github.com/google/wire"
|
||||||
|
|
||||||
"github.com/aquasecurity/fanal/analyzer/config"
|
"github.com/aquasecurity/fanal/analyzer/config"
|
||||||
"github.com/aquasecurity/fanal/artifact"
|
"github.com/aquasecurity/fanal/artifact"
|
||||||
"github.com/aquasecurity/fanal/cache"
|
"github.com/aquasecurity/fanal/cache"
|
||||||
|
"github.com/aquasecurity/fanal/types"
|
||||||
"github.com/aquasecurity/trivy/pkg/result"
|
"github.com/aquasecurity/trivy/pkg/result"
|
||||||
"github.com/aquasecurity/trivy/pkg/rpc/client"
|
"github.com/aquasecurity/trivy/pkg/rpc/client"
|
||||||
"github.com/aquasecurity/trivy/pkg/scanner"
|
"github.com/aquasecurity/trivy/pkg/scanner"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders,
|
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders,
|
||||||
url client.RemoteURL, timeout time.Duration, artifactOption artifact.Option, configScannerOption config.ScannerOption) (
|
url client.RemoteURL, dockerOpt types.DockerOption, artifactOption artifact.Option, configScannerOption config.ScannerOption) (
|
||||||
scanner.Scanner, func(), error) {
|
scanner.Scanner, func(), error) {
|
||||||
wire.Build(scanner.RemoteDockerSet)
|
wire.Build(scanner.RemoteDockerSet)
|
||||||
return scanner.Scanner{}, nil, nil
|
return scanner.Scanner{}, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache,
|
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache,
|
||||||
customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, artifactOption artifact.Option,
|
customHeaders client.CustomHeaders, url client.RemoteURL, artifactOption artifact.Option,
|
||||||
configScannerOption config.ScannerOption) (scanner.Scanner, error) {
|
configScannerOption config.ScannerOption) (scanner.Scanner, error) {
|
||||||
wire.Build(scanner.RemoteArchiveSet)
|
wire.Build(scanner.RemoteArchiveSet)
|
||||||
return scanner.Scanner{}, nil
|
return scanner.Scanner{}, nil
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ func initializeScanner(ctx context.Context, opt Option) (scanner.Scanner, func()
|
|||||||
if opt.Input != "" {
|
if opt.Input != "" {
|
||||||
// Scan tar file
|
// Scan tar file
|
||||||
s, err := initializeArchiveScanner(ctx, opt.Input, remoteCache, client.CustomHeaders(opt.CustomHeaders),
|
s, err := initializeArchiveScanner(ctx, opt.Input, remoteCache, client.CustomHeaders(opt.CustomHeaders),
|
||||||
client.RemoteURL(opt.RemoteAddr), opt.Timeout, artifactOpt, configScannerOptions)
|
client.RemoteURL(opt.RemoteAddr), artifactOpt, configScannerOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scanner.Scanner{}, nil, xerrors.Errorf("unable to initialize the archive scanner: %w", err)
|
return scanner.Scanner{}, nil, xerrors.Errorf("unable to initialize the archive scanner: %w", err)
|
||||||
}
|
}
|
||||||
@@ -176,8 +176,13 @@ func initializeScanner(ctx context.Context, opt Option) (scanner.Scanner, func()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scan an image in Docker Engine or Docker Registry
|
// Scan an image in Docker Engine or Docker Registry
|
||||||
|
dockerOpt, err := types.GetDockerOption(opt.Insecure)
|
||||||
|
if err != nil {
|
||||||
|
return scanner.Scanner{}, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
s, cleanup, err := initializeDockerScanner(ctx, opt.Target, remoteCache, client.CustomHeaders(opt.CustomHeaders),
|
s, cleanup, err := initializeDockerScanner(ctx, opt.Target, remoteCache, client.CustomHeaders(opt.CustomHeaders),
|
||||||
client.RemoteURL(opt.RemoteAddr), opt.Timeout, artifactOpt, configScannerOptions)
|
client.RemoteURL(opt.RemoteAddr), dockerOpt, artifactOpt, configScannerOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scanner.Scanner{}, nil, xerrors.Errorf("unable to initialize the docker scanner: %w", err)
|
return scanner.Scanner{}, nil, xerrors.Errorf("unable to initialize the docker scanner: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by Wire. DO NOT EDIT.
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
//go:generate wire
|
//go:generate go run github.com/google/wire/cmd/wire
|
||||||
//go:build !wireinject
|
//go:build !wireinject
|
||||||
// +build !wireinject
|
// +build !wireinject
|
||||||
|
|
||||||
@@ -13,24 +13,19 @@ import (
|
|||||||
image2 "github.com/aquasecurity/fanal/artifact/image"
|
image2 "github.com/aquasecurity/fanal/artifact/image"
|
||||||
"github.com/aquasecurity/fanal/cache"
|
"github.com/aquasecurity/fanal/cache"
|
||||||
"github.com/aquasecurity/fanal/image"
|
"github.com/aquasecurity/fanal/image"
|
||||||
|
"github.com/aquasecurity/fanal/types"
|
||||||
"github.com/aquasecurity/trivy-db/pkg/db"
|
"github.com/aquasecurity/trivy-db/pkg/db"
|
||||||
"github.com/aquasecurity/trivy/pkg/result"
|
"github.com/aquasecurity/trivy/pkg/result"
|
||||||
"github.com/aquasecurity/trivy/pkg/rpc/client"
|
"github.com/aquasecurity/trivy/pkg/rpc/client"
|
||||||
"github.com/aquasecurity/trivy/pkg/scanner"
|
"github.com/aquasecurity/trivy/pkg/scanner"
|
||||||
"github.com/aquasecurity/trivy/pkg/types"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Injectors from inject.go:
|
// Injectors from inject.go:
|
||||||
|
|
||||||
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, artifactOption artifact.Option, configScannerOption config.ScannerOption) (scanner.Scanner, func(), error) {
|
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, dockerOpt types.DockerOption, artifactOption artifact.Option, configScannerOption config.ScannerOption) (scanner.Scanner, func(), error) {
|
||||||
scannerScanner := client.NewProtobufClient(url)
|
scannerScanner := client.NewProtobufClient(url)
|
||||||
clientScanner := client.NewScanner(customHeaders, scannerScanner)
|
clientScanner := client.NewScanner(customHeaders, scannerScanner)
|
||||||
dockerOption, err := types.GetDockerOption(timeout)
|
typesImage, cleanup, err := image.NewDockerImage(ctx, imageName, dockerOpt)
|
||||||
if err != nil {
|
|
||||||
return scanner.Scanner{}, nil, err
|
|
||||||
}
|
|
||||||
typesImage, cleanup, err := image.NewDockerImage(ctx, imageName, dockerOption)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scanner.Scanner{}, nil, err
|
return scanner.Scanner{}, nil, err
|
||||||
}
|
}
|
||||||
@@ -45,7 +40,7 @@ func initializeDockerScanner(ctx context.Context, imageName string, artifactCach
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, artifactOption artifact.Option, configScannerOption config.ScannerOption) (scanner.Scanner, error) {
|
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, artifactOption artifact.Option, configScannerOption config.ScannerOption) (scanner.Scanner, error) {
|
||||||
scannerScanner := client.NewProtobufClient(url)
|
scannerScanner := client.NewProtobufClient(url)
|
||||||
clientScanner := client.NewScanner(customHeaders, scannerScanner)
|
clientScanner := client.NewScanner(customHeaders, scannerScanner)
|
||||||
typesImage, err := image.NewArchiveImage(filePath)
|
typesImage, err := image.NewArchiveImage(filePath)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type ArtifactOption struct {
|
|||||||
Input string
|
Input string
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
ClearCache bool
|
ClearCache bool
|
||||||
|
Insecure bool
|
||||||
|
|
||||||
SkipDirs []string
|
SkipDirs []string
|
||||||
SkipFiles []string
|
SkipFiles []string
|
||||||
@@ -32,6 +33,7 @@ func NewArtifactOption(c *cli.Context) ArtifactOption {
|
|||||||
SkipFiles: c.StringSlice("skip-files"),
|
SkipFiles: c.StringSlice("skip-files"),
|
||||||
SkipDirs: c.StringSlice("skip-dirs"),
|
SkipDirs: c.StringSlice("skip-dirs"),
|
||||||
OfflineScan: c.Bool("offline-scan"),
|
OfflineScan: c.Bool("offline-scan"),
|
||||||
|
Insecure: c.Bool("insecure"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by Wire. DO NOT EDIT.
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
//go:generate wire
|
//go:generate go run github.com/google/wire/cmd/wire
|
||||||
//go:build !wireinject
|
//go:build !wireinject
|
||||||
// +build !wireinject
|
// +build !wireinject
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ var StandaloneSuperSet = wire.NewSet(
|
|||||||
|
|
||||||
// StandaloneDockerSet binds docker dependencies
|
// StandaloneDockerSet binds docker dependencies
|
||||||
var StandaloneDockerSet = wire.NewSet(
|
var StandaloneDockerSet = wire.NewSet(
|
||||||
types.GetDockerOption,
|
|
||||||
image.NewDockerImage,
|
image.NewDockerImage,
|
||||||
aimage.NewArtifact,
|
aimage.NewArtifact,
|
||||||
StandaloneSuperSet,
|
StandaloneSuperSet,
|
||||||
@@ -63,7 +62,6 @@ var RemoteSuperSet = wire.NewSet(
|
|||||||
|
|
||||||
// RemoteDockerSet binds remote docker dependencies
|
// RemoteDockerSet binds remote docker dependencies
|
||||||
var RemoteDockerSet = wire.NewSet(
|
var RemoteDockerSet = wire.NewSet(
|
||||||
types.GetDockerOption,
|
|
||||||
image.NewDockerImage,
|
image.NewDockerImage,
|
||||||
RemoteSuperSet,
|
RemoteSuperSet,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/caarlos0/env/v6"
|
"github.com/caarlos0/env/v6"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
@@ -14,12 +12,11 @@ type DockerConfig struct {
|
|||||||
UserName string `env:"TRIVY_USERNAME"`
|
UserName string `env:"TRIVY_USERNAME"`
|
||||||
Password string `env:"TRIVY_PASSWORD"`
|
Password string `env:"TRIVY_PASSWORD"`
|
||||||
RegistryToken string `env:"TRIVY_REGISTRY_TOKEN"`
|
RegistryToken string `env:"TRIVY_REGISTRY_TOKEN"`
|
||||||
Insecure bool `env:"TRIVY_INSECURE" envDefault:"false"`
|
|
||||||
NonSSL bool `env:"TRIVY_NON_SSL" envDefault:"false"`
|
NonSSL bool `env:"TRIVY_NON_SSL" envDefault:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDockerOption returns the Docker scanning options using DockerConfig
|
// GetDockerOption returns the Docker scanning options using DockerConfig
|
||||||
func GetDockerOption(timeout time.Duration) (types.DockerOption, error) {
|
func GetDockerOption(insecureTlsSkip bool) (types.DockerOption, error) {
|
||||||
cfg := DockerConfig{}
|
cfg := DockerConfig{}
|
||||||
if err := env.Parse(&cfg); err != nil {
|
if err := env.Parse(&cfg); err != nil {
|
||||||
return types.DockerOption{}, xerrors.Errorf("unable to parse environment variables: %w", err)
|
return types.DockerOption{}, xerrors.Errorf("unable to parse environment variables: %w", err)
|
||||||
@@ -29,7 +26,7 @@ func GetDockerOption(timeout time.Duration) (types.DockerOption, error) {
|
|||||||
UserName: cfg.UserName,
|
UserName: cfg.UserName,
|
||||||
Password: cfg.Password,
|
Password: cfg.Password,
|
||||||
RegistryToken: cfg.RegistryToken,
|
RegistryToken: cfg.RegistryToken,
|
||||||
InsecureSkipTLSVerify: cfg.Insecure,
|
InsecureSkipTLSVerify: insecureTlsSkip,
|
||||||
NonSSL: cfg.NonSSL,
|
NonSSL: cfg.NonSSL,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user