aboutsummaryrefslogtreecommitdiff
path: root/cvss/v2key.go
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-02-04 00:35:31 -0500
committerPaul Duncan <pabs@pablotron.org>2022-02-04 00:35:31 -0500
commit9c17b97cd0f83be3fff9fa4e87fd1d29052ea616 (patch)
tree0d97030a0d0c3ad983be281ce89f80571338887f /cvss/v2key.go
parent92400d731546557d110c9c3cc3906d700f83dda8 (diff)
downloadcvez-9c17b97cd0f83be3fff9fa4e87fd1d29052ea616.tar.bz2
cvez-9c17b97cd0f83be3fff9fa4e87fd1d29052ea616.zip
rename to github.com/pablotron/cvez, remove internal libs
Diffstat (limited to 'cvss/v2key.go')
-rw-r--r--cvss/v2key.go92
1 files changed, 92 insertions, 0 deletions
diff --git a/cvss/v2key.go b/cvss/v2key.go
new file mode 100644
index 0000000..740d26d
--- /dev/null
+++ b/cvss/v2key.go
@@ -0,0 +1,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
+ }
+}