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

Improve template macros for grub command line #10989

Conversation

teacup-on-rockingchair
Copy link
Contributor

Description:

  • Some border cases of strange state of /etc/default/grub file revealed some minor issues with current remediations

Rationale:

  • Cover the case where default grub file has the GRUB_CMDLINE_LINUX line but it is commented or the case where no such line exists

Cover the case where default grub file has the GRUB_CMDLINE_LINUX line but it is commented
or the case where no such line exists
@teacup-on-rockingchair teacup-on-rockingchair added Ansible Ansible remediation update. Bash Bash remediation update. labels Aug 14, 2023
@github-actions
Copy link

github-actions bot commented Aug 14, 2023

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@jan-cerny
Copy link
Collaborator

@teacup-on-rockingchair It would be great to add a test scenario that would test this situation.

@jan-cerny jan-cerny self-assigned this Aug 16, 2023
@jan-cerny jan-cerny added this to the 0.1.70 milestone Aug 16, 2023
@@ -0,0 +1,5 @@
#!/bin/bas
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing h

@@ -0,0 +1,5 @@
#!/bin/bas
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing h

#!/bin/bas
# platform = Red Hat Enterprise Linux 7,sle12,sle15

# Removes kernel command line in /etc/default/grub
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't exactly remove it, instead, it comments it out.

@@ -0,0 +1,5 @@
#!/bin/bas
# platform = Red Hat Enterprise Linux 7,sle12,sle15
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can't use the short IDs, you should use full names:

# platform = Red Hat Enterprise Linux 7,Oracle Linux 7,SUSE Linux Enterprise 12,SUSE Linux Enterprise 15

Copy link
Contributor Author

Choose a reason for hiding this comment

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

used a multi_platform_sle instead , anyways that was the idea

@@ -0,0 +1,5 @@
#!/bin/bas
# platform = Red Hat Enterprise Linux 7,sle12,sle15
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can't use the short IDs, you should use full names

@teacup-on-rockingchair teacup-on-rockingchair force-pushed the improve_grub2_bootloader_argument_macros branch from 7e47f53 to 2634ce2 Compare August 17, 2023 04:25
@teacup-on-rockingchair teacup-on-rockingchair force-pushed the improve_grub2_bootloader_argument_macros branch from 2634ce2 to a2d4a97 Compare August 17, 2023 04:26
@codeclimate
Copy link

codeclimate bot commented Aug 17, 2023

Code Climate has analyzed commit a2d4a97 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.3% (0.0% change).

View more on Code Climate.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

When the tests are executed on a virtual machine backend, they're OK:

[jcerny@fedora scap-security-guide{pr/10989}]$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel7 --datastream build/ssg-rhel7-ds.xml grub2_ipv6_disable_argument
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/jcerny/work/git/scap-security-guide/logs/rule-custom-2023-08-21-0946/test_suite.log
WARNING - Script arg_not_there_grubenv.fail.sh is not applicable on given platform
WARNING - Script wrong_value_entries.fail.sh is not applicable on given platform
WARNING - Script wrong_value.fail.sh is not applicable on given platform
WARNING - Script invalid_rescue.pass.sh is not applicable on given platform
WARNING - Script arg_not_there_rhel8.fail.sh is not applicable on given platform
WARNING - Script correct_grubenv.pass.sh is not applicable on given platform
WARNING - Script wrong_value_rhel8.fail.sh is not applicable on given platform
WARNING - Script arg_not_there_rhel9.fail.sh is not applicable on given platform
WARNING - Script wrong_value_rhel9.fail.sh is not applicable on given platform
INFO - xccdf_org.ssgproject.content_rule_grub2_ipv6_disable_argument
INFO - Script arg_not_there_etcdefaultgrub.fail.sh using profile (all) OK
INFO - Script arg_not_there_etcdefaultgrub_recovery_disabled.fail.sh using profile (all) OK
INFO - Script arg_not_there_rhel7.fail.sh using profile (all) OK
INFO - Script correct_grubby.pass.sh using profile (all) OK
INFO - Script correct_recovery_disabled.pass.sh using profile (all) OK
INFO - Script correct_value.pass.sh using profile (all) OK
INFO - Script wrong_value_etcdefaultgrub.fail.sh using profile (all) OK
INFO - Script wrong_value_etcdefaultgrub_recovery_disabled.fail.sh using profile (all) OK
INFO - Script wrong_value_rhel7.fail.sh using profile (all) OK
INFO - Script cmd_line_commented_etcdefaultgrub.fail.sh using profile (all) OK
INFO - Script cmd_line_not_there_etcdefaultgrub.fail.sh using profile (all) OK
[jcerny@fedora scap-security-guide{pr/10989}]$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel7 --remediate-using ansible --datastream build/ssg-rhel7-ds.xml grub2_ipv6_disable_argument
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/jcerny/work/git/scap-security-guide/logs/rule-custom-2023-08-21-0957/test_suite.log
WARNING - Script arg_not_there_grubenv.fail.sh is not applicable on given platform
WARNING - Script invalid_rescue.pass.sh is not applicable on given platform
WARNING - Script wrong_value_entries.fail.sh is not applicable on given platform
WARNING - Script wrong_value.fail.sh is not applicable on given platform
WARNING - Script arg_not_there_rhel8.fail.sh is not applicable on given platform
WARNING - Script correct_grubenv.pass.sh is not applicable on given platform
WARNING - Script wrong_value_rhel8.fail.sh is not applicable on given platform
WARNING - Script arg_not_there_rhel9.fail.sh is not applicable on given platform
WARNING - Script wrong_value_rhel9.fail.sh is not applicable on given platform
INFO - xccdf_org.ssgproject.content_rule_grub2_ipv6_disable_argument
INFO - Script arg_not_there_etcdefaultgrub.fail.sh using profile (all) OK
INFO - Script arg_not_there_etcdefaultgrub_recovery_disabled.fail.sh using profile (all) OK
INFO - Script arg_not_there_rhel7.fail.sh using profile (all) OK
INFO - Script correct_grubby.pass.sh using profile (all) OK
INFO - Script correct_recovery_disabled.pass.sh using profile (all) OK
INFO - Script correct_value.pass.sh using profile (all) OK
INFO - Script wrong_value_etcdefaultgrub.fail.sh using profile (all) OK
INFO - Script wrong_value_etcdefaultgrub_recovery_disabled.fail.sh using profile (all) OK
INFO - Script wrong_value_rhel7.fail.sh using profile (all) OK
INFO - Script cmd_line_commented_etcdefaultgrub.fail.sh using profile (all) OK
INFO - Script cmd_line_not_there_etcdefaultgrub.fail.sh using profile (all) OK

@jan-cerny
Copy link
Collaborator

The CI fail on Rawhide is caused by missing dnf, the fail of testing farm on c8s is tracked in #10978, both fails aren't caused by the changes in this pull request.

@jan-cerny jan-cerny merged commit 88ea90c into ComplianceAsCode:master Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. Bash Bash remediation update.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants