aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/cvss/badkey.go20
-rw-r--r--internal/cvss/cvss.go18
-rw-r--r--internal/cvss/v2key.go18
3 files changed, 38 insertions, 18 deletions
diff --git a/internal/cvss/badkey.go b/internal/cvss/badkey.go
new file mode 100644
index 0000000..872a6d2
--- /dev/null
+++ b/internal/cvss/badkey.go
@@ -0,0 +1,20 @@
+// CVSS vector parser.
+package cvss
+
+import "fmt"
+
+// Bad metric key error.
+type badKey struct {
+ version Version
+ key string
+}
+
+// Create new bad key error.
+func newBadKey(version Version, key string) error {
+ return &badKey { version, key }
+}
+
+// Return printable error string
+func (e badKey) Error() string {
+ return fmt.Sprintf("invalid CVSS %s metric key: %s", e.version, e.key)
+}
diff --git a/internal/cvss/cvss.go b/internal/cvss/cvss.go
index 8fc6314..057a163 100644
--- a/internal/cvss/cvss.go
+++ b/internal/cvss/cvss.go
@@ -388,15 +388,15 @@ var v3KeyIds = map[string]v3Key {
"MA": v3ModifiedAvailability,
}
-// Get metric key from string.
-func getV3KeyFromString(s string) (v3Key, error) {
- k, ok := v3KeyIds[s]
- if ok {
- return k, nil
- } else {
- return v3InvalidKey, fmt.Errorf("invalid metric key: %s", s)
- }
-}
+// // Get metric key from string.
+// func getV3KeyFromString(s string) (v3Key, error) {
+// k, ok := v3KeyIds[s]
+// if ok {
+// return k, nil
+// } else {
+// return v3InvalidKey, newBadKey(V30, s)
+// }
+// }
// Get metric key name.
func (k v3Key) Name() string {
diff --git a/internal/cvss/v2key.go b/internal/cvss/v2key.go
index ae976be..8a7996c 100644
--- a/internal/cvss/v2key.go
+++ b/internal/cvss/v2key.go
@@ -64,15 +64,15 @@ var v2KeyIds = map[string]v2Key {
"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, fmt.Errorf("invalid metric key: %s", s)
- }
-}
+// // 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 {