diff --git a/README.md b/README.md index ef39b4c5..36a8abf5 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,6 @@ Options: provides help text on how to use nancy -no-color indicate output should not be colorized - -noColor - indicate output should not be colorized (deprecated: please use no-color) -output string Styling for output format. ["json-pretty" "text" "csv" "json"] (default "text") -quiet diff --git a/configuration/parse.go b/configuration/parse.go index e03f5dc5..c0d8a6a3 100644 --- a/configuration/parse.go +++ b/configuration/parse.go @@ -32,7 +32,6 @@ func Parse(args []string) (Configuration, error) { config := Configuration{} var excludeVulnerabilityFilePath string var outputFormat string - var noColorDeprecated bool var outputFormats = map[string]logrus.Formatter{ "json": &audit.JsonFormatter{}, @@ -43,7 +42,6 @@ func Parse(args []string) (Configuration, error) { flag.BoolVar(&config.Help, "help", false, "provides help text on how to use nancy") flag.BoolVar(&config.NoColor, "no-color", false, "indicate output should not be colorized") - flag.BoolVar(&noColorDeprecated, "noColor", false, "indicate output should not be colorized (deprecated: please use no-color)") flag.BoolVar(&config.Quiet, "quiet", false, "indicate output should contain only packages with vulnerabilities") flag.BoolVar(&config.Version, "version", false, "prints current nancy version") flag.BoolVar(&config.CleanCache, "clean-cache", false, "Deletes local cache directory") @@ -69,13 +67,6 @@ func Parse(args []string) (Configuration, error) { config.Path = args[len(args)-1] } - if noColorDeprecated == true { - fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") - fmt.Println("!!!! DEPRECATION WARNING : Please change 'noColor' param to be 'no-color'. This one will be removed in a future release. !!!!") - fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") - config.NoColor = noColorDeprecated - } - if outputFormats[outputFormat] != nil { config.Formatter = outputFormats[outputFormat] } else { diff --git a/configuration/parse_test.go b/configuration/parse_test.go index 34a63bc9..af55e258 100644 --- a/configuration/parse_test.go +++ b/configuration/parse_test.go @@ -46,14 +46,13 @@ CVN-543`) expectedConfig Configuration expectedErr error }{ - "defaults": {args: []string{"/tmp/go.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go.sum"}, expectedErr: nil}, - "help": {args: []string{"-help", "/tmp/go2.sum"}, expectedConfig: Configuration{Help: true, NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go2.sum"}, expectedErr: nil}, - "no color": {args: []string{"-no-color", "/tmp/go2.sum"}, expectedConfig: Configuration{NoColor: true, Quiet: false, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go2.sum"}, expectedErr: nil}, - "no color (deprecated)": {args: []string{"-noColor", "/tmp/go2.sum"}, expectedConfig: Configuration{NoColor: true, Quiet: false, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go2.sum"}, expectedErr: nil}, - "quiet": {args: []string{"-quiet", "/tmp/go3.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: true, Version: false, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go3.sum"}, expectedErr: nil}, - "version": {args: []string{"-version", "/tmp/go4.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: true, CveList: types.CveListFlag{}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go4.sum"}, expectedErr: nil}, - "exclude vulnerabilities": {args: []string{"-exclude-vulnerability=CVE123,CVE988", "/tmp/go5.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{Cves: []string{"CVE123", "CVE988"}}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go5.sum"}, expectedErr: nil}, - "std in as input": {args: []string{}, expectedConfig: Configuration{UseStdIn: true, Formatter: &audit.AuditLogTextFormatter{}}, expectedErr: nil}, + "defaults": {args: []string{"/tmp/go.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{}, Path: "/tmp/go.sum"}, expectedErr: nil}, + "help": {args: []string{"-help", "/tmp/go2.sum"}, expectedConfig: Configuration{Help: true, NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{}, Path: "/tmp/go2.sum"}, expectedErr: nil}, + "no color": {args: []string{"-no-color", "/tmp/go2.sum"}, expectedConfig: Configuration{NoColor: true, Quiet: false, Version: false, CveList: types.CveListFlag{}, Path: "/tmp/go2.sum"}, expectedErr: nil}, + "quiet": {args: []string{"-quiet", "/tmp/go3.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: true, Version: false, CveList: types.CveListFlag{}, Path: "/tmp/go3.sum"}, expectedErr: nil}, + "version": {args: []string{"-version", "/tmp/go4.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: true, CveList: types.CveListFlag{}, Path: "/tmp/go4.sum"}, expectedErr: nil}, + "exclude vulnerabilities": {args: []string{"-exclude-vulnerability=CVE123,CVE988", "/tmp/go5.sum"}, expectedConfig: Configuration{NoColor: false, Quiet: false, Version: false, CveList: types.CveListFlag{Cves: []string{"CVE123", "CVE988"}}, Path: "/tmp/go5.sum"}, expectedErr: nil}, + "std in as input": {args: []string{}, expectedConfig: Configuration{UseStdIn: true}, expectedErr: nil}, "path but invalid arg": {args: []string{"-invalid", "/tmp/go6.sum"}, expectedConfig: Configuration{}, expectedErr: errors.New("flag provided but not defined: -invalid")}, "exclude vulnerabilities when has comments": {args: []string{"-exclude-vulnerability-file=" + commentedFile.Name(), "/tmp/go14.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{Cves: []string{"CVN-111", "CVN-123", "CVN-543"}}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go14.sum"}, expectedErr: nil}, "exclude vulnerabilities with sane file": {args: []string{"-exclude-vulnerability-file=" + file.Name(), "/tmp/go7.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{Cves: []string{"CVF-000", "CVF-123", "CVF-9999"}}, Formatter: &audit.AuditLogTextFormatter{}, Path: "/tmp/go7.sum"}, expectedErr: nil},