]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commit
(SEC-944) Handle duplicate system rules SEC-944-handle_duplicate_rule_comments
authorCraig Gumbley <craiggumbley@gmail.com>
Thu, 17 Feb 2022 09:27:36 +0000 (09:27 +0000)
committerCraig Gumbley <craiggumbley@gmail.com>
Thu, 17 Feb 2022 15:21:56 +0000 (15:21 +0000)
commit40ed022ba59fcf5792c3e48450a017de6b4dd8fb
treea8222fb87263d551e6d0d2e8b1d8d1fc1cdc3c74
parentdc4d38c6431f4bad6330a1d9583f32d55c8224bb
(SEC-944) Handle duplicate system rules

In certain situations it is possible for an unmanaged rule to exist on
the target system that has the same comment as the rule specified in
the manifest.

When this condition is true puppet will ignore the the unmanaged rule
and continue to apply the rule in the manifest. This is because the
firewall module uses the comment field in IPT as it's namevar and
therefore expects it to be a unique identifier. In the case of IPT this
is not true given that you can have multiple rules with the same
comment.

This commit attempts to fix this behaviour by counting the occurrences
of each rule on the system with the expectation that there will only ever
be a count of 1 for each. In the case where the count is greater than 1,
the module will mark the rule as duplicate and emit a warning log
message. When the purge metaparam is set to true, the duplicate rules
will be removed and the puppet agent will reapply the correct one from
the manifest.
lib/puppet/provider/firewall/iptables.rb