aboutsummaryrefslogtreecommitdiff
path: root/dbstore/cisasearchrow.go
blob: 19dd04c60f812305b3c6dfea1e7de0203d7991c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package dbstore

import (
  "github.com/pablotron/cvez/feed"
  "github.com/pablotron/cvez/rfc3339"
)

// CisaSearch() result
type CisaSearchRow struct {
  Id int64 `json:"vuln_id"` // CISA vulnerability ID
  CatId int64 `json:"cat_id"` // CISA catalog ID
  CveId feed.CveId `json:"cve_id"` // NVD CVE ID
  Vendor string `json:"vendor"` // Vendor name
  Product string `json:"product"` // Product name
  Name string `json:"name"` // Vulnerability name
  Description string `json:"description"` // Vulnerability description
  AddedAt rfc3339.Date `json:"added_at"` // Date added to catalog
  Action string `json:"action"` // Action required
  DueAt rfc3339.Date `json:"due_at"` // Date due
  Rank float32 `json:"rank"` // search result rank
}

// sort.Interface for CisaSearchRow slice, sorted by rank.
type byRank []CisaSearchRow

// Required by sort.Interface.
func (r byRank) Len() int {
  return len(r)
}

// Required by sort.Interface.
func (r byRank) Less(i, j int) bool {
  return r[i].Rank < r[j].Rank
}

// Required by sort.Interface.
func (r byRank) Swap(i, j int) {
  r[i], r[j] = r[j], r[i]
}