-
Notifications
You must be signed in to change notification settings - Fork 698
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
Prevent quoting issues in rule firewalld-backend #10820
Conversation
This datastream diff is auto generated by the check Click here to see the full diffbash remediation for rule 'xccdf_org.ssgproject.content_rule_firewalld-backend' differs.
--- xccdf_org.ssgproject.content_rule_firewalld-backend
+++ xccdf_org.ssgproject.content_rule_firewalld-backend
@@ -16,10 +16,10 @@
if [ -z "$line_number" ]; then
# There was no match of '^#\s*FirewallBackend', insert at
# the end of the file.
- printf '%s\n' "FirewallBackend='nftables'" >> "/etc/firewalld/firewalld.conf"
+ printf '%s\n' "FirewallBackend=nftables" >> "/etc/firewalld/firewalld.conf"
else
head -n "$(( line_number - 1 ))" "/etc/firewalld/firewalld.conf.bak" > "/etc/firewalld/firewalld.conf"
- printf '%s\n' "FirewallBackend='nftables'" >> "/etc/firewalld/firewalld.conf"
+ printf '%s\n' "FirewallBackend=nftables" >> "/etc/firewalld/firewalld.conf"
tail -n "+$(( line_number ))" "/etc/firewalld/firewalld.conf.bak" >> "/etc/firewalld/firewalld.conf"
fi
# Clean up after ourselves.
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_firewalld-backend' differs.
--- xccdf_org.ssgproject.content_rule_firewalld-backend
+++ xccdf_org.ssgproject.content_rule_firewalld-backend
@@ -12,7 +12,7 @@
- no_reboot_needed
- restrict_strategy
-- name: Setting shell-quoted shell-style assignment of 'FirewallBackend' to 'nftables'
+- name: Setting unquoted shell-style assignment of 'FirewallBackend' to 'nftables'
in '/etc/firewalld/firewalld.conf'
block:
@@ -39,7 +39,7 @@
path: /etc/firewalld/firewalld.conf
create: true
regexp: ^\s*FirewallBackend=
- line: FirewallBackend="nftables"
+ line: FirewallBackend=nftables
state: present
insertbefore: ^# FirewallBackend
validate: /usr/bin/bash -n %s |
@Mab879 I have add a small test scenario. |
Can you please rebase this PR? That should fix the CI. |
We will set the no_quotes parameter of the template to avoid issues that can be caused by extra quotes in the configuration file. For example, setting `CleanupOnExit='no'` causes this problem: ``` Jul 11 10:22:20 fedora firewalld[117694]: WARNING: CleanupOnExit ''no'' is not valid, using default value True ``` The default for the `FirewallBackend` option is `nftables`, adding quotes will not cause a problem, until firewalld decides in future to change the defaults. ``` Jul 11 10:25:18 fedora firewalld[118127]: WARNING: FirewallBackend ''nftables'' is not valid, using default value nftables ``` We have seen similar things with journald rules, where it actually caused troubles, check: https://bugzilla.redhat.com/show_bug.cgi?id=2193169
ae6d8e5
to
3e51b8e
Compare
I have rebased this PR on the top of the latest upstream master branch. |
Code Climate has analyzed commit 3e51b8e and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 53.4% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waving Automatus tests as they pass locally.
$ ./automatus.py rule --libvirt qemu:///system automatus_rhel_9_latest_2 --remediate-using ansible --datastream ../build/ssg-rhel9-ds.xml firewalld-backend
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/mburket/review/ComplianceAsCode/content/tests/logs/rule-custom-2023-07-14-1515/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_firewalld-backend
INFO - Script quoted.fail.sh using profile (all) OK
INFO - Script missing.fail.sh using profile (all) OK
INFO - Script correct_value.pass.sh using profile (all) OK
INFO - Script wrong_value.fail.sh using profile (all) OK
We will set the no_quotes parameter of the template to avoid issues that can be caused by extra quotes in the configuration file.
For example, setting
CleanupOnExit='no'
causes this problem:The default for the
FirewallBackend
option isnftables
, adding quotes will not cause a problem, until firewalld decides in future to change the defaults.We have seen similar things with journald rules, where it actually caused troubles, check:
https://bugzilla.redhat.com/show_bug.cgi?id=2193169