Skip to content

Commit

Permalink
load json with parse_float=decimal.Decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
trolldbois authored Jul 1, 2024
1 parent d681987 commit 7dfbe32
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cvelib/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import decimal
import json
import re
import sys
Expand Down Expand Up @@ -351,9 +352,9 @@ def publish(

try:
if cve_json_str is not None:
cve_json = json.loads(cve_json_str)
cve_json = json.loads(cve_json_str, parse_float=decimal.Decimal)
elif cve_json_file is not None:
cve_json = json.load(cve_json_file)
cve_json = json.load(cve_json_file, parse_float=decimal.Decimal)
else:
raise click.BadParameter(
"must provide CNA JSON data using one of: "
Expand Down Expand Up @@ -443,9 +444,9 @@ def publish_adp(
)
try:
if adp_json_str is not None:
cve_json = json.loads(adp_json_str)
cve_json = json.loads(adp_json_str, parse_float=decimal.Decimal)
elif adp_json_file is not None:
cve_json = json.load(adp_json_file)
cve_json = json.load(adp_json_file, parse_float=decimal.Decimal)
else:
raise click.BadParameter(
"must provide ADP JSON record using one of: "
Expand Down Expand Up @@ -534,9 +535,9 @@ def reject(

try:
if cve_json_str is not None:
cve_json = json.loads(cve_json_str)
cve_json = json.loads(cve_json_str, parse_float=decimal.Decimal)
elif cve_json_file is not None:
cve_json = json.load(cve_json_file)
cve_json = json.load(cve_json_file, parse_float=decimal.Decimal)
else:
cve_json = None
except json.JSONDecodeError as exc:
Expand Down

0 comments on commit 7dfbe32

Please sign in to comment.