summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Herold <ruben@puettmann.net>2026-08-13 09:17:02 +0200
committerChristian Breunig <christian@breunig.cc>2026-09-25 20:53:02 +0200
commit626d5759b57839b72f89852cff8f4e0879dd862f (patch)
tree43bb1756e5d7a8b141f7cb595826a137fc0de46c /src
parent430dda1e170576239d3580c1b7a6381525a05cbc (diff)
downloadvyos-1x-626d5759b57839b72f89852cff8f4e0879dd862f.tar.gz
vyos-1x-626d5759b57839b72f89852cff8f4e0879dd862f.zip
firewall: T9205: fix ruff findings in conf_mode/op_mode firewall.py
Bare except:, extraneous f-string prefixes on ConfigError()/text calls without placeholders, and 3 unused test locals in test_firewall.py. No behavior change. Split out of PR #5374 (T9160) at sever-sever's request: that PR bundled this cleanup with the apply-path feature because it happened to touch the same files, but it isn't related to apply-path itself.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/firewall.py14
-rwxr-xr-xsrc/op_mode/firewall.py8
2 files changed, 14 insertions, 8 deletions
diff --git a/src/conf_mode/firewall.py b/src/conf_mode/firewall.py
index 3a01d2225..d00d7d214 100755
--- a/src/conf_mode/firewall.py
+++ b/src/conf_mode/firewall.py
@@ -610,7 +610,9 @@ def verify(firewall):
if 'jump' not in priority_conf['default_action']:
raise ConfigError('default-jump-target defined, but default-action jump needed and it is not defined')
if priority_conf['default_jump_target'] == priority:
- raise ConfigError(f'Loop detected on default-jump-target.')
+ raise ConfigError(
+ 'Loop detected on default-jump-target.'
+ )
if target not in dict_search_args(firewall[family], 'name'):
raise ConfigError(f'Invalid jump-target. Firewall name {target} does not exist on the system')
if 'rule' in priority_conf:
@@ -646,7 +648,9 @@ def verify(firewall):
for iface in zone_conf['member']['interface']:
if iface in zone_interfaces:
- raise ConfigError(f'Interfaces cannot be assigned to multiple zones')
+ raise ConfigError(
+ 'Interfaces cannot be assigned to multiple zones'
+ )
iface_vrf = get_interface_vrf(iface)
if iface_vrf != 'default':
@@ -656,7 +660,9 @@ def verify(firewall):
if 'vrf' in zone_conf['member']:
for vrf in zone_conf['member']['vrf']:
if vrf in zone_vrf:
- raise ConfigError(f'VRF cannot be assigned to multiple zones')
+ raise ConfigError(
+ 'VRF cannot be assigned to multiple zones'
+ )
zone_vrf.append(vrf)
if 'vrf_interfaces' in zone_conf:
@@ -791,7 +797,7 @@ def apply(firewall):
## DOMAIN RESOLVER
domain_action = 'restart'
if dict_search_args(firewall, 'group', 'remote_group') or dict_search_args(firewall, 'group', 'domain_group') or firewall['ip_fqdn'].items() or firewall['ip6_fqdn'].items():
- text = f'# Automatically generated by firewall.py\nThis file indicates that vyos-domain-resolver service is used by the firewall.\n'
+ text = '# Automatically generated by firewall.py\nThis file indicates that vyos-domain-resolver service is used by the firewall.\n'
write_file(domain_resolver_usage, text)
else:
if os.path.exists(domain_resolver_usage):
diff --git a/src/op_mode/firewall.py b/src/op_mode/firewall.py
index 962eff639..8ca5bd2ea 100755
--- a/src/op_mode/firewall.py
+++ b/src/op_mode/firewall.py
@@ -74,7 +74,7 @@ def get_nftables_details(family, hook, priority):
try:
results = cmdl(command)
- except:
+ except Exception:
return {}
out = {}
@@ -112,7 +112,7 @@ def get_nftables_state_details(family):
command = ['nft', 'list', 'chain', suffix, 'vyos_filter', f'VYOS_STATE_{name_suffix}']
try:
results = cmdl(command)
- except:
+ except Exception:
return {}
out = {}
@@ -135,7 +135,7 @@ def get_nftables_group_members(family, table, name):
try:
results_str = cmdl(['nft', '-j', 'list', 'set', prefix, table, name])
results = json.loads(results_str)
- except:
+ except Exception:
return out
if 'nftables' not in results:
@@ -163,7 +163,7 @@ def get_nftables_remote_group_members(family, table, name):
try:
results_str = cmdl(['nft', '-j', 'list', 'set', prefix, table, name])
results = json.loads(results_str)
- except:
+ except Exception:
return out
if 'nftables' not in results: