aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/cvss/cvss.go55
-rw-r--r--internal/cvss/v2vector.go62
2 files changed, 62 insertions, 55 deletions
diff --git a/internal/cvss/cvss.go b/internal/cvss/cvss.go
index c56046b..4a1a789 100644
--- a/internal/cvss/cvss.go
+++ b/internal/cvss/cvss.go
@@ -8,61 +8,6 @@ import (
//go:generate stringer -linecomment -type=v3Key
//go:generate stringer -linecomment -type=v3Metric
-// CVSS 2.0 vector.
-type v2Vector []v2Metric
-
-// Convert vector to string
-func (v v2Vector) String() string {
- // convert to slice of metrics
- metrics := []v2Metric(v)
-
- // build vector
- r := make([]string, len(metrics))
- for i, m := range(metrics) {
- r[i] = m.String()
- }
-
- // build and return string
- return strings.Join(r, "/")
-}
-
-// Return CVSS version.
-func (v2Vector) Version() Version {
- return V20
-}
-// Return metrics in this vector.
-func (v v2Vector) Metrics() []Metric {
- // build result
- r := make([]Metric, len(v))
- for i, m := range(v) {
- r[i] = m
- }
-
- // return result
- return r
-}
-
-// create CVSS 2.0 vector from string
-func newV2Vector(s string) (Vector, error) {
- strs := strings.Split(s, "/")
- r := make([]v2Metric, len(strs))
-
- // walk metric strings
- for i, ms := range(strs) {
- // convert string to vector
- m, err := getV2MetricFromString(ms)
- if err != nil {
- return nil, err
- }
-
- // add to results
- r[i] = m
- }
-
- // build and return vector
- return v2Vector(r), nil
-}
-
// CVSS v3 metric key
type v3Key byte
diff --git a/internal/cvss/v2vector.go b/internal/cvss/v2vector.go
new file mode 100644
index 0000000..1cb318a
--- /dev/null
+++ b/internal/cvss/v2vector.go
@@ -0,0 +1,62 @@
+// CVSS vector parser.
+package cvss
+
+import (
+ "strings"
+)
+
+// CVSS 2.0 vector.
+type v2Vector []v2Metric
+
+// Convert vector to string.
+func (v v2Vector) String() string {
+ // convert to slice of metrics
+ metrics := []v2Metric(v)
+
+ // build vector
+ r := make([]string, len(metrics))
+ for i, m := range(metrics) {
+ r[i] = m.String()
+ }
+
+ // build and return string
+ return strings.Join(r, "/")
+}
+
+// Return CVSS version.
+func (v2Vector) Version() Version {
+ return V20
+}
+
+// Return metrics in this vector.
+func (v v2Vector) Metrics() []Metric {
+ // build result
+ r := make([]Metric, len(v))
+ for i, m := range(v) {
+ r[i] = m
+ }
+
+ // return result
+ return r
+}
+
+// Create CVSS 2.0 vector from string.
+func newV2Vector(s string) (Vector, error) {
+ strs := strings.Split(s, "/")
+ r := make([]v2Metric, len(strs))
+
+ // walk metric strings
+ for i, ms := range(strs) {
+ // convert string to vector
+ m, err := getV2MetricFromString(ms)
+ if err != nil {
+ return nil, err
+ }
+
+ // add to results
+ r[i] = m
+ }
+
+ // build and return vector
+ return v2Vector(r), nil
+}