mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 07:10:41 -08:00
feat(option): warn "--list-all-pkgs" with "--format table" (#1632)
Co-authored-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
@@ -93,6 +93,43 @@ func TestOption_Init(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "happy path with list-all-pkgs warning",
|
||||
args: []string{"--format", "table", "--list-all-pkgs", "centos:7"},
|
||||
logs: []string{
|
||||
`"--list-all-pkgs" cannot be used with "--format table". Try "--format json" or other formats.`,
|
||||
},
|
||||
want: Option{
|
||||
ReportOption: option.ReportOption{
|
||||
Severities: []dbTypes.Severity{dbTypes.SeverityCritical},
|
||||
Format: "table",
|
||||
Output: os.Stdout,
|
||||
VulnType: []string{types.VulnTypeOS, types.VulnTypeLibrary},
|
||||
SecurityChecks: []string{types.SecurityCheckVulnerability},
|
||||
ListAllPkgs: true,
|
||||
},
|
||||
ArtifactOption: option.ArtifactOption{
|
||||
Target: "centos:7",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "happy path without list-all-pkgs warning",
|
||||
args: []string{"--format", "json", "--list-all-pkgs", "centos:7"},
|
||||
want: Option{
|
||||
ReportOption: option.ReportOption{
|
||||
Severities: []dbTypes.Severity{dbTypes.SeverityCritical},
|
||||
Format: "json",
|
||||
Output: os.Stdout,
|
||||
VulnType: []string{types.VulnTypeOS, types.VulnTypeLibrary},
|
||||
SecurityChecks: []string{types.SecurityCheckVulnerability},
|
||||
ListAllPkgs: true,
|
||||
},
|
||||
ArtifactOption: option.ArtifactOption{
|
||||
Target: "centos:7",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid option combination: --template enabled without --format",
|
||||
args: []string{"--template", "@contrib/gitlab.tpl", "gitlab/gitlab-ce:12.7.2-ce.0"},
|
||||
@@ -177,6 +214,7 @@ func TestOption_Init(t *testing.T) {
|
||||
set.Bool("reset", false, "")
|
||||
set.Bool("skip-db-update", false, "")
|
||||
set.Bool("download-db-only", false, "")
|
||||
set.Bool("list-all-pkgs", false, "")
|
||||
set.String("severity", "CRITICAL", "")
|
||||
set.String("vuln-type", "os,library", "")
|
||||
set.String("security-checks", "vuln", "")
|
||||
|
||||
Reference in New Issue
Block a user