diff --git a/CHANGELOG b/CHANGELOG index 0a5e0e87..33802f59 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ jc changelog -20231023 v1.23.7 -- xxx +20231024 v1.23.7 +- Fix `iptables` parser for cases where the `target` field is blank in a rule 20231023 v1.23.6 - Fix XML parser for xmltodict library versions < 0.13.0 diff --git a/jc/parsers/iptables.py b/jc/parsers/iptables.py index 7a1d45b2..704756ac 100644 --- a/jc/parsers/iptables.py +++ b/jc/parsers/iptables.py @@ -163,7 +163,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.8' + version = '1.9' description = '`iptables` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -271,6 +271,10 @@ def parse(data, raw=False, quiet=False): continue else: + # sometimes the "target" column is blank. Stuff in a dummy character + if headers[0] == 'target' and line.startswith(' '): + line = '\u2063' + line + rule = line.split(maxsplit=len(headers) - 1) temp_rule = dict(zip(headers, rule)) if temp_rule: @@ -279,7 +283,4 @@ def parse(data, raw=False, quiet=False): if chain: raw_output.append(chain) - if raw: - return raw_output - else: - return _process(raw_output) + return raw_output if raw else _process(raw_output)