feat: cvss v2 support - #45
Conversation
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
🎉 This PR is included in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
No description provided.