aboutsummaryrefslogtreecommitdiff
path: root/cvss/scores.go
blob: 0f6b6d31ee1f0329363acf0ff21f7842eddce26a (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
package cvss

// 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 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 Scores{}, err
  }

  // convert temporal from float to Score
  tempScore, err := NewScore(temporal)
  if err != nil {
    return Scores{}, err
  }

  // convert env from float to Score
  envScore, err := NewScore(env)
  if err != nil {
    return Scores{}, err
  }

  // return success
  return Scores {
    Base: baseScore,
    Temporal: tempScore,
    Env: envScore,
  }, nil
}