From e4acb3d5b70a7d75741ef3e35cd6750d1362a80f Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Wed, 21 Apr 2021 07:08:50 -0700 Subject: [PATCH] always make to/from_service None if ports are assigned --- jc/parsers/ufw.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jc/parsers/ufw.py b/jc/parsers/ufw.py index 18305e5c..b43e3bbe 100644 --- a/jc/parsers/ufw.py +++ b/jc/parsers/ufw.py @@ -380,13 +380,15 @@ def _parse_to_from(linedata, direction, rule_obj=None): # find the numeric port(s) linedata_list = linedata.split(':', maxsplit=1) - if len(linedata_list) == 2 and linedata_list[1].strip().isnumeric(): + if len(linedata_list) == 2 and linedata_list[0].strip().isnumeric(): rule_obj[direction + '_start_port'] = linedata_list[0].strip() rule_obj[direction + '_end_port'] = linedata_list[1].strip() + rule_obj[direction + '_service'] = None linedata = '' elif len(linedata_list) == 1 and linedata_list[0].strip().isnumeric(): rule_obj[direction + '_start_port'] = linedata_list[0].strip() rule_obj[direction + '_end_port'] = linedata_list[0].strip() + rule_obj[direction + '_service'] = None linedata = '' # only thing left should be the service name.