aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/cmd.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/cmd/cmd.go b/cmd/cmd.go
index 4b09d18..80c1527 100644
--- a/cmd/cmd.go
+++ b/cmd/cmd.go
@@ -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