aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-01-31 14:09:06 -0500
committerPaul Duncan <pabs@pablotron.org>2022-01-31 14:09:06 -0500
commit70889646400b871027970e1381ffc96e7f356af8 (patch)
tree459fa60d2b4cf6f442a6e1a3bc19108f53b48d06 /internal
parent2a29b254b40bad71fc00a312280c3373b1bb733b (diff)
downloadcvez-70889646400b871027970e1381ffc96e7f356af8.tar.bz2
cvez-70889646400b871027970e1381ffc96e7f356af8.zip
internal/cvss: s/MetricKey/Key/g
Diffstat (limited to 'internal')
-rw-r--r--internal/cvss/cvss.go70
-rw-r--r--internal/cvss/v2key_string.go (renamed from internal/cvss/v2metrickey_string.go)16
-rw-r--r--internal/cvss/v3key_string.go (renamed from internal/cvss/v3metrickey_string.go)16
3 files changed, 51 insertions, 51 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
diff --git a/internal/cvss/v2metrickey_string.go b/internal/cvss/v2key_string.go
index 5017567..8e945fd 100644
--- a/internal/cvss/v2metrickey_string.go
+++ b/internal/cvss/v2key_string.go
@@ -1,4 +1,4 @@
-// Code generated by "stringer -linecomment -type=v2MetricKey"; DO NOT EDIT.
+// Code generated by "stringer -linecomment -type=v2Key"; DO NOT EDIT.
package cvss
@@ -22,16 +22,16 @@ func _() {
_ = x[v2ConfidentialityRequirement-11]
_ = x[v2IntegrityRequirement-12]
_ = x[v2AvailabilityRequirement-13]
- _ = x[v2InvalidMetricKey-14]
+ _ = x[v2InvalidKey-14]
}
-const _v2MetricKey_name = "AVACAuCIAERLRCCDPTDCRIRARinvalid"
+const _v2Key_name = "AVACAuCIAERLRCCDPTDCRIRARinvalid"
-var _v2MetricKey_index = [...]uint8{0, 2, 4, 6, 7, 8, 9, 10, 12, 14, 17, 19, 21, 23, 25, 32}
+var _v2Key_index = [...]uint8{0, 2, 4, 6, 7, 8, 9, 10, 12, 14, 17, 19, 21, 23, 25, 32}
-func (i v2MetricKey) String() string {
- if i >= v2MetricKey(len(_v2MetricKey_index)-1) {
- return "v2MetricKey(" + strconv.FormatInt(int64(i), 10) + ")"
+func (i v2Key) String() string {
+ if i >= v2Key(len(_v2Key_index)-1) {
+ return "v2Key(" + strconv.FormatInt(int64(i), 10) + ")"
}
- return _v2MetricKey_name[_v2MetricKey_index[i]:_v2MetricKey_index[i+1]]
+ return _v2Key_name[_v2Key_index[i]:_v2Key_index[i+1]]
}
diff --git a/internal/cvss/v3metrickey_string.go b/internal/cvss/v3key_string.go
index e30c9cc..0644117 100644
--- a/internal/cvss/v3metrickey_string.go
+++ b/internal/cvss/v3key_string.go
@@ -1,4 +1,4 @@
-// Code generated by "stringer -linecomment -type=v3MetricKey"; DO NOT EDIT.
+// Code generated by "stringer -linecomment -type=v3Key"; DO NOT EDIT.
package cvss
@@ -30,16 +30,16 @@ func _() {
_ = x[v3ModifiedConfidentiality-19]
_ = x[v3ModifiedIntegrity-20]
_ = x[v3ModifiedAvailability-21]
- _ = x[v3InvalidMetricKey-22]
+ _ = x[v3InvalidKey-22]
}
-const _v3MetricKey_name = "AVACPRUISCIAERLRCCRIRARMAVMACMPRMUIMSMCMIMAinvalid"
+const _v3Key_name = "AVACPRUISCIAERLRCCRIRARMAVMACMPRMUIMSMCMIMAinvalid"
-var _v3MetricKey_index = [...]uint8{0, 2, 4, 6, 8, 9, 10, 11, 12, 13, 15, 17, 19, 21, 23, 26, 29, 32, 35, 37, 39, 41, 43, 50}
+var _v3Key_index = [...]uint8{0, 2, 4, 6, 8, 9, 10, 11, 12, 13, 15, 17, 19, 21, 23, 26, 29, 32, 35, 37, 39, 41, 43, 50}
-func (i v3MetricKey) String() string {
- if i >= v3MetricKey(len(_v3MetricKey_index)-1) {
- return "v3MetricKey(" + strconv.FormatInt(int64(i), 10) + ")"
+func (i v3Key) String() string {
+ if i >= v3Key(len(_v3Key_index)-1) {
+ return "v3Key(" + strconv.FormatInt(int64(i), 10) + ")"
}
- return _v3MetricKey_name[_v3MetricKey_index[i]:_v3MetricKey_index[i+1]]
+ return _v3Key_name[_v3Key_index[i]:_v3Key_index[i+1]]
}