From 702de7c3eb3fd19f7f7d431100b84db5266a3625 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 31 Jan 2022 16:42:09 -0500 Subject: internal/cvss: add isV30VectorString() and isV31VectorString(), remove extraneous package docs --- internal/cvss/v30vector.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'internal/cvss/v30vector.go') diff --git a/internal/cvss/v30vector.go b/internal/cvss/v30vector.go index 4154a2f..951cd03 100644 --- a/internal/cvss/v30vector.go +++ b/internal/cvss/v30vector.go @@ -1,4 +1,3 @@ -// CVSS vector parser. package cvss import ( @@ -43,9 +42,9 @@ func (v v30Vector) Metrics() []Metric { return r } -// create CVSS 3.0 vector from string +// Create CVSS 3.0 vector from string. func newV30Vector(s string) (Vector, error) { - strs := strings.Split(s, "/") + strs := strings.Split(s[len(v31Prefix):], "/") r := make([]v3Metric, len(strs)) // walk metric strings @@ -63,3 +62,8 @@ func newV30Vector(s string) (Vector, error) { // build and return vector return v30Vector(r), nil } + +// Is the given string a CVSSv3.0 vector string? +func isV30VectorString(s string) bool { + return (len(s) > len(v30Prefix)) && (s[:len(v30Prefix)] == v30Prefix); +} -- cgit v1.2.3