RedHatProductSecurity / cvss

CVSS2/3/4 library with interactive calculator for Python 2 and Python 3
GNU Lesser General Public License v3.0
79 stars 28 forks source link

Improve error message on malformed CVSS string #13

Closed mprpic closed 6 years ago

mprpic commented 6 years ago
In [1]: from cvss import CVSS3

In [2]: from cvss.exceptions import CVSS3MalformedError

In [3]: vector = 'CVSS:3.0//AC:H/PR:H/UI:R/S:U/C:L/I:N/A:L'

In [4]: try:
   ...:     cvss = CVSS3(vector)
   ...: except CVSS3MalformedError as e:
   ...:     print(e)
   ...:
Malformed CVSS3 field ""

The vector is missing the AV value but the error message is not very helpful in this case since it shows an empty string. Perhaps default to showing the whole string in case of an empty string.