Refactor score method and add round_up function #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
Refactor score method to return float and add rounding functionality to align with https://www.first.org/cvss/v3-1/specification-document#Appendix-A---Floating-Point-Rounding .
Problem
The CVSS 3.1 implementation was missing the required
roundupfunction specified in the CVSS 3.1 specification (Appendix A), causing certain vectors to produce incorrect scores.Most notably, the vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:Hwas returning a score of 10.0 instead of the correct 9.9.Root Cause
The CVSS 3.1 specification requires a specific rounding function that rounds up to 1 decimal place using integer arithmetic to avoid floating-point precision issues. The current implementation was returning raw calculated values without applying this mandatory rounding step.
Solution
Implemented the
round_upfunction following the CVSS 3.1 specification Appendix A:Types of changes
What types of changes does your code introduce to CvssSuite?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR.