-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9911 from marcusburghardt/grub2_enable_selinux_an…
…sible Stabilization: Make Ansible remediation less prone to fatal errors
- Loading branch information
Showing
9 changed files
with
88 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 28 additions & 26 deletions
54
linux_os/guide/system/selinux/grub2_enable_selinux/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,55 @@ | ||
<def-group> | ||
<definition class="compliance" id="grub2_enable_selinux" version="1"> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="2"> | ||
{{{ oval_metadata(" | ||
Check if selinux=0 OR enforcing=0 within the GRUB2 configuration files, fail if found. | ||
") }}} | ||
<criteria operator="AND"> | ||
<criterion comment="check value selinux|enforcing=0 in /etc/default/grub, fail if found" test_ref="test_selinux_default_grub" /> | ||
<criterion comment="check value selinux|enforcing=0 in /etc/grub2.cfg, fail if found" test_ref="test_selinux_grub2_cfg" /> | ||
<criterion comment="check value selinux|enforcing=0 in /etc/grub.d, fail if found" test_ref="test_selinux_grub_dir" /> | ||
<criterion test_ref="test_selinux_default_grub" | ||
comment="check value selinux|enforcing=0 in /etc/default/grub, fail if found"/> | ||
<criterion test_ref="test_selinux_grub2_cfg" | ||
comment="check value selinux|enforcing=0 in /etc/grub2.cfg, fail if found"/> | ||
<criterion test_ref="test_selinux_grub_dir" | ||
comment="check value selinux|enforcing=0 in /etc/grub.d, fail if found"/> | ||
</criteria> | ||
</definition> | ||
|
||
<ind:textfilecontent54_test check="all" check_existence="none_exist" | ||
comment="check value selinux|enforcing=0 in /etc/default/grub, fail if found" | ||
id="test_selinux_default_grub" version="1"> | ||
<ind:object object_ref="object_selinux_default_grub" /> | ||
<ind:textfilecontent54_test id="test_selinux_default_grub" version="1" | ||
check="all" check_existence="none_exist" | ||
comment="check value selinux|enforcing=0 in /etc/default/grub, fail if found"> | ||
<ind:object object_ref="object_selinux_default_grub"/> | ||
</ind:textfilecontent54_test> | ||
<ind:textfilecontent54_object id="object_selinux_default_grub" | ||
comment="check value selinux|enforcing=0 in /etc/default/grub, fail if found" | ||
version="1"> | ||
|
||
<ind:textfilecontent54_object id="object_selinux_default_grub" version="1" | ||
comment="check value selinux|enforcing=0 in /etc/default/grub, fail if found"> | ||
<ind:filepath>/etc/default/grub</ind:filepath> | ||
<ind:pattern operation="pattern match">^[\s]*GRUB_CMDLINE_LINUX.*(selinux|enforcing)=0.*$</ind:pattern> | ||
<ind:instance datatype="int" operation="equals">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
<ind:textfilecontent54_test check="all" check_existence="none_exist" | ||
comment="check value selinux|enforcing=0 in /etc/grub2.cfg, fail if found" | ||
id="test_selinux_grub2_cfg" version="1"> | ||
<ind:object object_ref="object_selinux_grub2_cfg" /> | ||
<ind:textfilecontent54_test id="test_selinux_grub2_cfg" version="1" | ||
check="all" check_existence="none_exist" | ||
comment="check value selinux|enforcing=0 in /etc/grub2.cfg, fail if found"> | ||
<ind:object object_ref="object_selinux_grub2_cfg"/> | ||
</ind:textfilecontent54_test> | ||
<ind:textfilecontent54_object id="object_selinux_grub2_cfg" | ||
comment="check value selinux|enforcing=0 in /etc/grub2.cfg, fail if found" | ||
version="1"> | ||
|
||
<ind:textfilecontent54_object id="object_selinux_grub2_cfg" version="1" | ||
comment="check value selinux|enforcing=0 in /etc/grub2.cfg, fail if found"> | ||
<ind:filepath>/etc/grub2.cfg</ind:filepath> | ||
<ind:pattern operation="pattern match">^.*(selinux|enforcing)=0.*$</ind:pattern> | ||
<ind:instance datatype="int" operation="equals">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
<ind:textfilecontent54_test check="all" check_existence="none_exist" | ||
comment="check value selinux|enforcing=0 in /etc/grub.d fail if found" | ||
id="test_selinux_grub_dir" version="1"> | ||
<ind:object object_ref="object_selinux_grub_dir" /> | ||
<ind:textfilecontent54_test id="test_selinux_grub_dir" version="1" | ||
check="all" check_existence="none_exist" | ||
comment="check value selinux|enforcing=0 in /etc/grub.d fail if found"> | ||
<ind:object object_ref="object_selinux_grub_dir"/> | ||
</ind:textfilecontent54_test> | ||
<ind:textfilecontent54_object id="object_selinux_grub_dir" | ||
comment="check value selinux|enforcing=0 in /etc/grub.d, fail if found" | ||
version="1"> | ||
|
||
<ind:textfilecontent54_object id="object_selinux_grub_dir" version="1" | ||
comment="check value selinux|enforcing=0 in /etc/grub.d, fail if found"> | ||
<ind:path>/etc/grub.d</ind:path> | ||
<ind:filename operation="pattern match">^.*$</ind:filename> | ||
<ind:pattern operation="pattern match">^.*(selinux|enforcing)=0.*$</ind:pattern> | ||
<ind:instance datatype="int" operation="equals">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
</def-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
..._os/guide/system/selinux/grub2_enable_selinux/tests/selinux_disabled_default_grub.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
echo "GRUB_CMDLINE_LINUX=selinux=0 enforcing=0 audit=1" >> /etc/default/grub | ||
sed -i --follow-symlinks "s/selinux=0//gI" /etc/grub2.cfg /etc/grub.d/* | ||
sed -i --follow-symlinks "s/enforcing=0//gI" /etc/grub2.cfg /etc/grub.d/* |
5 changes: 5 additions & 0 deletions
5
...e/system/selinux/grub2_enable_selinux/tests/selinux_disabled_default_grub_missing.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
rm -f /etc/default/grub | ||
sed -i --follow-symlinks "s/selinux=0//gI" /etc/grub2.cfg /etc/grub.d/* | ||
sed -i --follow-symlinks "s/enforcing=0//gI" /etc/grub2.cfg /etc/grub.d/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
linux_os/guide/system/selinux/grub2_enable_selinux/tests/selinux_disabled_grub_cfg.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
echo "selinux=0" >> /etc/grub2.cfg | ||
echo "enforcing=0" >> /etc/grub2.cfg | ||
sed -i --follow-symlinks "s/selinux=0//gI" /etc/default/grub /etc/grub.d/* | ||
sed -i --follow-symlinks "s/enforcing=0//gI" /etc/default/grub /etc/grub.d/* |
6 changes: 6 additions & 0 deletions
6
linux_os/guide/system/selinux/grub2_enable_selinux/tests/selinux_disabled_grub_d.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
echo "selinux=0" > /etc/grub.d/tmp_file | ||
echo "enforcing=0" >> /etc/grub.d/tmp_file | ||
sed -i --follow-symlinks "s/selinux=0//gI" /etc/default/grub /etc/grub2.cfg | ||
sed -i --follow-symlinks "s/enforcing=0//gI" /etc/default/grub /etc/grub2.cfg |
5 changes: 5 additions & 0 deletions
5
linux_os/guide/system/selinux/grub2_enable_selinux/tests/selinux_enable_similar_line.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
echo "rubbish=0" >> /etc/grub.d/tmp_file | ||
sed -i --follow-symlinks "s/selinux=0//gI" /etc/default/grub /etc/grub2.cfg /etc/grub.d/* | ||
sed -i --follow-symlinks "s/enforcing=0//gI" /etc/default/grub /etc/grub2.cfg /etc/grub.d/* |