From: Shivani Bhardwaj Date: Thu, 22 Jun 2023 12:21:05 +0000 (+0530) Subject: suricatasc: handle exceptions in caller X-Git-Tag: suricata-6.0.14~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ddbcb1f017772f0f5aaeffab591cb8ccdb64c8a;p=thirdparty%2Fsuricata.git suricatasc: handle exceptions in caller (cherry picked from commit 46ce371d9c550ea840cb946b06c5614569ca98fa) --- diff --git a/python/bin/suricatasc b/python/bin/suricatasc index 51f12d59a4..ce521f46fd 100755 --- a/python/bin/suricatasc +++ b/python/bin/suricatasc @@ -1,6 +1,6 @@ #! /usr/bin/env python # -# Copyright(C) 2013-2022 Open Information Security Foundation +# Copyright(C) 2013-2023 Open Information Security Foundation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -69,8 +69,16 @@ except SuricataReturnException as err: sys.exit(1) if args.command: - (command, arguments) = sc.parse_command(args.command) - res = sc.send_command(command, arguments) + try: + (command, arguments) = sc.parse_command(args.command) + except SuricataCommandException as err: + print(err.value) + sys.exit(1) + try: + res = sc.send_command(command, arguments) + except (SuricataCommandException, SuricataReturnException) as err: + print(err.value) + sys.exit(1) print(json.dumps(res)) sc.close() if res['return'] == 'OK':