Skip to content

📦 Go SDK Overview ​

pkg/cvss · pkg/parser · pkg/vector · pkg/mock — spec-accurate CVSS v3.0/v3.1 scoring, parsing and comparison for Go.

Package Structure ​

The SDK is split into four packages with a clear dependency direction: pkg/parser and pkg/mock sit on top of pkg/cvss, which in turn depends on pkg/vector for the immutable metric-value objects.

PackageResponsibilityKey types
pkg/cvssThe core: Cvss3x model, scoring, builder, options, presets, distance, impact, JSON/CSV, validation, SQL, enumerationCvss3x, Calculator, Cvss3xBuilder, Option, DistanceCalculator
pkg/parserTurn vector strings into *Cvss3x, with strict, relaxed, batch and parse-and-score flavorsCvss3xParser, VectorParser, ParseString, BatchParse
pkg/vectorImmutable metric-value objects and the factory that resolves a short name + value into a VectorVector, VectorImpl, GetAttackVector, AttackVectorNetwork
pkg/mockRandom vector generation and severity-preset fixtures for tests and demosRandomCvss3x, RandomCvss3xFull, CriticalCvss31

Install ​

bash
go get github.com/scagogogo/cvss-skills@latest

The module path is github.com/scagogogo/cvss-skills (Go 1.18+). Import the packages you need:

go
import (
    "github.com/scagogogo/cvss-skills/pkg/cvss"
    "github.com/scagogogo/cvss-skills/pkg/parser"
    "github.com/scagogogo/cvss-skills/pkg/vector"
    "github.com/scagogogo/cvss-skills/pkg/mock"
)

5-Minute Quickstart ​

Three steps: parse a vector string, score it, and read its severity.

go
package main

import (
    "fmt"

    "github.com/scagogogo/cvss-skills/pkg/cvss"
    "github.com/scagogogo/cvss-skills/pkg/parser"
)

func main() {
    // 1. Parse a CVSS vector string into a *Cvss3x.
    cv, err := parser.ParseString("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H")
    if err != nil {
        panic(err)
    }

    // 2. Score it with a Calculator.
    calc := cvss.NewCalculator(cv)
    score, err := calc.Calculate()
    if err != nil {
        panic(err)
    }

    // 3. Map the score to a severity rating.
    severity := calc.GetSeverityRating(score)

    fmt.Printf("vector    : %s\n", cv.String())
    fmt.Printf("score     : %.1f\n", score)       // 9.8
    fmt.Printf("severity  : %s\n", severity)       // High
}

One-shot parse + score

When you only need the score from a string, skip the intermediate steps with parser.ParseAndScore, which returns the object, score and severity in one call.

Where to Go Next ​

Each topic below is its own page with full API reference and runnable examples.

TopicWhat you'll learn
pkg/cvssThe Cvss3x type and its Base / Temporal / Environmental three-part structure
pkg/parserStrict, relaxed, validated and batched parsing
pkg/vectorThe Vector interface, preset variables and the Get* factory
pkg/mockRandom vector generation and severity presets
Scoring (calculator)Base / Temporal / Environmental scores and breakdowns
Builder PatternFluent NewBuilder().AV('N')...Build() construction
Functional OptionsNewCvss3xWithOptions(WithAV('N'), ...)
PresetsCriticalV31(), HighV31(), and the v3.0 family
Distance & ComparisonEuclidean, Manhattan, Hamming, Jaccard, score-delta
Impact & SensitivityWhich metric moves the score the most
JSON SerializationToJSON / FromJSON and the JSONOutput shape
CSV I/OWriteCSV / ReadCSV / ReadCSVLax
ValidationValidate, MissingMetrics, sentinel errors
EnumerationList metrics, iterate all 2592 base combinations
Score RangeBest/worst case for partial vectors
SQL & Sortingsql.Scanner / driver.Valuer, sort by score, canonicalize

Released under the MIT License.