aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/update.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/cmd/update.go b/cmd/update.go
new file mode 100644
index 0000000..fe234ed
--- /dev/null
+++ b/cmd/update.go
@@ -0,0 +1,46 @@
+package cmd
+
+import (
+ // "encoding/json"
+ "github.com/pablotron/cvez/nvdmirror"
+ "github.com/spf13/cobra"
+ "github.com/rs/zerolog"
+ "github.com/rs/zerolog/log"
+ "os"
+ "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
+ urls := nvdmirror.Urls {
+ Cve11Base: "https://pmdn.org/nvdmirror",
+ }
+
+ // sync data
+ if err := nvdmirror.Sync(urls, &cache, "stuff"); err != nil {
+ log.Error().Err(err).Msg("Sync")
+ os.Exit(-1)
+ }
+ },
+}
+
+func init() {
+ rootCmd.AddCommand(updateCmd)
+}