Skip to content

Commit 8eee7b0

Browse files
committed
Fix calculation bug in RVSS1
1 parent ef6c64d commit 8eee7b0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cvsslib/rvss/calculations.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .enums import *
44
from decimal import Decimal as D
55
from cvsslib.base_enum import NotDefined
6-
6+
import decimal
77

88
EXPLOITABILITY_COEFFECIENT = D("8.22")
99
IMPACT_UNCHANGED_COEFFECIENT = D("6.42")
@@ -59,9 +59,13 @@ def calculate_modified_impact_sub_score(scope: ModifiedScope,
5959
)
6060

6161
if scope == ModifiedScope.UNCHANGED.value:
62-
return IMPACT_UNCHANGED_COEFFECIENT * modified
62+
# print("calculating")
63+
# print(type(IMPACT_UNCHANGED_COEFFECIENT)) # Decimal.decimal
64+
# print(type(modified)) # float
65+
# print(IMPACT_UNCHANGED_COEFFECIENT * decimal.Decimal(modified))
66+
return IMPACT_UNCHANGED_COEFFECIENT * decimal.Decimal(modified)
6367
else:
64-
return IMPACT_CHANGED_COEFFECIENT * (modified - D("0.029")) - D("3.25") * D(math.pow(modified - D(0.02), 15))
68+
return IMPACT_CHANGED_COEFFECIENT * (decimal.Decimal(modified) - D("0.029")) - D("3.25") * D(math.pow(decimal.Decimal(modified) - D(0.02), 15))
6569

6670

6771
def calculate_base_score(run_calculation, scope: Scope, privilege: PrivilegeRequired):
@@ -144,4 +148,4 @@ def calculate(run_calculation, get):
144148

145149
environment_score = run_calculation(calculate_environmental_score, override=override)
146150

147-
return float(base_score), float(temporal_score), float(environment_score)
151+
return float(base_score), float(temporal_score), float(environment_score)

0 commit comments

Comments
 (0)