Page MenuHomeVyOS Platform

Fix comparing of firewall rules
In progress, NormalPublicBUG

Description

Part of this description is copied from the GitHub PR.

The zip function used here is insufficient for comparing rules.

As mentioned in the docs of Python:

The iterator stops when the shortest input iterable is exhausted

Here is a example how this could cause a issue, in Python:

first = [{"key": "value1"}, {"key": "value2"}]
second = [{"key": "value1"}]
zipped = list(zip(first, second))
zipped[0][0] == zipped[0][1]
#True

To test this with the module:

Run this code in a testing VyOS:

vyos
delete firewall
set firewall name test default-action 'drop'
set firewall name test rule 1 action 'accept'
set firewall name test rule 1 protocol 'all'
set firewall name test rule 2 action 'drop'
set firewall name test rule 2 protocol 'all'

(those rules don't make any sense. This is just an example!)

with this ansible code, I would expect only the first rule to remain:

yaml
- name: Set firewall rules
  vyos.vyos.vyos_firewall_rules:
    config:
      - afi: ipv4
        rule_sets:
          - default_action: drop
            name: test
            rules:
              - action: accept
                protocol: all
                number: 1
    state: overridden

Currently, this does nothing.

Details

Version
6.0.0
Is it a breaking change?
Behavior change
Issue type
Bug (incorrect behavior)
Story points
0

Event Timeline

RubenNL changed Is it a breaking change? from Unspecified (possibly destroys the router) to Behavior change.Tue, Mar 11, 9:23 AM
RubenNL renamed this task from Comparing of firewall rules doesn't check amount of rules to Fix comparing of firewall rules.Tue, Mar 11, 2:15 PM
Viacheslav changed the task status from Open to In progress.Tue, Mar 11, 4:47 PM
Viacheslav assigned this task to RubenNL.
Viacheslav triaged this task as Normal priority.