Skip to content

⚖️ equal ​

CVSS v3.0CVSS v3.1text + json

Synopsis ​

cvss equal performs a deep equality check on two CVSS vectors. It prints Equal or Not equal and uses its exit code as the result: 0 if identical, 1 if different or on error. This makes it ideal for shell if guards and CI gates.

How It Works ​

Both vectors are parsed and compared by deep equality; the command prints Equal/Not equal and encodes the result in its exit code (0 equal, 1 different or error).

Usage ​

cvss equal [vector1] [vector2] [flags]

Flags ​

FlagDefaultDescription
--format stringtextoutput format: text or json
-h, --help—help for equal

Examples ​

bash
cvss equal "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H" "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
# Output:
# Not equal
# (stderr: not equal, exit=1)
bash
cvss equal "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H" "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
# Output:
# Equal

Exit code is the contract

In text mode, Not equal is printed to stdout and not equal is printed to stderr, then the process exits 1. Script against the exit code, not the stdout text. In JSON mode, the result is {"equal": false, ...} with exit 1 when unequal.

Underlying API ​

go
import "github.com/scagogogo/cvss-skills/pkg/parser"

cv1, _ := parser.ParseString("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H")
cv2, _ := parser.ParseString("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H")

eq := cv1.Equal(cv2) // bool
if eq {
    fmt.Println("Equal")
} else {
    fmt.Println("Not equal")
    os.Exit(1)
}

Equal(other *Cvss3x) bool is a deep comparison of the two vectors' metric values.

  • diff — shows what differs, not just whether
  • distance — numeric measure of how far apart two vectors are
  • validate — check one vector's validity

Released under the MIT License.