Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(SEC-944) Handle duplicate system rules #1030

Merged
merged 5 commits into from
Feb 28, 2022

Conversation

chelnak
Copy link
Contributor

@chelnak chelnak commented Feb 21, 2022

Context

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.

What has changed?

This commit adds a check that will identify system rules that have their comment field set to the same value as a rule in the manifest. If we enter a situation where any of the duplicate counts are greater than 1 then we will respond with a configurable action. The behaviour of this can be configured via the onduplicaterulebehaviour parameter.

@chelnak chelnak requested a review from a team as a code owner February 21, 2022 09:32
david22swan
david22swan previously approved these changes Feb 21, 2022
@chelnak chelnak force-pushed the SEC-944-handle_duplicate_rule_comments_v2 branch 2 times, most recently from 8acd01a to c05cdaa Compare February 22, 2022 12:34
@chelnak chelnak force-pushed the SEC-944-handle_duplicate_rule_comments_v2 branch from c05cdaa to 7f25c62 Compare February 22, 2022 12:36
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 adds a check that will identify system rules that have their
comment field set to the same value as a rule in the manifest. If we
enter a situation where any of the duplicate counts are greater than 1
then we will respond with a configurable action. The behaviour of this
can be configured via the onduplicaterulebehaviour parameter.
@chelnak chelnak force-pushed the SEC-944-handle_duplicate_rule_comments_v2 branch from 7f25c62 to 91d4d48 Compare February 22, 2022 14:22
Copy link
Contributor

@michaeltlombardi michaeltlombardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding a section to the README for duplicate rules/behavior.

Here we add a new parameter that determines how the puppet run will
behave if a duplicate system rule is encountered. The default is to
warn and continue.
@chelnak chelnak force-pushed the SEC-944-handle_duplicate_rule_comments_v2 branch from 91d4d48 to 1c9914f Compare February 22, 2022 14:33
This commit adds a new section to inform users about how the module will behave when it encounters duplicate rules.

It also inclues a small bit of house keeping.
@chelnak
Copy link
Contributor Author

chelnak commented Feb 22, 2022

@michaeltlombardi README updated 👍

README.md Outdated Show resolved Hide resolved
Co-authored-by: Michael T Lombardi (He/Him) <michael.lombardi@puppet.com>
Copy link
Contributor

@michaeltlombardi michaeltlombardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the documentation and code implementation, this still needs testing (unit and acceptance).

@chelnak chelnak force-pushed the SEC-944-handle_duplicate_rule_comments_v2 branch 2 times, most recently from aff7a87 to 5487964 Compare February 28, 2022 13:27
Prior to this commit there we no test cases to validate our
changes to the module.

This commit adds test cases for each of the configurations for
onduplicaterulebehaviour.
@chelnak chelnak force-pushed the SEC-944-handle_duplicate_rule_comments_v2 branch from 5487964 to 30db99b Compare February 28, 2022 13:37
@chelnak
Copy link
Contributor Author

chelnak commented Feb 28, 2022

#1031 raised for unrelated failing tests

Copy link
Member

@david22swan david22swan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@david22swan david22swan merged commit 45228a5 into main Feb 28, 2022
@david22swan david22swan deleted the SEC-944-handle_duplicate_rule_comments_v2 branch February 28, 2022 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants