Skip to content

Commit

Permalink
Tweak of error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSeccubus committed May 27, 2024
1 parent 0ea4626 commit 6a7675e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions program/cve_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import os
import re
import json
from jsonschema import Draft7Validator
from jsonschema.exceptions import best_match
import datetime
import sys
from cvelib.cve_api import CveApi
Expand Down Expand Up @@ -124,9 +122,10 @@ def file_valid_json1(file,json_data,args,type) :
try:
CveRecord.validate(json_data["containers"]["cna"])
except Exception as e:
error_str="Schema validation of CVE record failed."
error_str="Schema validation of CVE record failed\n--------------------------------------"
for error in e.errors:
error_str = "{}\n{}\n\n---".format(error_str,error)
jpath = error.json_path.replace("$","$.containers.cna")
error_str = "{}\n{} -> {}".format(error_str,jpath,error.message)
results.append(error_str)

# return results
Expand Down Expand Up @@ -395,7 +394,6 @@ def out(str, level=1, max_level=9999, end="\n") :
parser.add_argument('--list', action="count", default=0, help="list all checks and exit" )
parser.add_argument('--min-reserved', type=int, metavar="N", default=0, help="Minimum number of reserved IDs for the current year" )
parser.add_argument('--reserve', type=int, metavar="N", default=0, help="Reserve N new entries if reserved for this year is below minimum")
parser.add_argument('--schema', type=str, metavar="./schemas", default="./schemas", help="Path to the directory containing the CVE json schema files")
parser.add_argument('--include-reservations', action="store_true", default=False, help="Include reservations in our records")
parser.add_argument('--reservations-path', type=str, metavar="./reservations", default="", help="path of directory for reservations")
parser.add_argument('--create-missing', action="store_true", default=False, help="Create cve records from cve databazse when missing")
Expand All @@ -418,10 +416,6 @@ def out(str, level=1, max_level=9999, end="\n") :

skips=args.skip.split(",")

if not os.path.exists(args.schema) and os.path.isdir(args.schema) :
print("Schema directory '{}' does not exist".format(args.schema),file=sys.stderr)
exit(255)

if not os.path.exists(args.path) :
print("Path '{}' does not exist".format(args.path),file=sys.stderr)
exit(255)
Expand Down

0 comments on commit 6a7675e

Please sign in to comment.