aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/cvss/v2key.go12
-rw-r--r--internal/cvss/v2metric.go7
-rw-r--r--internal/cvss/v3key.go12
-rw-r--r--internal/cvss/v3metric.go7
4 files changed, 30 insertions, 8 deletions
diff --git a/internal/cvss/v2key.go b/internal/cvss/v2key.go
index 26ee200..740d26d 100644
--- a/internal/cvss/v2key.go
+++ b/internal/cvss/v2key.go
@@ -75,10 +75,18 @@ var v2Keys = map[v2Key]struct {
// Get metric key name.
func (k v2Key) Name() string {
- return v2Keys[k].Name
+ if data, ok := v2Keys[k]; ok {
+ return data.Name
+ } else {
+ return "invalid"
+ }
}
// Get metric key category.
func (k v2Key) Category() Category {
- return v2Keys[k].Category
+ if data, ok := v2Keys[k]; ok {
+ return data.Category
+ } else {
+ return InvalidCategory
+ }
}
diff --git a/internal/cvss/v2metric.go b/internal/cvss/v2metric.go
index a80cf8a..2dee41a 100644
--- a/internal/cvss/v2metric.go
+++ b/internal/cvss/v2metric.go
@@ -236,6 +236,9 @@ func getV2Metric(s string) (v2Metric, error) {
// Get CVSS 2.0 metric key.
func (m v2Metric) Key() Key {
- k, _ := v2KeyLut[m]
- return k
+ if k, ok := v2KeyLut[m]; ok {
+ return k
+ } else {
+ return v2InvalidKey
+ }
}
diff --git a/internal/cvss/v3key.go b/internal/cvss/v3key.go
index f1f32cd..653c2da 100644
--- a/internal/cvss/v3key.go
+++ b/internal/cvss/v3key.go
@@ -99,10 +99,18 @@ var v3Keys = map[v3Key]struct {
// Get metric key name.
func (k v3Key) Name() string {
- return v3Keys[k].Name
+ if data, ok := v3Keys[k]; ok {
+ return data.Name
+ } else {
+ return "invalid"
+ }
}
// Get metric key category.
func (k v3Key) Category() Category {
- return v3Keys[k].Category
+ if data, ok := v3Keys[k]; ok {
+ return data.Category
+ } else {
+ return InvalidCategory
+ }
}
diff --git a/internal/cvss/v3metric.go b/internal/cvss/v3metric.go
index a8f25de..e9a6763 100644
--- a/internal/cvss/v3metric.go
+++ b/internal/cvss/v3metric.go
@@ -314,8 +314,11 @@ var v3MetricStrLut = map[string]v3Metric {
// Get CVSS 3.x metric key.
func (m v3Metric) Key() Key {
- k, _ := v3KeyLut[m]
- return k
+ if k, ok := v3KeyLut[m]; ok {
+ return k
+ } else {
+ return v3InvalidKey
+ }
}
// Convert string to CVSS 3.1 metric.