summaryrefslogtreecommitdiff
path: root/src/op_mode/show_nat_rules.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/op_mode/show_nat_rules.py')
-rwxr-xr-xsrc/op_mode/show_nat_rules.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/op_mode/show_nat_rules.py b/src/op_mode/show_nat_rules.py
index a98fbef8c..4bf9ff3b5 100755
--- a/src/op_mode/show_nat_rules.py
+++ b/src/op_mode/show_nat_rules.py
@@ -40,6 +40,16 @@ if args.source or args.destination:
data_json = jmespath.search('nftables[?rule].rule[?chain]', tmp)
for idx in range(0, len(data_json)):
data = data_json[idx]
+
+ # If there is no index 3, we don't think this is the record we need to check
+ if len(data['expr']) <= 3:
+ continue
+
+ # The following key values must exist
+ for keys in ['comment', 'chain', 'expr']:
+ if keys not in data:
+ continue
+
comment = data['comment']
rule = int(''.join(list(filter(str.isdigit, comment))))
chain = data['chain']