diff options
Diffstat (limited to 'internal/feed/feed.go')
-rw-r--r-- | internal/feed/feed.go | 62 |
1 files changed, 2 insertions, 60 deletions
diff --git a/internal/feed/feed.go b/internal/feed/feed.go index affa5d2..3a6e695 100644 --- a/internal/feed/feed.go +++ b/internal/feed/feed.go @@ -1,15 +1,5 @@ package feed -import ( - "encoding/json" - "fmt" -) - -const ( - CvssVersion31 = iota // CVSS version 3.1 - CvssVersion20 // CVSS version 2.0 -) - // TODO: parse cpe, cve id // CVE metadata @@ -126,58 +116,10 @@ type ItemConfigurations struct { Nodes []ConfigurationNode `json:"nodes"` } -// CVSS version. -type CvssV3Version int - -// Unmarshal CVSS version from JSON. -func (me *CvssV3Version) UnmarshalJSON(b []byte) error { - // decode string, check for error - var s string - if err := json.Unmarshal(b, &s); err != nil { - return err - } - - // check value - switch s { - case "3.1": - *me = CvssVersion31 - default: - // return error - return fmt.Errorf("unknown CVSS V3 version: %s", s) - } - - // return success - return nil -} - -// CVSS V2 version. -type CvssV2Version int - -// Unmarshal CVSS version from JSON. -func (me *CvssV2Version) UnmarshalJSON(b []byte) error { - // decode string, check for error - var s string - if err := json.Unmarshal(b, &s); err != nil { - return err - } - - // check value - switch s { - case "2.0": - *me = CvssVersion20 - default: - // return error - return fmt.Errorf("unknown CVSS V2 version: %s", s) - } - - // return success - return nil -} - // CVSS V3 type CvssV3 struct { // CVSS V3 version - Version CvssV3Version `json:"version"` + Version V3Version `json:"version"` // CVSS V3 vector string (FIXME: add custom type) VectorString string `json:"vectorString"` @@ -220,7 +162,7 @@ type BaseMetricV3 struct { // CVSS V2 type CvssV2 struct { // CVSS V2 version - Version CvssV2Version `json:"version"` + Version V2Version `json:"version"` // CVSS V3 vector string (FIXME: add custom type) VectorString string `json:"vectorString"` |