polycvss
Rust library to parse and score CVSS vector strings.
Features:
- CVSS v2, CVSS v3, and CVSS v4 support.
- Version-agnostic parsing and scoring API.
- Memory efficient: Parsed vectors are 8 bytes. Scores and severities are 1 byte.
- No dependencies except the standard library.
- Extensive tests: Tested against thousands of results from the NVD CVSS score calculators.
Here is an example tool which parses the first command-line argument as a CVSS vector string, then prints the score and severity:
use ;
Here is the example tool output for a CVSS v2 vector string, a CVSS v3 vector string, and a CVSS v4 vector string:
# test with cvss v2 vector string
# test with cvss v3 vector string
# test with cvss v4 vector string
This example tool is included in the Git repository as
src/bin/cvss-score.rs.
Build
Run cargo build to create a debug build of the example tool in
target/debug:
Run cargo build --release to create a release build of the example
tool in target/release:
You can also build the example tool in a container using Podman or Docker like this:
Documentation
Run cargo doc to build the API documentation in target/doc/polycvss:
Run cargo doc --lib build the library documentation and exclude the
example tool:
# remove generated docs
# (needed to clean up stale artifacts)
# generate library-only docs
Tests
Use cargo test to run the test suite:
; ; ; ; ;
Use cargo clippy to run the linter:
)
The test suite includes a large number of scored CVSS vector string test cases. The test cases were generated using cvss-calcs.
The generated test cases can be found in src/v3.rs,
src/v3.rs, and src/v4.rs.