From a5519890086a81fc5ee69d082ade99673f094973 Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Tue, 9 Dec 2025 19:16:11 +0100 Subject: [PATCH] fix: do not expect db to exist with --import-json Obviously, --import-json is mainly useful when db doesn't exist so drop cvedb_orig.check_db_exists() from if statement Moreover, do not exit after --import-json or --export-json to be consistent with --import and --export Finally, while at it, add --{im,ex}port-json to offline.md Signed-off-by: Fabrice Fontaine --- cve_bin_tool/cli.py | 10 +++------- doc/how_to_guides/offline.md | 9 +++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cve_bin_tool/cli.py b/cve_bin_tool/cli.py index 95074e65cc..9366066e4a 100644 --- a/cve_bin_tool/cli.py +++ b/cve_bin_tool/cli.py @@ -859,25 +859,21 @@ def main(argv=None): return ERROR_CODES[MirrorError] # import database from JSON chopped by years - if args["import_json"] and cvedb_orig.check_db_exists(): - return_code = cvedb_orig.json_to_db_wrapper( + if args["import_json"]: + cvedb_orig.json_to_db_wrapper( path=args["import_json"], pubkey=args["verify"], ignore_signature=args["ignore_sig"], log_signature_error=args["log_signature_error"], ) - # And terminate operation - return return_code # Export database as JSON chopped by years if args["export_json"] and cvedb_orig.check_db_exists(): - return_code = cvedb_orig.db_to_json( + cvedb_orig.db_to_json( path=args["export_json"], private_key=args["pgp_sign"], passphrase=args["passphrase"], ) - # And terminate operation - return return_code # Import database if file exists if args["import"] and Path(args["import"]).exists(): diff --git a/doc/how_to_guides/offline.md b/doc/how_to_guides/offline.md index af648fa075..c4123d677c 100644 --- a/doc/how_to_guides/offline.md +++ b/doc/how_to_guides/offline.md @@ -17,6 +17,11 @@ Run the tool to export the latest version of the vulnerability database. ``` $ cve-bin-tool --export ``` +or + +``` +$ cve-bin-tool --export-json +``` ## Transfer the vulnerability database file into a directory in the offline environment @@ -28,6 +33,10 @@ Run the tool to import the transferred copy of the vulnerability database. ``` $ cve-bin-tool --import ``` +or +``` +$ cve-bin-tool --import-json +``` The cve-bin-tool will fail to operate in offline mode if a vulnerability database is not present on the system.