Page MenuHomeVyOS Platform

firewall: negated day in "time weekdays" is dropped instead of negated
Open, Requires assessmentPublicBUG

Description

A day prefixed with ! in firewall ... rule N time weekdays is left out of the generated nftables rule instead of being negated. If every day in the value is negated, the rule is rendered with an empty set (meta day {}), and the commit fails with an nftables syntax error.

Steps to reproduce

set firewall ipv4 input filter rule 50 action accept
set firewall ipv4 input filter rule 50 protocol icmp
set firewall ipv4 input filter rule 50 time weekdays '!Sat'
commit

Actual result

The CLI accepts the value, and the commit fails:

[ firewall ]
Fail to apply firewall
Error found on: firewall ipv4 input filter rule 50
        Error message: syntax error, unexpected '}'
[[firewall]] failed
Commit failed

The same happens with '!Sat,!Sun' and '!6'.

With a mix of plain and negated days, for example 'Mon,!Sat', the commit succeeds with no warning, and the rule contains only the plain days: meta day "Monday". The !Sat part is dropped.

Cause

python/vyos/firewall.py, parse_time():

out_days = [f'"{expand_weekday(day).title()}"' for day in days if day[0] != '!']
out.append(f'day {{{",".join(out_days)}}}')

Days starting with ! are filtered out, and nothing is rendered for them. The weekdays node (interface-definitions/include/firewall/time.xml.i) has no constraint, so the CLI accepts any value.

Details

Version
rolling, 1.4, 1.5
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)