aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/feed.go
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-02-01 12:48:15 -0500
committerPaul Duncan <pabs@pablotron.org>2022-02-01 12:48:15 -0500
commit465f427a04c2f10bc5163f6bceef13693f7e99e6 (patch)
treead4c963ee1b918fee01436030ceda2e6c882b225 /internal/feed/feed.go
parentf4f3bf7f03e790b5d98004de3498c102bdac50ad (diff)
downloadcvez-465f427a04c2f10bc5163f6bceef13693f7e99e6.tar.bz2
cvez-465f427a04c2f10bc5163f6bceef13693f7e99e6.zip
internal/feed: add v2impact, v3impact, and tests
Diffstat (limited to 'internal/feed/feed.go')
-rw-r--r--internal/feed/feed.go45
1 files changed, 5 insertions, 40 deletions
diff --git a/internal/feed/feed.go b/internal/feed/feed.go
index b9f7678..9c27fb0 100644
--- a/internal/feed/feed.go
+++ b/internal/feed/feed.go
@@ -11,9 +11,6 @@ const (
Medium // medium complexity/priv req
High // high complexity/priv req
- Complete // complete integrity impact
- Partial // partial integrity impact
-
Critical // critical severity
CvssVersion31 // CVSS version 3.1
@@ -24,38 +21,6 @@ const (
// TODO: parse cpe
-// CVSS integrity/availability impact level
-type ImpactLevel int
-
-// Unmarshal CVSS integrity/availability impact level from JSON.
-func (me *ImpactLevel) 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 "NONE":
- *me = None
- case "LOW":
- *me = Low
- case "PARTIAL":
- *me = Partial
- case "HIGH":
- *me = High
- case "COMPLETE":
- *me = Complete
- default:
- // return error
- return fmt.Errorf("unknown impact level: %s", s)
- }
-
- // return success
- return nil
-}
-
// CVSS score
type Score float32
@@ -381,10 +346,10 @@ type CvssV3 struct {
Scope V3Scope `json:"scope"`
// integrity impact
- IntegrityImpact ImpactLevel `json:"integrityImpact"`
+ IntegrityImpact V3Impact `json:"integrityImpact"`
// availability impact
- AvailabilityImpact ImpactLevel `json:"availabilityImpact"`
+ AvailabilityImpact V3Impact `json:"availabilityImpact"`
// base score
BaseScore Score `json:"baseScore"`
@@ -417,9 +382,9 @@ type CvssV2 struct {
// authentication
Authentication Authentication `json:"authentication"`
- ConfidentialityImpact ImpactLevel `json:"confidentialityImpact"`
- IntegrityImpact ImpactLevel `json:"integrityImpact"`
- AvailabilityImpact ImpactLevel `json:"availabilityImpact"`
+ ConfidentialityImpact V2Impact `json:"confidentialityImpact"`
+ IntegrityImpact V2Impact `json:"integrityImpact"`
+ AvailabilityImpact V2Impact `json:"availabilityImpact"`
// base score
BaseScore Score `json:"baseScore"`