From 70889646400b871027970e1381ffc96e7f356af8 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 31 Jan 2022 14:09:06 -0500 Subject: internal/cvss: s/MetricKey/Key/g --- internal/cvss/cvss.go | 70 ++++++++++++++++++------------------- internal/cvss/v2key_string.go | 37 ++++++++++++++++++++ internal/cvss/v2metrickey_string.go | 37 -------------------- internal/cvss/v3key_string.go | 45 ++++++++++++++++++++++++ internal/cvss/v3metrickey_string.go | 45 ------------------------ 5 files changed, 117 insertions(+), 117 deletions(-) create mode 100644 internal/cvss/v2key_string.go delete mode 100644 internal/cvss/v2metrickey_string.go create mode 100644 internal/cvss/v3key_string.go delete mode 100644 internal/cvss/v3metrickey_string.go (limited to 'internal/cvss') 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/v2key_string.go b/internal/cvss/v2key_string.go new file mode 100644 index 0000000..8e945fd --- /dev/null +++ b/internal/cvss/v2key_string.go @@ -0,0 +1,37 @@ +// Code generated by "stringer -linecomment -type=v2Key"; DO NOT EDIT. + +package cvss + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[v2AccessVector-0] + _ = x[v2AccessComplexity-1] + _ = x[v2Authentication-2] + _ = x[v2ConfidentialityImpact-3] + _ = x[v2IntegrityImpact-4] + _ = x[v2AvailabilityImpact-5] + _ = x[v2Exploitability-6] + _ = x[v2RemediationLevel-7] + _ = x[v2ReportConfidence-8] + _ = x[v2CollateralDamagePotential-9] + _ = x[v2TargetDistribution-10] + _ = x[v2ConfidentialityRequirement-11] + _ = x[v2IntegrityRequirement-12] + _ = x[v2AvailabilityRequirement-13] + _ = x[v2InvalidKey-14] +} + +const _v2Key_name = "AVACAuCIAERLRCCDPTDCRIRARinvalid" + +var _v2Key_index = [...]uint8{0, 2, 4, 6, 7, 8, 9, 10, 12, 14, 17, 19, 21, 23, 25, 32} + +func (i v2Key) String() string { + if i >= v2Key(len(_v2Key_index)-1) { + return "v2Key(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _v2Key_name[_v2Key_index[i]:_v2Key_index[i+1]] +} diff --git a/internal/cvss/v2metrickey_string.go b/internal/cvss/v2metrickey_string.go deleted file mode 100644 index 5017567..0000000 --- a/internal/cvss/v2metrickey_string.go +++ /dev/null @@ -1,37 +0,0 @@ -// Code generated by "stringer -linecomment -type=v2MetricKey"; DO NOT EDIT. - -package cvss - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[v2AccessVector-0] - _ = x[v2AccessComplexity-1] - _ = x[v2Authentication-2] - _ = x[v2ConfidentialityImpact-3] - _ = x[v2IntegrityImpact-4] - _ = x[v2AvailabilityImpact-5] - _ = x[v2Exploitability-6] - _ = x[v2RemediationLevel-7] - _ = x[v2ReportConfidence-8] - _ = x[v2CollateralDamagePotential-9] - _ = x[v2TargetDistribution-10] - _ = x[v2ConfidentialityRequirement-11] - _ = x[v2IntegrityRequirement-12] - _ = x[v2AvailabilityRequirement-13] - _ = x[v2InvalidMetricKey-14] -} - -const _v2MetricKey_name = "AVACAuCIAERLRCCDPTDCRIRARinvalid" - -var _v2MetricKey_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) + ")" - } - return _v2MetricKey_name[_v2MetricKey_index[i]:_v2MetricKey_index[i+1]] -} diff --git a/internal/cvss/v3key_string.go b/internal/cvss/v3key_string.go new file mode 100644 index 0000000..0644117 --- /dev/null +++ b/internal/cvss/v3key_string.go @@ -0,0 +1,45 @@ +// Code generated by "stringer -linecomment -type=v3Key"; DO NOT EDIT. + +package cvss + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[v3AttackVector-0] + _ = x[v3AttackComplexity-1] + _ = x[v3PrivilegesRequired-2] + _ = x[v3UserInteraction-3] + _ = x[v3Scope-4] + _ = x[v3Confidentiality-5] + _ = x[v3Integrity-6] + _ = x[v3Availability-7] + _ = x[v3ExploitCodeMaturity-8] + _ = x[v3RemediationLevel-9] + _ = x[v3ReportConfidence-10] + _ = x[v3ConfidentialityRequirement-11] + _ = x[v3IntegrityRequirement-12] + _ = x[v3AvailabilityRequirement-13] + _ = x[v3ModifiedAttackVector-14] + _ = x[v3ModifiedAttackComplexity-15] + _ = x[v3ModifiedPrivilegesRequired-16] + _ = x[v3ModifiedUserInteraction-17] + _ = x[v3ModifiedScope-18] + _ = x[v3ModifiedConfidentiality-19] + _ = x[v3ModifiedIntegrity-20] + _ = x[v3ModifiedAvailability-21] + _ = x[v3InvalidKey-22] +} + +const _v3Key_name = "AVACPRUISCIAERLRCCRIRARMAVMACMPRMUIMSMCMIMAinvalid" + +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 v3Key) String() string { + if i >= v3Key(len(_v3Key_index)-1) { + return "v3Key(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _v3Key_name[_v3Key_index[i]:_v3Key_index[i+1]] +} diff --git a/internal/cvss/v3metrickey_string.go b/internal/cvss/v3metrickey_string.go deleted file mode 100644 index e30c9cc..0000000 --- a/internal/cvss/v3metrickey_string.go +++ /dev/null @@ -1,45 +0,0 @@ -// Code generated by "stringer -linecomment -type=v3MetricKey"; DO NOT EDIT. - -package cvss - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[v3AttackVector-0] - _ = x[v3AttackComplexity-1] - _ = x[v3PrivilegesRequired-2] - _ = x[v3UserInteraction-3] - _ = x[v3Scope-4] - _ = x[v3Confidentiality-5] - _ = x[v3Integrity-6] - _ = x[v3Availability-7] - _ = x[v3ExploitCodeMaturity-8] - _ = x[v3RemediationLevel-9] - _ = x[v3ReportConfidence-10] - _ = x[v3ConfidentialityRequirement-11] - _ = x[v3IntegrityRequirement-12] - _ = x[v3AvailabilityRequirement-13] - _ = x[v3ModifiedAttackVector-14] - _ = x[v3ModifiedAttackComplexity-15] - _ = x[v3ModifiedPrivilegesRequired-16] - _ = x[v3ModifiedUserInteraction-17] - _ = x[v3ModifiedScope-18] - _ = x[v3ModifiedConfidentiality-19] - _ = x[v3ModifiedIntegrity-20] - _ = x[v3ModifiedAvailability-21] - _ = x[v3InvalidMetricKey-22] -} - -const _v3MetricKey_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} - -func (i v3MetricKey) String() string { - if i >= v3MetricKey(len(_v3MetricKey_index)-1) { - return "v3MetricKey(" + strconv.FormatInt(int64(i), 10) + ")" - } - return _v3MetricKey_name[_v3MetricKey_index[i]:_v3MetricKey_index[i+1]] -} -- cgit v1.2.3