Added support of list-all-packages (#574)

* Added support of list-all-packages

* updated Readme

* Added library packages and fixed import name

* updated env var name

* Sorting packages in scan
This commit is contained in:
rahul2393
2020-07-30 00:41:38 +05:30
committed by GitHub
parent 469c0b41df
commit 88aaffa957
8 changed files with 220 additions and 5 deletions

View File

@@ -182,6 +182,12 @@ var (
EnvVars: []string{"TRIVY_IGNORE_POLICY"},
}
listAllPackages = cli.BoolFlag{
Name: "list-all-pkgs",
Usage: "enabling the option will output all packages regardless of vulnerability",
EnvVars: []string{"TRIVY_LIST_ALL_PKGS"},
}
globalFlags = []cli.Flag{
&quietFlag,
&debugFlag,
@@ -207,6 +213,7 @@ var (
&timeoutFlag,
&lightFlag,
&ignorePolicy,
&listAllPackages,
}
// deprecated options
@@ -360,6 +367,7 @@ func NewFilesystemCommand() *cli.Command {
&timeoutFlag,
&noProgressFlag,
&ignorePolicy,
&listAllPackages,
},
}
}
@@ -389,6 +397,7 @@ func NewRepositoryCommand() *cli.Command {
&timeoutFlag,
&noProgressFlag,
&ignorePolicy,
&listAllPackages,
},
}
}

View File

@@ -76,6 +76,7 @@ func run(c config.Config, initializeScanner InitializeScanner) error {
scanOptions := types.ScanOptions{
VulnType: c.VulnType,
ScanRemovedPackages: c.ScanRemovedPkgs, // this is valid only for image subcommand
ListAllPackages: c.ListAllPkgs,
}
log.Logger.Debugf("Vulnerability type: %s", scanOptions.VulnType)

View File

@@ -9,11 +9,13 @@ import (
type ImageConfig struct {
ScanRemovedPkgs bool
ListAllPkgs bool
}
func NewImageConfig(c *cli.Context) ImageConfig {
return ImageConfig{
ScanRemovedPkgs: c.Bool("removed-pkgs"),
ListAllPkgs: c.Bool("list-all-pkgs"),
}
}