aboutsummaryrefslogtreecommitdiff
path: root/dbstore/dbstore.go
diff options
context:
space:
mode:
Diffstat (limited to 'dbstore/dbstore.go')
-rw-r--r--dbstore/dbstore.go55
1 files changed, 0 insertions, 55 deletions
diff --git a/dbstore/dbstore.go b/dbstore/dbstore.go
index 00b8fe2..7f22f3b 100644
--- a/dbstore/dbstore.go
+++ b/dbstore/dbstore.go
@@ -5,7 +5,6 @@ import (
"context"
db_sql "database/sql"
"embed"
- "encoding/json"
"fmt"
_ "github.com/mattn/go-sqlite3"
"github.com/pablotron/cvez/cpedict"
@@ -160,60 +159,6 @@ func (me DbStore) AddCpeDictionary(ctx context.Context, dict cpedict.Dictionary)
return tx.Commit()
}
-//go:generate stringer -linecomment -type=CpeSearchType
-
-// CPE search type
-type CpeSearchType byte
-
-const (
- CpeSearchAll CpeSearchType = iota //cpe-search-all
- CpeSearchTitle // cpe-search-title
- CpeSearchRef // cpe-search-ref
-)
-
-// title search result
-type CpeSearchRow struct {
- // Database CPE ID
- CpeId int64 `json:"cpe_id"`
-
- // v2.3 formatting string
- Cpe23 string `json:"cpe23"`
-
- // titles
- Titles []cpedict.Title `json:"titles"`
-
- // references
- Refs []cpedict.Reference `json:"refs"`
-
- // search result rank
- Rank float32 `json:"rank"`
-}
-
-// Unmarshal CPE search row from row set.
-func unmarshalCpeSearchRow(rows *db_sql.Rows) (CpeSearchRow, error) {
- var r CpeSearchRow
- var titles string
- var refs string
-
- // get row values
- if err := rows.Scan(&r.CpeId, &r.Cpe23, &titles, &refs, &r.Rank); err != nil {
- return r, err
- }
-
- // unmarshal titles
- if err := json.Unmarshal([]byte(titles), &r.Titles); err != nil {
- return r, err
- }
-
- // unmarshal refs
- if err := json.Unmarshal([]byte(refs), &r.Refs); err != nil {
- return r, err
- }
-
- // return sccess
- return r, nil
-}
-
// search CPEs
func (me DbStore) CpeSearch(
ctx context.Context,