Skip to content

Commit

Permalink
fix for blank target in rule
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjonbrazil committed Oct 24, 2023
1 parent 59b89ec commit b70025d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 6 additions & 5 deletions jc/parsers/iptables.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@

class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.8'
version = '1.9'
description = '`iptables` command parser'
author = 'Kelly Brazil'
author_email = '[email protected]'
Expand Down Expand Up @@ -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:
Expand All @@ -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)

0 comments on commit b70025d

Please sign in to comment.