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

SLE improve kernel module disabled rule #10368

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions shared/templates/kernel_module_disabled/ansible.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,17 @@
# strategy = disable
# complexity = low
# disruption = medium
{{% if product in ["sle12", "sle15"] %}}
- name: Ensure kernel module '{{{ KERNMODULE }}}' is disabled
lineinfile:
create: yes
dest: "/etc/modprobe.d/50-blacklist.conf"
regexp: '^blacklist {{{ KERNMODULE }}}$'
line: "blacklist {{{ KERNMODULE }}}"
{{% else %}}
- name: Ensure kernel module '{{{ KERNMODULE }}}' is disabled
lineinfile:
create: yes
dest: "/etc/modprobe.d/{{{ KERNMODULE }}}.conf"
regexp: 'install\s+{{{ KERNMODULE }}}'
line: "install {{{ KERNMODULE }}} /bin/true"
{{% if product in ["ol7", "ol8"] or 'rhel' in product %}}
{{% if product in ["ol7", "ol8", "sle12", "sle15"] or 'rhel' in product %}}
- name: Ensure kernel module '{{{ KERNMODULE }}}' is blacklisted
lineinfile:
create: yes
dest: "/etc/modprobe.d/{{{ KERNMODULE }}}.conf"
regexp: '^blacklist {{{ KERNMODULE }}}$'
line: "blacklist {{{ KERNMODULE }}}"
{{% endif %}}
{{% endif %}}
9 changes: 1 addition & 8 deletions shared/templates/kernel_module_disabled/bash.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
# strategy = disable
# complexity = low
# disruption = medium
{{% if product in ["sle12", "sle15"] %}}
if ! LC_ALL=C grep -q -m 1 "^blacklist {{{ KERNMODULE }}}$" /etc/modprobe.d/50-blacklist.conf ; then
echo -e "\n# Disable per security requirements" >> /etc/modprobe.d/50-blacklist.conf
echo "blacklist {{{ KERNMODULE }}}" >> /etc/modprobe.d/50-blacklist.conf
fi
{{% else %}}
if LC_ALL=C grep -q -m 1 "^install {{{ KERNMODULE }}}" /etc/modprobe.d/{{{ KERNMODULE }}}.conf ; then
{{% if '#' in KERNMODULE %}}
{{{ raise("KERNMODULE (" + KERNMODULE + ") uses sed path separator (#) in " + rule_id) }}}
Expand All @@ -18,9 +12,8 @@ else
echo -e "\n# Disable per security requirements" >> /etc/modprobe.d/{{{ KERNMODULE }}}.conf
echo "install {{{ KERNMODULE }}} /bin/true" >> /etc/modprobe.d/{{{ KERNMODULE }}}.conf
fi
{{% if product in ["ol7", "ol8"] or 'rhel' in product %}}
{{% if product in ["ol7", "ol8", "sle12", "sle15"] or 'rhel' in product %}}
if ! LC_ALL=C grep -q -m 1 "^blacklist {{{ KERNMODULE }}}$" /etc/modprobe.d/{{{ KERNMODULE }}}.conf ; then
echo "blacklist {{{ KERNMODULE }}}" >> /etc/modprobe.d/{{{ KERNMODULE }}}.conf
fi
{{% endif %}}
{{% endif %}}
11 changes: 1 addition & 10 deletions shared/templates/kernel_module_disabled/oval.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
id="kernel_module_{{{ KERNMODULE }}}_disabled" version="1">
{{{ oval_metadata("The kernel module " + KERNMODULE + " should be disabled.") }}}
<criteria operator="OR">
{{% if product in ["sle12", "sle15"] %}}
<criterion test_ref="test_kernmod_{{{ KERNMODULE }}}_blacklisted"
comment="kernel module {{{ KERNMODULE }}} blacklisted in modprobe.d" />
{{% elif product in ["ol7", "ol8", "rhcos4"] or 'rhel' in product %}}
{{% if product in ["ol7", "ol8", "rhcos4", "sle12", "sle15"] or 'rhel' in product %}}
<criteria operator="AND">
<criterion test_ref="test_kernmod_{{{ KERNMODULE }}}_blacklisted"
comment="kernel module {{{ KERNMODULE }}} blacklisted in modprobe.d" />
Expand All @@ -24,7 +21,6 @@
</criteria>
</definition>

{{% if product not in ["sle12", "sle15"] %}}
<ind:textfilecontent54_test id="test_kernmod_{{{ KERNMODULE }}}_disabled" version="1" check="all"
comment="kernel module {{{ KERNMODULE }}} disabled">
<ind:object object_ref="obj_kernmod_{{{ KERNMODULE }}}_disabled" />
Expand All @@ -47,7 +43,6 @@
<value>/usr/lib/modprobe.d</value>
<value>/usr/lib/modules-load.d</value>
</constant_variable>
{{% endif %}}

{{% if product in ["ol7", "ol8", "rhcos4", "sle12", "sle15"] or 'rhel' in product %}}
<ind:textfilecontent54_test id="test_kernmod_{{{ KERNMODULE }}}_blacklisted" version="1" check="all"
Expand All @@ -57,12 +52,8 @@

<ind:textfilecontent54_object id="obj_kernmod_{{{ KERNMODULE }}}_blacklisted"
version="1" comment="kernel module {{{ KERNMODULE }}} blacklisted">
{{% if product in ["sle12", "sle15"] %}}
<ind:filepath>/etc/modprobe.d/50-blacklist.conf</ind:filepath>
{{% else %}}
<ind:path var_ref="var_kernel_module_{{{ KERNMODULE }}}_paths" var_check="at least one" />
<ind:filename operation="pattern match">^.*\.conf$</ind:filename>
{{% endif %}}
<ind:pattern operation="pattern match">^blacklist\s+{{{ KERNMODULE }}}$</ind:pattern>
<ind:instance datatype="int">1</ind:instance>
</ind:textfilecontent54_object>
Expand Down