From 5b78051b3a023e78634e8985807a7beddaa0aaa9 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 21 Feb 2022 22:09:26 -0500 Subject: add cvss/calc.go and cmd/cvss.go (cvss calculator) --- cmd/cvss.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cmd/cvss.go (limited to 'cmd') diff --git a/cmd/cvss.go b/cmd/cvss.go new file mode 100644 index 0000000..d704811 --- /dev/null +++ b/cmd/cvss.go @@ -0,0 +1,33 @@ +package cmd + +import ( + "encoding/json" + "github.com/pablotron/cvez/cvss" + "github.com/spf13/cobra" + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" + "os" + "time" +) + +var cvssCmd = &cobra.Command{ + Use: "cvss", + Short: "CVSS vector calculator.", + Long: `Common Vulnerability Scoring System (CVSS) vector calculator.`, + + Run: func(cmd *cobra.Command, args []string) { + // set global logging options + zerolog.TimeFieldFormat = time.RFC3339 + zerolog.SetGlobalLevel(zerolog.InfoLevel) + + // parse args, write result + e := json.NewEncoder(os.Stdout) + if err := e.Encode(cvss.Calc(args)); err != nil { + log.Error().Err(err).Msg("Encode") + } + }, +} + +func init() { + rootCmd.AddCommand(cvssCmd) +} -- cgit v1.2.3