mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 15:50:15 -08:00
feat: add --skip-directories option (#595)
* feat: add --skip-directories option * chore(README): update * refactor: rename skip-directories to skip-dirs * Update internal/app.go Co-authored-by: Daniel Pacak <pacak.daniel@gmail.com> * refactor: add some context in the warning message * chore(README): update Co-authored-by: Daniel Pacak <pacak.daniel@gmail.com>
This commit is contained in:
@@ -188,6 +188,12 @@ var (
|
||||
EnvVars: []string{"TRIVY_LIST_ALL_PKGS"},
|
||||
}
|
||||
|
||||
skipDirectories = cli.StringFlag{
|
||||
Name: "skip-dirs",
|
||||
Usage: "specify the directory where the traversal is skipped",
|
||||
EnvVars: []string{"TRIVY_SKIP_DIRS"},
|
||||
}
|
||||
|
||||
globalFlags = []cli.Flag{
|
||||
&quietFlag,
|
||||
&debugFlag,
|
||||
@@ -214,6 +220,7 @@ var (
|
||||
&lightFlag,
|
||||
&ignorePolicy,
|
||||
&listAllPackages,
|
||||
&skipDirectories,
|
||||
}
|
||||
|
||||
// deprecated options
|
||||
@@ -368,6 +375,7 @@ func NewFilesystemCommand() *cli.Command {
|
||||
&noProgressFlag,
|
||||
&ignorePolicy,
|
||||
&listAllPackages,
|
||||
&skipDirectories,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -398,6 +406,7 @@ func NewRepositoryCommand() *cli.Command {
|
||||
&noProgressFlag,
|
||||
&ignorePolicy,
|
||||
&listAllPackages,
|
||||
&skipDirectories,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ func run(c config.Config, initializeScanner InitializeScanner) error {
|
||||
VulnType: c.VulnType,
|
||||
ScanRemovedPackages: c.ScanRemovedPkgs, // this is valid only for image subcommand
|
||||
ListAllPackages: c.ListAllPkgs,
|
||||
SkipDirectories: c.SkipDirectories,
|
||||
}
|
||||
log.Logger.Debugf("Vulnerability type: %s", scanOptions.VulnType)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -13,15 +14,19 @@ type ArtifactConfig struct {
|
||||
Timeout time.Duration
|
||||
ClearCache bool
|
||||
|
||||
skipDirectories string
|
||||
SkipDirectories []string
|
||||
|
||||
// this field is populated in Init()
|
||||
Target string
|
||||
}
|
||||
|
||||
func NewArtifactConfig(c *cli.Context) ArtifactConfig {
|
||||
return ArtifactConfig{
|
||||
Input: c.String("input"),
|
||||
Timeout: c.Duration("timeout"),
|
||||
ClearCache: c.Bool("clear-cache"),
|
||||
Input: c.String("input"),
|
||||
Timeout: c.Duration("timeout"),
|
||||
ClearCache: c.Bool("clear-cache"),
|
||||
skipDirectories: c.String("skip-dirs"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,5 +45,9 @@ func (c *ArtifactConfig) Init(args cli.Args, logger *zap.SugaredLogger) (err err
|
||||
c.Target = args.First()
|
||||
}
|
||||
|
||||
if c.skipDirectories != "" {
|
||||
c.SkipDirectories = strings.Split(c.skipDirectories, ",")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user