3
3
from .enums import *
4
4
from decimal import Decimal as D
5
5
from cvsslib .base_enum import NotDefined
6
-
6
+ import decimal
7
7
8
8
EXPLOITABILITY_COEFFECIENT = D ("8.22" )
9
9
IMPACT_UNCHANGED_COEFFECIENT = D ("6.42" )
@@ -59,9 +59,13 @@ def calculate_modified_impact_sub_score(scope: ModifiedScope,
59
59
)
60
60
61
61
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 )
63
67
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 ))
65
69
66
70
67
71
def calculate_base_score (run_calculation , scope : Scope , privilege : PrivilegeRequired ):
@@ -144,4 +148,4 @@ def calculate(run_calculation, get):
144
148
145
149
environment_score = run_calculation (calculate_environmental_score , override = override )
146
150
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