Skip to content

Commit 81a9299

Browse files
authored
Merge pull request #259 from ansible-lockdown/devel
CIS v1.0.0 updates Nov 2024
2 parents 16cb6a4 + 2ff1550 commit 81a9299

18 files changed

+34
-45
lines changed

.github/workflows/devel_pipeline_validation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
jobs:
2828
# This will create messages for first time contributers and direct them to the Discord server
2929
welcome:
30-
runs-on: self-hosted
30+
runs-on: ubuntu-latest
3131

3232
steps:
3333
- uses: actions/first-interaction@main

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ci:
77

88
repos:
99
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: v4.6.0
10+
rev: v5.0.0
1111
hooks:
1212
# Safety
1313
- id: detect-aws-credentials
@@ -37,13 +37,13 @@ repos:
3737
exclude: .config/.gitleaks-report.json
3838

3939
- repo: https://github.com/gitleaks/gitleaks
40-
rev: v8.18.4
40+
rev: v8.21.2
4141
hooks:
4242
- id: gitleaks
4343
args: ['--baseline-path', '.config/.gitleaks-report.json']
4444

4545
- repo: https://github.com/ansible-community/ansible-lint
46-
rev: v24.7.0
46+
rev: v24.10.0
4747
hooks:
4848
- id: ansible-lint
4949
name: Ansible-lint

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Refer to [Contributing Guide](./CONTRIBUTING.rst)
5353

5454
This role **will make changes to the system** which may have unintended consequences. This is not an auditing tool but rather a remediation tool to be used after an audit has been conducted.
5555

56-
Check Mode is not supported! The role will complete in check mode without errors, but it is not supported and should be used with caution. The RHEL8-CIS-Audit role or a compliance scanner should be used for compliance checking over check mode.
56+
Check Mode is not supported! The role will complete in check mode without errors, but it is not supported and should be used with caution. The RHEL9-CIS-Audit role or a compliance scanner should be used for compliance checking over check mode.
5757

5858
This role was developed against a clean install of the Operating System. If you are implementing to an existing system please review this role for any site specific changes that are needed.
5959

@@ -128,11 +128,9 @@ os_check: false
128128
**Technical Dependencies:**
129129

130130
- Python3
131-
- Ansible 2.10+
131+
- Ansible 2.12+
132132
- python-def (should be included in RHEL 9)
133133
- libselinux-python
134-
- pip packages
135-
- jmespath
136134
- collections found in collections/requirements.yml
137135

138136
pre-commit is available if installed on your host for pull request testing.

defaults/main.yml

+9-11
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,10 @@ rhel9cis_selinux_disable: false
4949
# UEFI boot('/etc/grub2-efi.cfg') or in case of BIOS legacy-boot('/etc/grub2.cfg').
5050
rhel9cis_legacy_boot: false
5151

52-
## Python Binary
53-
## This is used for python3 Installations where python2 OS modules are used in ansible
54-
python2_bin: /bin/python2.7
55-
5652
## Benchmark name used by audting control role
5753
# The audit variable found at the base
5854
## metadata for Audit benchmark
5955
benchmark_version: 'v1.0.0'
60-
6156
benchmark: RHEL9-CIS
6257

6358
# Whether to skip the system reboot before audit
@@ -526,6 +521,10 @@ rhel9cis_selinux_pol: targeted
526521
rhel9cis_selinux_enforce: enforcing
527522

528523
# Whether or not to run tasks related to auditing/patching the desktop environment
524+
## Control 1.8.1-10
525+
# This variable governs whether rules dealing with GUI specific packages(and/or their settings)
526+
# Discovered value can be overridden to true is required
527+
rhel9cis_gui: "{{ prelim_gnome_present.stat.exists | default(false) }}"
529528

530529
## Section 2. Services
531530

@@ -567,12 +566,6 @@ rhel9cis_chrony_server_minsources: 2
567566
# Set the respective variable to true to keep the service,
568567
# otherwise the service is stopped and disabled
569568

570-
## Control 1.8.10-10, 2.2.1
571-
# This variable governs whether rules dealing with GUI specific packages(and/or their settings) should
572-
# be executed either to:
573-
# - secure GDM, if GUI is needed('rhel9cis_gui: true')
574-
# - or remove GDM and X-Windows-system, if no GUI is needed('rhel9cis_gui: false')
575-
rhel9cis_gui: false
576569
## Control 2.2.2 - Ensure Avahi Server is not installed
577570
# This variable, when set to false, will specify that Avahi Server packages should be uninstalled.
578571
rhel9cis_avahi_server: false
@@ -1144,6 +1137,11 @@ rhel9cis_force_user_mindays: false
11441137
# This can break current connecting user access
11451138
rhel9cis_force_user_warnage: false
11461139

1140+
## Control 5.6.2 - Ensure system accounts are secured | Set nologin
1141+
# The system users on this list are allowed to have a shell (e.g. applications
1142+
# that require a shell to function)
1143+
rhel9cis_system_users_shell: []
1144+
11471145
## Control 5.6.3 - Ensure default user shell timeout is 900 seconds or less
11481146
# Session timeout setting file (TMOUT setting can be set in multiple files)
11491147
# Timeout value is in seconds. (60 seconds * 10 = 600)

handlers/main.yml

-4
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
- name: Grub2cfg
5858
ansible.builtin.shell: "grub2-mkconfig -o /boot/grub2/grub.cfg"
5959
ignore_errors: true # noqa ignore-errors
60-
tags:
61-
- skip_ansible_lint
6260

6361
- name: Restart rsyslog
6462
ansible.builtin.systemd:
@@ -102,8 +100,6 @@
102100

103101
- name: Restart auditd
104102
ansible.builtin.shell: service auditd restart
105-
tags:
106-
- skip_ansible_lint
107103

108104
- name: Change_requires_reboot
109105
ansible.builtin.set_fact:

tasks/prelim.yml

+7
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@
190190
- rhel9cis_force_gpg_key_import
191191
- ansible_facts.distribution == 'RedHat'
192192

193+
- name: "PRELIM | Discover Gnome Desktop Environment"
194+
ansible.builtin.stat:
195+
path: /usr/share/gnome/gnome-version.xml
196+
register: prelim_gnome_present
197+
tags:
198+
- always
199+
193200
- name: "PRELIM | Section 4.1 | Configure System Accounting (auditd)"
194201
ansible.builtin.package:
195202
name: audit

tasks/section_1/cis_1.1.2.x.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
src: "{{ item.device }}"
3333
fstype: "{{ item.fstype }}"
3434
state: present
35-
opts: defaults,{% if rhel9cis_rule_1_1_2_2 %}nodev,{% endif %}{% if rhel9cis_rule_1_1_2_3 %}noexec,{% endif %}{% if rhel9cis_rule_1_1_2_4 %}nosuid{% endif %}
35+
opts: "{{ item.options }}{% if ('nodev' not in item.options and rhel9cis_rule_1_1_2_2) %},nodev{% endif %}{% if ('noexec' not in item.options and rhel9cis_rule_1_1_2_3) %},noexec{% endif %}{% if ('nosuid' not in item.options and rhel9cis_rule_1_1_2_4) %},nosuid{% endif %}"
3636
notify: Remount tmp
3737
loop: "{{ ansible_facts.mounts }}"
3838
loop_control:

tasks/section_1/cis_1.1.3.x.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
src: "{{ item.device }}"
3232
fstype: "{{ item.fstype }}"
3333
state: present
34-
opts: defaults,{% if rhel9cis_rule_1_1_3_2 %}nodev,{% endif %}{% if rhel9cis_rule_1_1_3_3 %}nosuid{% endif %}
34+
opts: "{{ item.options }}{% if ('nodev' not in item.options and rhel9cis_rule_1_1_3_2) %},nodev{% endif %}{% if ('nosuid' not in item.options and rhel9cis_rule_1_1_3_3) %},nosuid{% endif %}"
3535
loop: "{{ ansible_facts.mounts }}"
3636
loop_control:
3737
label: "{{ item.device }}"
@@ -45,6 +45,5 @@
4545
- level1-workstation
4646
- patch
4747
- mounts
48-
- skip_ansible_lint
4948
- rule_1.1.3.2
5049
- rule_1.1.3.3

tasks/section_1/cis_1.1.4.x.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
src: "{{ item.device }}"
3434
fstype: "{{ item.fstype }}"
3535
state: present
36-
opts: defaults,{% if rhel9cis_rule_1_1_4_2 %}noexec,{% endif %}{% if rhel9cis_rule_1_1_4_3 %}nosuid,{% endif %}{% if rhel9cis_rule_1_1_4_4 %}nodev{% endif %}
36+
opts: "{{ item.options }}{% if ('noexec' not in item.options and rhel9cis_rule_1_1_4_2) %},noexec{% endif %}{% if ('nosuid' not in item.options and rhel9cis_rule_1_1_4_3) %},nosuid{% endif %}{% if ('nodev' not in item.options and rhel9cis_rule_1_1_4_4) %},nodev{% endif %}"
3737
loop: "{{ ansible_facts.mounts }}"
3838
loop_control:
3939
label: "{{ item.device }}"
@@ -48,7 +48,6 @@
4848
- level1-workstation
4949
- patch
5050
- mounts
51-
- skip_ansible_lint
5251
- rule_1.1.4.2
5352
- rule_1.1.4.3
5453
- rule_1.1.4.4

tasks/section_1/cis_1.1.5.x.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
- audit
2323
- mounts
2424
- rule_1.1.5.1
25-
- skip_ansible_lint
2625

2726
- name: |
2827
"1.1.5.2 | PATCH | Ensure nodev option set on /var/log partition"
@@ -33,7 +32,7 @@
3332
src: "{{ item.device }}"
3433
fstype: "{{ item.fstype }}"
3534
state: present
36-
opts: defaults,{% if rhel9cis_rule_1_1_5_2 %}nodev,{% endif %}{% if rhel9cis_rule_1_1_5_3 %}noexec,{% endif %}{% if rhel9cis_rule_1_1_5_4 %}nosuid{% endif %}
35+
opts: "{{ item.options }}{% if ('nodev' not in item.options and rhel9cis_rule_1_1_5_2) %},nodev{% endif %}{% if ('noexec' not in item.options and rhel9cis_rule_1_1_5_3) %},noexec{% endif %}{% if ('nosuid' not in item.options and rhel9cis_rule_1_1_5_4) %},nosuid{% endif %}"
3736
loop: "{{ ansible_facts.mounts }}"
3837
loop_control:
3938
label: "{{ item.device }}"
@@ -48,7 +47,6 @@
4847
- level1-workstation
4948
- patch
5049
- mounts
51-
- skip_ansible_lint
5250
- rule_1.1.5.2
5351
- rule_1.1.5.3
5452
- rule_1.1.5.4

tasks/section_1/cis_1.1.6.x.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
src: "{{ item.device }}"
3333
fstype: "{{ item.fstype }}"
3434
state: present
35-
opts: defaults,{% if rhel9cis_rule_1_1_6_2 %}noexec,{% endif %}{% if rhel9cis_rule_1_1_6_3 %}nodev,{% endif %}{% if rhel9cis_rule_1_1_6_4 %}nosuid{% endif %}
35+
opts: "{{ item.options }}{% if ('noexec' not in item.options and rhel9cis_rule_1_1_6_2) %},noexec{% endif %}{% if ('nodev' not in item.options and rhel9cis_rule_1_1_6_3) %},nodev{% endif %}{% if ('nosuid' not in item.options and rhel9cis_rule_1_1_6_4) %},nosuid{% endif %}"
3636
loop: "{{ ansible_facts.mounts }}"
3737
loop_control:
3838
label: "{{ item.device }}"
@@ -47,7 +47,6 @@
4747
- level1-workstation
4848
- patch
4949
- mounts
50-
- skip_ansible_lint
5150
- rule_1.1.6.2
5251
- rule_1.1.6.3
5352
- rule_1.1.6.4

tasks/section_1/cis_1.1.7.x.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
- audit
2323
- mounts
2424
- rule_1.1.7.1
25-
- skip_ansible_lint
2625

2726
- name: |
2827
"1.1.7.2 | PATCH | Ensure nodev option set on /home partition
@@ -32,7 +31,7 @@
3231
src: "{{ item.device }}"
3332
fstype: "{{ item.fstype }}"
3433
state: present
35-
opts: defaults,{% if rhel9cis_rule_1_1_7_2 %}nodev,{% endif %}{% if rhel9cis_rule_1_1_7_3 %}nosuid{% endif %}
34+
opts: "{{ item.options }}{% if ('nodev' not in item.options and rhel9cis_rule_1_1_7_2) %},nodev{% endif %}{% if ('nosuid' not in item.options and rhel9cis_rule_1_1_7_3) %},nosuid{% endif %}"
3635
loop: "{{ ansible_facts.mounts }}"
3736
loop_control:
3837
label: "{{ item.device }}"
@@ -48,4 +47,3 @@
4847
- mounts
4948
- rule_1.1.7.2
5049
- rule_1.1.7.3
51-
- skip_ansible_lint

tasks/section_1/cis_1.1.8.x.yml

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
- audit
3030
- mounts
3131
- rule_1.1.8.1
32-
- skip_ansible_lint
3332

3433
- name: |
3534
"1.1.8.2 | PATCH | Ensure nodev option set on /dev/shm partition | Set nodev option

tasks/section_1/cis_1.2.x.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
- name: "1.2.2 | PATCH | Ensure gpgcheck is globally activated | Update yum.repos"
4545
ansible.builtin.replace:
4646
name: "{{ item.path }}"
47-
regexp: "^gpgcheck=0"
47+
regexp: ^gpgcheck\s*=\s*0
4848
replace: "gpgcheck=1"
4949
loop: "{{ yum_repos.files }}"
5050
loop_control:
@@ -85,7 +85,6 @@
8585
- manual
8686
- audit
8787
- rule_1.2.3
88-
- skip_ansible_lint
8988

9089
- name: "1.2.4 | AUDIT | Ensure repo_gpgcheck is globally activated"
9190
block:
@@ -104,7 +103,7 @@
104103
- name: "1.2.4 | PATCH | Ensure repo_gpgcheck is globally activated | amend repo files"
105104
ansible.builtin.replace:
106105
path: "{{ item.path }}"
107-
regexp: '^repo_gpgcheck( |)=( |)0'
106+
regexp: ^repo_gpgcheck\s*=\s*0
108107
replace: repo_gpgcheck=1
109108
loop: "{{ repo_files.files }}"
110109
loop_control:

tasks/section_1/cis_1.8.x.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
- name: "1.8.5 | PATCH | Ensure GDM screen locks cannot be overridden | Make lock file"
132132
ansible.builtin.template:
133133
src: etc/dconf/db/00-screensaver_lock.j2
134-
dest: "/etc/dconf/db/{{ rhel9cis_dconf_db_name }}.d/locks/00-screensaver"
134+
dest: "/etc/dconf/db/{{ rhel9cis_dconf_db_name }}.d/locks/00-screensaver_lock"
135135
owner: root
136136
group: root
137137
mode: '0644'

tasks/section_1/cis_1.9.yml

-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
notify: Change_requires_reboot
88
when:
99
- rhel9cis_rule_1_9
10-
- not system_is_ec2
1110
tags:
1211
- level1-server
1312
- level1-workstation
1413
- patch
1514
- rule_1.9
16-
- skip_ansible_lint

tasks/section_5/cis_5.6.x.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- item.id != "shutdown"
1414
- item.id != "halt"
1515
- item.id != "nfsnobody"
16+
- item.id not in rhel9cis_system_users_shell
1617
- item.uid < min_int_uid | int
1718
- item.shell != "/bin/false"
1819
- item.shell != "/usr/sbin/nologin"

tasks/section_6/cis_6.1.x.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164

165165
- name: "6.1.10 | AUDIT | Ensure no unowned files or directories exist | Flatten no_user_items results for easier use"
166166
ansible.builtin.set_fact:
167-
discovered_unowned_files_flatten: "{{ rhel_09_6_1_10_audit.results | map(attribute='stdout_lines') | flatten }}"
167+
discovered_unowned_files_flatten: "{{ rhel_09_6_1_10_audit.results | selectattr('stdout_lines', 'defined') | map(attribute='stdout_lines') | flatten }}"
168168

169169
- name: "6.1.10 | AUDIT | Ensure no unowned files or directories exist | Displaying any unowned files or directories"
170170
ansible.builtin.debug:
@@ -204,7 +204,7 @@
204204

205205
- name: "6.1.11 | AUDIT | Ensure no ungrouped files or directories exist | Flatten no_user_items results for easier use"
206206
ansible.builtin.set_fact:
207-
discovered_ungrouped_files_flatten: "{{ rhel_09_6_1_11_audit.results | map(attribute='stdout_lines') | flatten }}"
207+
discovered_ungrouped_files_flatten: "{{ rhel_09_6_1_11_audit.results | selectattr('stdout_lines', 'defined') | map(attribute='stdout_lines') | flatten }}"
208208

209209
- name: "6.1.11 | AUDIT | Ensure no ungrouped files or directories exist | Displaying all ungrouped files or directories"
210210
ansible.builtin.debug:

0 commit comments

Comments
 (0)