Skip to content

Commit

Permalink
Load json schema with parse_float as decimal
Browse files Browse the repository at this point in the history
Float value in the json schema are used in arithmetic division. They must be loaded as decimal or comparison will fail.
see RedHatProductSecurity#87
  • Loading branch information
trolldbois authored Jul 1, 2024
1 parent bc72a35 commit d681987
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cvelib/cve_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def validate(cls, cve_json: dict, schema_path: Optional[str] = None) -> None:
schema_path = cls.Schemas.CNA_PUBLISHED

with open(schema_path) as schema_file:
schema = json.load(schema_file)
schema = json.load(schema_file, parse_float=decimal.Decimal)

validator = Draft7Validator(schema)
errors = sorted(validator.iter_errors(cve_json), key=lambda e: e.message)
Expand Down

0 comments on commit d681987

Please sign in to comment.