Skip to content

feat: cvss v2 support - #45

Merged
derevnjuk merged 11 commits into
masterfrom
feat/cvss_v2_support
Dec 3, 2025
Merged

feat: cvss v2 support#45
derevnjuk merged 11 commits into
masterfrom
feat/cvss_v2_support

Conversation

@tssbox

@tssbox tssbox commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@tssbox
tssbox requested a review from Copilot December 2, 2025 14:41
@tssbox tssbox self-assigned this Dec 2, 2025
@tssbox tssbox added the enhancement New feature or request label Dec 2, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for CVSS v2.0 scoring to the existing CVSS calculator library that previously only supported v3.0 and v3.1. The implementation follows the existing architecture by creating version-specific modules under src/versions/v2/ and maintaining backward compatibility with the public API.

Key changes:

  • Added complete CVSS v2.0 support including validator, calculator, and models
  • Refactored shared parser functions to a common module
  • Updated public API to handle both v2 and v3 versions
  • Reorganized test files to be version-specific

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/validator.spec.ts Removed - split into version-specific test files
tests/validator-v3.spec.ts New file with v3-specific validator tests, refactored from original validator tests
tests/validator-v2.spec.ts New file with v2-specific validator tests covering all v2 validation scenarios
tests/parser.spec.ts Added v2.0 test cases for parser functions alongside existing v3 tests
tests/cvss-v3.spec.ts Refactored to use CvssV3Calculator class directly instead of legacy function exports
tests/cvss-v2.spec.ts New comprehensive test suite with 170+ test vectors for v2 calculator validation
src/versions/v3/validator.ts Updated imports to use shared parser module and improved error messages
src/versions/v3/calculator.ts Renamed environmental subscores from environmentalImpact/Exploitability to modifiedImpact/Exploitability
src/versions/v2/validator.ts New v2 validator implementation with v2-specific metric validation logic
src/versions/v2/models.ts New v2 type definitions and metric enums for CVSS v2.0 specification
src/versions/v2/calculator.ts New v2 calculator with base, temporal, and environmental score calculations
src/parser.ts Refactored as shared parser module, removed version-specific type dependencies
src/index.ts Updated to route to appropriate validator and handle both v2 and v3 results
src/factory.ts Added v2.0 case to calculator factory
src/common/CvssVersion.ts Extended type to include '2.0'
src/common/CvssResult.ts Added CvssResultV2 interface and updated union type
Comments suppressed due to low confidence (1)

tests/cvss-v3.spec.ts:178

  • The tests for calculator error handling that were removed from validator.spec.ts (lines testing empty values, missing metrics, and unsupported versions passed to calculator functions) are not present in the new test files. Consider adding tests to verify that the calculator properly handles invalid inputs, such as empty strings, incomplete CVSS vectors, or unsupported versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.ts Outdated
Comment thread src/versions/v2/validator.ts Outdated
Comment thread tests/cvss-v2.spec.ts Outdated
Comment thread tests/cvss-v2.spec.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/versions/v2/humanizer.ts Outdated
Comment thread tests/cvss.spec.ts Outdated
Comment thread src/versions/v3/calculator.ts Outdated
tssbox and others added 3 commits December 2, 2025 21:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.ts
Comment thread src/index.ts
Comment thread src/index.ts
Comment thread src/index.ts
Comment thread src/index.ts
Comment thread tests/validator-v2.spec.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@derevnjuk
derevnjuk merged commit ae64172 into master Dec 3, 2025
3 checks passed
@derevnjuk
derevnjuk deleted the feat/cvss_v2_support branch December 3, 2025 10:41
@derevnjuk

Copy link
Copy Markdown
Member

🎉 This PR is included in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants