-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#0): cis_ubuntu2404_rule_1_1_1_10 block not loopable
- Loading branch information
1 parent
5e68fdf
commit ed4e848
Showing
2 changed files
with
81 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
# tasks file for ansible-cis-ubuntu-2404 | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
- name: > | ||
SECTION1 | 1.1.1.10 | Ensure unused filesystems kernel modules are not available | check if filesystem is mounted for {{ cis_ubuntu2404_fs_module_file }} | ||
ansible.builtin.set_fact: | ||
cis_ubuntu2404_is_fs_mounted: "{{ cis_ubuntu2404_fs_module_file in cis_ubuntu2404_mounted_filesystems.stdout_lines }}" | ||
tags: | ||
- rule_1_1_1 | ||
- server_l2 | ||
- workstation_l2 | ||
|
||
- name: > | ||
SECTION1 | 1.1.1.10 | Ensure unused filesystems kernel modules are not available | check if kernel module is loaded for {{ cis_ubuntu2404_fs_module_file }} | ||
ansible.builtin.shell: "set -o pipefail && lsmod | grep {{ cis_ubuntu2404_fs_module_file }}" | ||
args: | ||
executable: "{{ cis_ubuntu2404_shell_executable }}" | ||
register: cis_ubuntu2404_lsmod_output | ||
changed_when: false | ||
failed_when: false | ||
check_mode: false | ||
tags: | ||
- rule_1_1_1 | ||
- server_l2 | ||
- workstation_l2 | ||
|
||
- name: > | ||
SECTION1 | 1.1.1.10 | Ensure unused filesystems kernel modules are not available | log vulnerable filesystem | ||
ansible.builtin.debug: | ||
msg: "** WARNING: Filesystem {{ cis_ubuntu2404_fs_module_file }} is loaded and vulnerable to CVE!" | ||
when: | ||
- cis_ubuntu2404_lsmod_output.rc == 0 | ||
- not cis_ubuntu2404_is_fs_mounted | bool | ||
tags: | ||
- rule_1_1_1 | ||
- server_l2 | ||
- workstation_l2 | ||
|
||
- name: > | ||
SECTION1 | 1.1.1.10 | Ensure unused filesystems kernel modules are not available | unload kernel module if loaded for {{ cis_ubuntu2404_fs_module_file }} | ||
community.general.modprobe: | ||
name: "{{ cis_ubuntu2404_fs_module_file }}" | ||
state: absent | ||
when: | ||
- cis_ubuntu2404_lsmod_output.rc == 0 | ||
- not cis_ubuntu2404_is_fs_mounted | bool | ||
tags: | ||
- rule_1_1_1 | ||
- server_l2 | ||
- workstation_l2 | ||
|
||
- name: > | ||
SECTION1 | 1.1.1.10 | Ensure unused filesystems kernel modules are not available | setting module and deny listing for {{ item }} | ||
ansible.builtin.lineinfile: | ||
dest: /etc/modprobe.d/cis.conf | ||
regexp: "{{ item.reg }}" | ||
line: "{{ item.line }}" | ||
state: present | ||
create: true | ||
owner: "{{ cis_ubuntu2404_section1_owner_default }}" | ||
group: "{{ cis_ubuntu2404_section1_group_default }}" | ||
mode: "{{ cis_ubuntu2404_section1_mode_default }}" | ||
with_items: | ||
- reg: '{{ cis_ubuntu2404_regex_base_search }}install {{ item }}(\s|$)' | ||
line: "install {{ item }} /bin/false" | ||
- reg: "{{ cis_ubuntu2404_regex_base_search }}blacklist {{ item }}$" | ||
line: "blacklist {{ item }}" | ||
when: | ||
- cis_ubuntu2404_lsmod_output.rc == 0 | ||
- not cis_ubuntu2404_is_fs_mounted | bool | ||
tags: | ||
- rule_1_1_1 | ||
- server_l2 | ||
- workstation_l2 |
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