diff options
Diffstat (limited to 'internal/cvss/cvss.go')
-rw-r--r-- | internal/cvss/cvss.go | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/internal/cvss/cvss.go b/internal/cvss/cvss.go index b92d819..e8c62a1 100644 --- a/internal/cvss/cvss.go +++ b/internal/cvss/cvss.go @@ -6,16 +6,16 @@ import ( "strings" ) -//go:generate stringer -linecomment -type=v2MetricKey +//go:generate stringer -linecomment -type=v2Key //go:generate stringer -linecomment -type=v2Metric -//go:generate stringer -linecomment -type=v3MetricKey +//go:generate stringer -linecomment -type=v3Key //go:generate stringer -linecomment -type=v3Metric -// CVSS metric key. -type v2MetricKey byte +// CVSS 2.0 metric key. +type v2Key byte const ( - v2AccessVector v2MetricKey = iota // AV + v2AccessVector v2Key = iota // AV v2AccessComplexity // AC v2Authentication // Au v2ConfidentialityImpact // C @@ -30,11 +30,11 @@ const ( v2IntegrityRequirement // IR v2AvailabilityRequirement // AR - v2InvalidMetricKey // invalid + v2InvalidKey // invalid ) // CVSS V2 metric key info lut -var v2MetricKeys = map[v2MetricKey]struct { +var v2Keys = map[v2Key]struct { Name string Category Category } { @@ -55,7 +55,7 @@ var v2MetricKeys = map[v2MetricKey]struct { } // v2 metric key IDs lut -var v2MetricKeyIds = map[string]v2MetricKey { +var v2KeyIds = map[string]v2Key { "AV": v2AccessVector, "AC": v2AccessComplexity, "Au": v2Authentication, @@ -73,23 +73,23 @@ var v2MetricKeyIds = map[string]v2MetricKey { } // Get metric key from string. -func getV2MetricKeyFromString(s string) (v2MetricKey, error) { - k, ok := v2MetricKeyIds[s] +func getV2KeyFromString(s string) (v2Key, error) { + k, ok := v2KeyIds[s] if ok { return k, nil } else { - return v2InvalidMetricKey, fmt.Errorf("invalid metric key: %s", s) + return v2InvalidKey, fmt.Errorf("invalid metric key: %s", s) } } // Get metric key name. -func (k v2MetricKey) Name() string { - return v2MetricKeys[k].Name +func (k v2Key) Name() string { + return v2Keys[k].Name } // Get metric key category. -func (k v2MetricKey) Category() Category { - return v2MetricKeys[k].Category +func (k v2Key) Category() Category { + return v2Keys[k].Category } // CVSS v2 metric value @@ -169,7 +169,7 @@ const ( ) // map of metrics to metric keys -var v2MetricKeyLut = map[v2Metric]v2MetricKey { +var v2KeyLut = map[v2Metric]v2Key { v2AVNetwork: v2AccessVector, v2AVAdjacentNetwork: v2AccessVector, v2AVLocal: v2AccessVector, @@ -325,8 +325,8 @@ func getV2MetricFromString(s string) (v2Metric, error) { } // Get CVSS 2.0 metric key. -func (m v2Metric) Key() MetricKey { - k, _ := v2MetricKeyLut[m] +func (m v2Metric) Key() Key { + k, _ := v2KeyLut[m] return k } @@ -386,10 +386,10 @@ func newV2Vector(s string) (Vector, error) { } // CVSS v3 metric key -type v3MetricKey byte +type v3Key byte const ( - v3AttackVector v3MetricKey = iota // AV + v3AttackVector v3Key = iota // AV v3AttackComplexity // AC v3PrivilegesRequired // PR v3UserInteraction // UI @@ -412,11 +412,11 @@ const ( v3ModifiedIntegrity // MI v3ModifiedAvailability // MA - v3InvalidMetricKey // invalid + v3InvalidKey // invalid ) // CVSS v3 metric key info lut -var v3MetricKeys = map[v3MetricKey]struct { +var v3Keys = map[v3Key]struct { Name string Category Category } { @@ -445,7 +445,7 @@ var v3MetricKeys = map[v3MetricKey]struct { } // metric key IDs lut -var v3MetricKeyIds = map[string]v3MetricKey { +var v3KeyIds = map[string]v3Key { "AV": v3AttackVector, "AC": v3AttackComplexity, "PR": v3PrivilegesRequired, @@ -471,23 +471,23 @@ var v3MetricKeyIds = map[string]v3MetricKey { } // Get metric key from string. -func getV3MetricKeyFromString(s string) (v3MetricKey, error) { - k, ok := v3MetricKeyIds[s] +func getV3KeyFromString(s string) (v3Key, error) { + k, ok := v3KeyIds[s] if ok { return k, nil } else { - return v3InvalidMetricKey, fmt.Errorf("invalid metric key: %s", s) + return v3InvalidKey, fmt.Errorf("invalid metric key: %s", s) } } // Get metric key name. -func (k v3MetricKey) Name() string { - return v3MetricKeys[k].Name +func (k v3Key) Name() string { + return v3Keys[k].Name } // Get metric key category. -func (k v3MetricKey) Category() Category { - return v3MetricKeys[k].Category +func (k v3Key) Category() Category { + return v3Keys[k].Category } // metric value @@ -597,7 +597,7 @@ const ( ) // map of metrics to metric keys -var v3MetricKeyLut = map[v3Metric]v3MetricKey { +var v3KeyLut = map[v3Metric]v3Key { v3AVNetwork: v3AttackVector, // AV:N v3AVAdjacentNetwork: v3AttackVector, // AV:A v3AVLocal: v3AttackVector, // AV:L @@ -801,8 +801,8 @@ var v3MetricStrLut = map[string]v3Metric { } // Get CVSS 3.x metric key. -func (m v3Metric) Key() MetricKey { - k, _ := v3MetricKeyLut[m] +func (m v3Metric) Key() Key { + k, _ := v3KeyLut[m] return k } @@ -937,7 +937,7 @@ func newV31Vector(s string) (Vector, error) { } // Metric key. -type MetricKey interface { +type Key interface { // Get full name. Name() string @@ -951,7 +951,7 @@ type MetricKey interface { // CVSS metric. type Metric interface { // Get metric key. - Key() MetricKey + Key() Key // Return string representation of metric. String() string |