fix: ensure rich rule handling is idempotent#358
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe pull request standardizes firewall rich rule representation by converting all configuration sources and backends to use a unified ChangesRich rule representation and storage standardization
Possibly related issues
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
3cab916 to
2d5f67b
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/tests_zone.yml (1)
48-55: ⚡ Quick winAdd an explicit verification for the newly configured rich rule.
The test now configures
rich_rule, but the verify block does not assert that rule is present; this can let rich-rule regressions hide behind unrelated zone changes.✅ Suggested verification task
+ - name: Verify firewalld zone internal rich rules + ansible.builtin.command: firewall-offline-cmd --zone=internal --list-rich-rules + register: result + changed_when: false + failed_when: result.failed + or 'rule family="ipv4" source address="192.0.2.0/24" reject' + not in result.stdoutAs per coding guidelines, "Tests should verify both success and failure scenarios" and "Use assert module to verify expected state after role execution".
Also applies to: 99-106, 153-160
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/tests_zone.yml` around lines 48 - 55, Add an explicit assertion in the verify block of the tests for the zone that checks the configured rich_rule value (the 'rich_rule' entry set to 'rule family="ipv4" source address="192.0.2.0/24" reject') so the test fails if that rule is not applied; update the verify task(s) that currently check zone/state/service/port/forward_port to also import and use the assert module and assert that the actual zone rich_rule equals the expected string (apply same change for the other occurrences mentioned around lines 99-106 and 153-160).Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/tests_zone.yml`:
- Around line 48-55: Add an explicit assertion in the verify block of the tests
for the zone that checks the configured rich_rule value (the 'rich_rule' entry
set to 'rule family="ipv4" source address="192.0.2.0/24" reject') so the test
fails if that rule is not applied; update the verify task(s) that currently
check zone/state/service/port/forward_port to also import and use the assert
module and assert that the actual zone rich_rule equals the expected string
(apply same change for the other occurrences mentioned around lines 99-106 and
153-160).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d0fe3432-5764-4bc1-aa04-d20bdfddcc21
📒 Files selected for processing (3)
library/firewall_lib.pymodule_utils/firewall_lsr/get_config.pytests/tests_zone.yml
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #358 +/- ##
===========================================
- Coverage 61.09% 42.99% -18.11%
===========================================
Files 2 4 +2
Lines 910 2342 +1432
===========================================
+ Hits 556 1007 +451
- Misses 354 1335 +981
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2d5f67b to
2538193
Compare
|
[citest] |
Cause: The in-memory backend was using a key 'rich_rule' for handling the rich rules, but the code in get_config was using 'rules_str'. Consequence: The firewall module added the rich rule every time to the 'rich_rule' key, ignoring the 'rules_str' key, and was not idempotent. Fix: Ensure that the key 'rich_rule' is used everywhere. When reading the information from the firewall api, ensure that the data under the key 'rules_str' is normalized and added to the 'rich_rule' key. Result: The firewall role can manage rich rules idempotently. Signed-off-by: Rich Megginson <rmeggins@redhat.com> Fixes: linux-system-roles#357
2538193 to
4c4e619
Compare
|
[citest] |
Cause: The in-memory backend was using a key 'rich_rule' for handling the rich
rules, but the code in get_config was using 'rules_str'.
Consequence: The firewall module added the rich rule every time to the 'rich_rule'
key, ignoring the 'rules_str' key, and was not idempotent.
Fix: Ensure that the key 'rich_rule' is used everywhere. When reading the information
from the firewall api, ensure that the data under the key 'rules_str' is normalized
and added to the 'rich_rule' key.
Result: The firewall role can manage rich rules idempotently.
Signed-off-by: Rich Megginson rmeggins@redhat.com
Fixes: #357
Summary by CodeRabbit
Improvements
Tests