aboutsummaryrefslogtreecommitdiff
path: root/cvss/v2key.go
blob: 740d26dfa53335e70543519104f30eb052d3115b (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package cvss

//go:generate stringer -linecomment -type=v2Key

// CVSS 2.0 metric key.
type v2Key byte

const (
  v2AccessVector v2Key = iota // AV
  v2AccessComplexity // AC
  v2Authentication // Au
  v2ConfidentialityImpact // C
  v2IntegrityImpact // I
  v2AvailabilityImpact // A
  v2Exploitability // E
  v2RemediationLevel // RL
  v2ReportConfidence // RC
  v2CollateralDamagePotential // CDP
  v2TargetDistribution // TD
  v2ConfidentialityRequirement // CR
  v2IntegrityRequirement // IR
  v2AvailabilityRequirement // AR

  v2InvalidKey // invalid
)

// CVSS V2 metric key info lut
var v2Keys = map[v2Key]struct {
  Name string
  Category Category
} {
  v2AccessVector: { "Access Vector", Base },
  v2AccessComplexity: { "Access Complexity", Base },
  v2Authentication: { "Authentication", Base },
  v2ConfidentialityImpact: { "Confidentiality Impact", Base },
  v2IntegrityImpact: { "Integrity Impact", Base },
  v2AvailabilityImpact: { "Availability Impact", Base },
  v2Exploitability: { "Exploitability", Temporal },
  v2RemediationLevel: { "Remediation Level", Temporal },
  v2ReportConfidence: { "Report Confidence", Temporal },
  v2CollateralDamagePotential: { "Collateral Damage Potential", Environmental },
  v2TargetDistribution: { "Target Distribution", Environmental },
  v2ConfidentialityRequirement: { "Confidentiality Requirement", Environmental },
  v2IntegrityRequirement: { "Integrity Requirement", Environmental },
  v2AvailabilityRequirement: { "Availability Requirement", Environmental },
}

// // v2 metric key IDs lut
// var v2KeyIds = map[string]v2Key {
//   "AV": v2AccessVector,
//   "AC": v2AccessComplexity,
//   "Au": v2Authentication,
//   "C": v2ConfidentialityImpact,
//   "I": v2IntegrityImpact,
//   "A": v2AvailabilityImpact,
//   "E": v2Exploitability,
//   "RL": v2RemediationLevel,
//   "RC": v2ReportConfidence,
//   "CDP": v2CollateralDamagePotential,
//   "TD": v2TargetDistribution,
//   "CR": v2ConfidentialityRequirement,
//   "IR": v2IntegrityRequirement,
//   "AR": v2AvailabilityRequirement,
// }
// 
// // Get metric key from string.
// func getV2KeyFromString(s string) (v2Key, error) {
//   k, ok := v2KeyIds[s]
//   if ok {
//     return k, nil
//   } else {
//     return v2InvalidKey, newBadKey(V20, s)
//   }
// }

// Get metric key name.
func (k v2Key) Name() string {
  if data, ok := v2Keys[k]; ok {
    return data.Name
  } else {
    return "invalid"
  }
}

// Get metric key category.
func (k v2Key) Category() Category {
  if data, ok := v2Keys[k]; ok {
    return data.Category
  } else {
    return InvalidCategory
  }
}