package cmd import ( // "encoding/json" "github.com/pablotron/cvez/nvdmirror" "github.com/spf13/cobra" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "time" ) var updateCmd = &cobra.Command{ Use: "update", Aliases: []string { "up" }, Short: "Update mirror.", Long: `Update local NVD mirror.`, Run: func(cmd *cobra.Command, args []string) { // set global logging options zerolog.TimeFieldFormat = time.RFC3339 zerolog.SetGlobalLevel(zerolog.InfoLevel) // create cache cache, err := nvdmirror.NewJsonCache("stuff/cache.json.gz") if err != nil { log.Error().Err(err).Msg("NewJsonCache") } defer cache.Close() // custom sync config config := nvdmirror.SyncConfig { Cve11BaseUrl: "https://pmdn.org/nvdmirror", CpeMatch10BaseUrl: "https://pmdn.org/nvdmirror", Cpe23DictUrl: "https://pmdn.org/nvdmirror", } // sync data, get changed data nvdmirror.Sync(config, &cache, "stuff") }, } func init() { rootCmd.AddCommand(updateCmd) }