aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbstore/dbstore.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/dbstore/dbstore.go b/dbstore/dbstore.go
index 11ad02c..f432054 100644
--- a/dbstore/dbstore.go
+++ b/dbstore/dbstore.go
@@ -8,6 +8,7 @@ import (
"fmt"
_ "github.com/mattn/go-sqlite3"
"github.com/pablotron/cvez/cpedict"
+ "github.com/pablotron/cvez/cpematch"
)
//go:embed sql
@@ -104,6 +105,12 @@ func getQueries(ids []string) (map[string]string, error) {
return r, nil
}
+var addCpeDictionaryQueryIds = []string {
+ "cpe/insert",
+ "cpe/insert-title",
+ "cpe/insert-ref",
+}
+
// import CPE dictionary
func (me DbStore) AddCpeDictionary(ctx context.Context, dict cpedict.Dictionary) error {
// lazy-init db
@@ -112,8 +119,7 @@ func (me DbStore) AddCpeDictionary(ctx context.Context, dict cpedict.Dictionary)
}
// build query map
- queryIds := []string { "insert-cpe", "insert-title", "insert-ref" }
- queries, err := getQueries(queryIds)
+ queries, err := getQueries(addCpeDictionaryQueryIds)
if err != nil {
return err
}
@@ -138,7 +144,7 @@ func (me DbStore) AddCpeDictionary(ctx context.Context, dict cpedict.Dictionary)
// add items
for _, item := range(dict.Items) {
// add cpe
- rs, err := sts["insert-cpe"].ExecContext(ctx, item.CpeUri, item.Cpe23Item.Name)
+ rs, err := sts["cpe/insert"].ExecContext(ctx, item.CpeUri, item.Cpe23Item.Name)
if err != nil {
return err
}
@@ -151,7 +157,7 @@ func (me DbStore) AddCpeDictionary(ctx context.Context, dict cpedict.Dictionary)
// add titles
for _, title := range(item.Titles) {
- _, err := sts["insert-title"].ExecContext(ctx, id, title.Lang, title.Text)
+ _, err := sts["cpe/insert-title"].ExecContext(ctx, id, title.Lang, title.Text)
if err != nil {
return err
}
@@ -159,7 +165,7 @@ func (me DbStore) AddCpeDictionary(ctx context.Context, dict cpedict.Dictionary)
// add refs
for _, ref := range(item.References) {
- _, err := sts["insert-ref"].ExecContext(ctx, id, ref.Href, ref.Text)
+ _, err := sts["cpe/insert-ref"].ExecContext(ctx, id, ref.Href, ref.Text)
if err != nil {
return err
}