From 85c2fe75b977fa3a923808b665c96426a040b16b Mon Sep 17 00:00:00 2001 From: Christian Studer Date: Fri, 19 Jul 2024 08:18:16 +0200 Subject: [PATCH] fix: [misp_stix_converter] Handling cases where url or authentication key is not provided to connect to MISP --- misp_stix_converter/misp_stix_converter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misp_stix_converter/misp_stix_converter.py b/misp_stix_converter/misp_stix_converter.py index b598f9a..7f968d4 100644 --- a/misp_stix_converter/misp_stix_converter.py +++ b/misp_stix_converter/misp_stix_converter.py @@ -1075,7 +1075,7 @@ def _stix_to_misp(args): if args.url is not None and args.api_key is not None: misp = PyMISP(args.url, args.api_key, not args.skip_ssl) return _process_stix_to_misp_instance(misp, args) - if args.config is not None: + elif args.config is not None: try: with open(args.config, 'rt', encoding='utf-8') as f: config = json.load(f) @@ -1085,6 +1085,8 @@ def _stix_to_misp(args): return _process_stix_to_misp_instance(misp, args) except (FileNotFoundError, KeyError, json.JSONDecodeError): msg = 'Unable to read configuration file to connect to MISP -' + else: + msg = 'Missing URL or API key to connect to MISP instance -' except PyMISPError as error: msg = f'Unable to connect to MISP instance ({error}) -' print(f'{msg} Saving MISP results into files instead.')