Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions smoketest/scripts/cli/test_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ def test_ipv4_time_weekdays(self):

def test_ipv4_advanced(self):
name = 'smoketest-adv'
name2 = 'smoketest-adv2'
interface = 'eth0'

self.cli_set(['firewall', 'ipv4', 'name', name, 'default-action', 'drop'])
Comment on lines 329 to 332
self.cli_set(['firewall', 'ipv4', 'name', name, 'default-log'])
Expand Down Expand Up @@ -415,7 +413,6 @@ def test_ipv4_synproxy(self):

def test_ipv4_mask(self):
name = 'smoketest-mask'
interface = 'eth0'

self.cli_set(['firewall', 'group', 'address-group', 'mask_group', 'address', '1.1.1.1'])

Expand Down Expand Up @@ -644,7 +641,6 @@ def test_ipv6_advanced(self):

def test_ipv6_mask(self):
name = 'v6-smoketest-mask'
interface = 'eth0'

self.cli_set(['firewall', 'group', 'ipv6-address-group', 'mask_group', 'address', '::beef'])

Expand Down
14 changes: 10 additions & 4 deletions src/conf_mode/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,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:
Expand Down Expand Up @@ -605,7 +607,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':
Expand All @@ -615,7 +619,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:
Expand Down Expand Up @@ -750,7 +756,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):
Expand Down
8 changes: 4 additions & 4 deletions src/op_mode/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_nftables_details(family, hook, priority):

try:
results = cmdl(command)
except:
except (OSError, UnicodeDecodeError):
return {}
Comment on lines 75 to 78

out = {}
Expand Down Expand Up @@ -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 (OSError, UnicodeDecodeError):
return {}

out = {}
Expand All @@ -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 (OSError, UnicodeDecodeError, json.JSONDecodeError):
return out

if 'nftables' not in results:
Expand Down Expand Up @@ -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 (OSError, UnicodeDecodeError, json.JSONDecodeError):
return out

if 'nftables' not in results:
Expand Down
Loading