aboutsummaryrefslogtreecommitdiff
path: root/internal/cvss/v2key.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/v2key.go
parent6b80bfb7889444cdb9ab07dcd5fe2fcb2000ce8e (diff)
downloadcvez-5c4ff27a0bc70cdefad0c9a68e920e480465c4d9.tar.bz2
cvez-5c4ff27a0bc70cdefad0c9a68e920e480465c4d9.zip
internal/cvss: handle invalid keys and metrics
Diffstat (limited to 'internal/cvss/v2key.go')
-rw-r--r--internal/cvss/v2key.go12
1 files changed, 10 insertions, 2 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
+ }
}