aboutsummaryrefslogtreecommitdiff
path: root/internal/cvss/v3key.go
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-01-31 22:16:23 -0500
committerPaul Duncan <pabs@pablotron.org>2022-01-31 22:16:23 -0500
commit5c4ff27a0bc70cdefad0c9a68e920e480465c4d9 (patch)
tree1cad646424696fab83956d2f042d00551228d962 /internal/cvss/v3key.go
parent6b80bfb7889444cdb9ab07dcd5fe2fcb2000ce8e (diff)
downloadcvez-5c4ff27a0bc70cdefad0c9a68e920e480465c4d9.tar.bz2
cvez-5c4ff27a0bc70cdefad0c9a68e920e480465c4d9.zip
internal/cvss: handle invalid keys and metrics
Diffstat (limited to 'internal/cvss/v3key.go')
-rw-r--r--internal/cvss/v3key.go12
1 files changed, 10 insertions, 2 deletions
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
+ }
}