diff options
-rw-r--r-- | cmd/cmd.go | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -5,9 +5,11 @@ import ( "encoding/json" "github.com/pablotron/cvez/datadir" "github.com/pablotron/cvez/dbstore" + "github.com/pablotron/cvez/nvdmirror" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "os" + "path/filepath" "strings" "time" ) @@ -42,6 +44,26 @@ func getDb() dbstore.DbStore { return db } +// Get cache. +func getCache() nvdmirror.JsonCache { + // get path to cache directory + cacheDir, err := datadir.CacheDir() + if err != nil { + log.Error().Err(err).Msg("CacheDir") + os.Exit(-1) + } + + // create cache + cache, err := nvdmirror.NewJsonCache(filepath.Join(cacheDir, "cache.json.gz")) + if err != nil { + log.Error().Err(err).Msg("NewJsonCache") + os.Exit(-1) + } + + // return cache + return cache +} + // JSON encode data and write it to standard output func jsonEncode(data interface{}) { // search for CVEs, write result |