Skip to content

Commit ef6c64d

Browse files
committed
Fix calculation bug in CVSS3
1 parent 40690e2 commit ef6c64d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cvsslib/cvss3/calculations.py

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

78

89
EXPLOITABILITY_COEFFECIENT = D("8.22")
@@ -59,9 +60,9 @@ def calculate_modified_impact_sub_score(scope: ModifiedScope,
5960
)
6061

6162
if scope == ModifiedScope.UNCHANGED.value:
62-
return IMPACT_UNCHANGED_COEFFECIENT * modified
63+
return IMPACT_UNCHANGED_COEFFECIENT * decimal.Decimal(modified)
6364
else:
64-
return IMPACT_CHANGED_COEFFECIENT * (modified - D("0.029")) - D("3.25") * D(math.pow(modified - D(0.02), 15))
65+
return IMPACT_CHANGED_COEFFECIENT * (decimal.Decimal(modified) - D("0.029")) - D("3.25") * D(math.pow(decimal.Decimal(modified) - D(0.02), 15))
6566

6667

6768
def calculate_base_score(run_calculation, scope: Scope, privilege: PrivilegeRequired):
@@ -144,4 +145,4 @@ def calculate(run_calculation, get):
144145

145146
environment_score = run_calculation(calculate_environmental_score, override=override)
146147

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

0 commit comments

Comments
 (0)