diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-02-07 12:19:10 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-02-07 12:19:10 -0500 |
commit | b5bf40450de4d4aaf13225a9d245e33c8af7db70 (patch) | |
tree | 5f448612a62378815de3dca07322a3b96fcba271 | |
parent | e24e6af76a1dcd64889f47e3fae03d7c3fa6f7a3 (diff) | |
download | cvez-b5bf40450de4d4aaf13225a9d245e33c8af7db70.tar.bz2 cvez-b5bf40450de4d4aaf13225a9d245e33c8af7db70.zip |
s/v2Scores/Scores/
-rw-r--r-- | cvss/v2scores.go | 32 | ||||
-rw-r--r-- | cvss/v2scores_test.go | 8 | ||||
-rw-r--r-- | cvss/v2vector.go | 4 |
3 files changed, 22 insertions, 22 deletions
diff --git a/cvss/v2scores.go b/cvss/v2scores.go index 990b805..3100b19 100644 --- a/cvss/v2scores.go +++ b/cvss/v2scores.go @@ -4,43 +4,43 @@ import ( "math" ) -// CVSS v2 base, temporal, and environmental scores. -type v2Scores struct { - base Score // base score - temporal Score // temporal score - env Score // environmental score +// CVSS score set. +type Scores struct { + Base Score `json:"base"` // base score + Temporal Score `json:"temporal"` // temporal score + Env Score `json:"env"` // environmental score } -// Create new CVSS v2Scores from floats. -func newV2ScoresFromFloats(base, temporal, env float64) (v2Scores, error) { +// Create new score set from floats. +func NewScores(base, temporal, env float64) (Scores, error) { // convert base from float to Score baseScore, err := NewScore(base) if err != nil { - return v2Scores{}, err + return Scores{}, err } // convert temporal from float to Score tempScore, err := NewScore(temporal) if err != nil { - return v2Scores{}, err + return Scores{}, err } // convert env from float to Score envScore, err := NewScore(env) if err != nil { - return v2Scores{}, err + return Scores{}, err } // return success - return v2Scores { - base: baseScore, - temporal: tempScore, - env: envScore, + return Scores { + Base: baseScore, + Temporal: tempScore, + Env: envScore, }, nil } // Create new v2 scores from v2 vector. -func newV2Scores(v v2Vector) (v2Scores, error) { +func newScoresFromV2Vector(v v2Vector) (Scores, error) { // CVSS v2 (https://www.first.org/cvss/v2/guide 3.2.1) // // Impact = 10.41*(1-(1-ConfImpact)*(1-IntegImpact)*(1-AvailImpact)) @@ -262,5 +262,5 @@ func newV2Scores(v v2Vector) (v2Scores, error) { } // build and return result - return newV2ScoresFromFloats(baseScore, tempScore, envScore) + return NewScores(baseScore, tempScore, envScore) } diff --git a/cvss/v2scores_test.go b/cvss/v2scores_test.go index 0d6ab87..f35904c 100644 --- a/cvss/v2scores_test.go +++ b/cvss/v2scores_test.go @@ -5,7 +5,7 @@ import ( "testing" ) -func TestNewV2ScoresFromFloats(t *testing.T) { +func TestNewScores(t *testing.T) { // test out of bound errors failTests := []struct { name string // test name @@ -23,7 +23,7 @@ func TestNewV2ScoresFromFloats(t *testing.T) { for _, test := range(failTests) { t.Run(test.name, func(t *testing.T) { - got, err := newV2ScoresFromFloats(test.vals[0], test.vals[1], test.vals[2]) + got, err := NewScores(test.vals[0], test.vals[1], test.vals[2]) if err == nil { t.Errorf("got %v, exp error", got) } @@ -31,7 +31,7 @@ func TestNewV2ScoresFromFloats(t *testing.T) { } } -func TestNewV2Scores(t *testing.T) { +func TestNewScoresFromV2Vector(t *testing.T) { // test vectors from section 3.3 passTests := []struct { name string // test name @@ -211,7 +211,7 @@ func TestNewV2Scores(t *testing.T) { for _, test := range(passTests) { t.Run(test.name, func(t *testing.T) { // build expected result - exp, err := newV2ScoresFromFloats(test.exps[0], test.exps[1], test.exps[2]) + exp, err := NewScores(test.exps[0], test.exps[1], test.exps[2]) if err != nil { t.Error(err) return diff --git a/cvss/v2vector.go b/cvss/v2vector.go index 14a4afb..e015544 100644 --- a/cvss/v2vector.go +++ b/cvss/v2vector.go @@ -42,8 +42,8 @@ func (v v2Vector) Metrics() []Metric { } // Return numerical scores for this vector. -func (v v2Vector) Scores() (v2Scores, error) { - return newV2Scores(v) +func (v v2Vector) Scores() (Scores, error) { + return newScoresFromV2Vector(v) } // Create CVSS 2.0 vector from string. |