mirror of
https://github.com/ansible-lockdown/RHEL9-CIS.git
synced 2025-12-27 23:43:06 +00:00
Merge 'devel' of kris9854/RHEL9-CIS-fix into devel
This commit is contained in:
commit
d4471a3016
65 changed files with 801 additions and 461 deletions
|
|
@ -5,23 +5,31 @@
|
|||
- name: "6.1.1 | AUDIT | Audit system file permissions | Audit the packages"
|
||||
shell: rpm -Va --nomtime --nosize --nomd5 --nolinkto
|
||||
args:
|
||||
warn: no
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_6_1_1_packages_rpm
|
||||
|
||||
- name: "6.1.1 | AUDIT | Audit system file permissions | Create list and warning"
|
||||
block:
|
||||
- name: "6.1.1 | Audit system file permissions | Add file discrepancy list to system"
|
||||
- name: "6.1.1 | AUDIT | Audit system file permissions | Add file discrepancy list to system"
|
||||
copy:
|
||||
dest: "{{ rhel9cis_rpm_audit_file }}"
|
||||
content: "{{ rhel9cis_6_1_1_packages_rpm.stdout }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0640
|
||||
|
||||
- name: "6.1.1 | AUDIT | Audit system file permissions | Message out alert for package descrepancies"
|
||||
debug:
|
||||
msg: |
|
||||
"Warning! You have some package descrepancies issues.
|
||||
"Warning!! You have some package descrepancies issues.
|
||||
The file list can be found in {{ rhel9cis_rpm_audit_file }}"
|
||||
|
||||
- name: "6.1.1 | AUDIT | Audit system file permissions | warning count"
|
||||
set_fact:
|
||||
control_number: "{{ control_number }} + [ 'rule_6.1.1' ]"
|
||||
warn_count: "{{ warn_count | int + 1 }}"
|
||||
when: rhel9cis_6_1_1_packages_rpm.stdout|length > 0
|
||||
|
||||
- name: "6.1.1 | AUDIT | Audit system file permissions | Message out no package descrepancies"
|
||||
|
|
@ -41,7 +49,7 @@
|
|||
- name: "6.1.2 | PATCH | Ensure sticky bit is set on all world-writable directories"
|
||||
shell: df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type d -perm -0002 2>/dev/null | xargs chmod a+t
|
||||
args:
|
||||
warn: no
|
||||
warn: false
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when:
|
||||
|
|
|
|||
|
|
@ -33,8 +33,14 @@
|
|||
|
||||
- name: "6.2.2 | AUDIT | Ensure all groups in /etc/passwd exist in /etc/group | Print warning about users with invalid GIDs missing GID entries in /etc/group"
|
||||
debug:
|
||||
msg: "Warning! The following users have non-existent GIDs (Groups): {{ rhel9cis_6_2_2_passwd_gid_check.stdout_lines | join (', ') }}"
|
||||
when: rhel9cis_6_2_2_passwd_gid_check.stdout | length > 0
|
||||
msg: "Warning!! The following users have non-existent GIDs (Groups): {{ rhel9cis_6_2_2_passwd_gid_check.stdout_lines | join (', ') }}"
|
||||
when: rhel9cis_6_2_2_passwd_gid_check.stdout | length >= 1
|
||||
|
||||
- name: "6.2.2 | AUDIT | Ensure all groups in /etc/passwd exist in /etc/group | warning count"
|
||||
set_fact:
|
||||
control_number: "{{ control_number }} + [ 'rule_6.2.2' ]"
|
||||
warn_count: "{{ warn_count | int + 1 }}"
|
||||
when: rhel9cis_6_2_2_passwd_gid_check.stdout | length >= 1
|
||||
when:
|
||||
- rhel9cis_rule_6_2_2
|
||||
tags:
|
||||
|
|
@ -61,8 +67,14 @@
|
|||
|
||||
- name: "6.2.3 | AUDIT| Ensure no duplicate UIDs exist | Print warning about users with duplicate UIDs"
|
||||
debug:
|
||||
msg: "Warning! The following users have UIDs that are duplicates: {{ rhel9cis_6_2_3_user_uid_check.stdout_lines }}"
|
||||
when: rhel9cis_6_2_3_user_uid_check.stdout | length > 0
|
||||
msg: "Warning!! The following users have UIDs that are duplicates: {{ rhel9cis_6_2_3_user_uid_check.stdout_lines }}"
|
||||
when: rhel9cis_6_2_3_user_uid_check.stdout | length >= 1
|
||||
|
||||
- name: "6.2.3 | AUDIT| Ensure no duplicate UIDs exist | warning count"
|
||||
set_fact:
|
||||
control_number: "{{ control_number }} + [ 'rule_6.2.3' ]"
|
||||
warn_count: "{{ warn_count | int + 1 }}"
|
||||
when: rhel9cis_6_2_3_user_uid_check.stdout | length >= 1
|
||||
when:
|
||||
- rhel9cis_rule_6_2_3
|
||||
tags:
|
||||
|
|
@ -89,8 +101,15 @@
|
|||
|
||||
- name: "6.2.4 | AUDIT | Ensure no duplicate GIDs exist | Print warning about users with duplicate GIDs"
|
||||
debug:
|
||||
msg: "Warning! The following groups have duplicate GIDs: {{ rhel9cis_6_2_4_user_user_check.stdout_lines }}"
|
||||
when: rhel9cis_6_2_4_user_user_check.stdout | length > 0
|
||||
msg: "Warning!! The following groups have duplicate GIDs: {{ rhel9cis_6_2_4_user_user_check.stdout_lines }}"
|
||||
when: rhel9cis_6_2_4_user_user_check.stdout | length >= 1
|
||||
|
||||
- name: "6.2.4 | AUDIT | Ensure no duplicate GIDs exist | warning count"
|
||||
set_fact:
|
||||
control_number: "{{ control_number }} + [ 'rule_6.2.4' ]"
|
||||
warn_count: "{{ warn_count | int + 1 }}"
|
||||
when: rhel9cis_6_2_4_user_user_check.stdout | length >= 1
|
||||
|
||||
when:
|
||||
- rhel9cis_rule_6_2_4
|
||||
tags:
|
||||
|
|
@ -117,8 +136,14 @@
|
|||
|
||||
- name: "6.2.5 | AUDIT | Ensure no duplicate user names exist | Print warning about users with duplicate User Names"
|
||||
debug:
|
||||
msg: "Warning! The following user names are duplicates: {{ rhel9cis_6_2_5_user_username_check.stdout_lines }}"
|
||||
when: rhel9cis_6_2_5_user_username_check.stdout | length > 0
|
||||
msg: "Warning!! The following user names are duplicates: {{ rhel9cis_6_2_5_user_username_check.stdout_lines }}"
|
||||
when: rhel9cis_6_2_5_user_username_check.stdout | length >= 1
|
||||
|
||||
- name: "6.2.5 | AUDIT | Ensure no duplicate user names exist | warning count"
|
||||
set_fact:
|
||||
control_number: "{{ control_number }} + [ 'rule_6.2.5' ]"
|
||||
warn_count: "{{ warn_count | int + 1 }}"
|
||||
when: rhel9cis_6_2_5_user_username_check.stdout | length >= 1
|
||||
when:
|
||||
- rhel9cis_rule_6_2_5
|
||||
tags:
|
||||
|
|
@ -136,18 +161,24 @@
|
|||
shell: 'getent passwd | cut -d: -f1 | sort -n | uniq -d'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: no
|
||||
check_mode: false
|
||||
register: rhel9cis_6_2_6_group_group_check
|
||||
|
||||
- name: "6.2.6 | AUDIT | Ensure no duplicate group names exist | Print message that no duplicate groups exist"
|
||||
debug:
|
||||
msg: "Good News! There are no duplicate group names in the system"
|
||||
when: rhel9cis_6_2_6_group_group_check.stdout | length == 0
|
||||
when: rhel9cis_6_2_6_group_group_check.stdout is defined
|
||||
|
||||
- name: "6.2.6 | AUDIT | Ensure no duplicate group names exist | Print warning about users with duplicate group names"
|
||||
debug:
|
||||
msg: "Warning! The following group names are duplicates: {{ rhel9cis_6_2_6_group_group_check.stdout_lines }}"
|
||||
when: rhel9cis_6_2_6_group_group_check.stdout | length > 0
|
||||
msg: "Warning!! The following group names are duplicates: {{ rhel9cis_6_2_6_group_group_check.stdout_lines }}"
|
||||
when: rhel9cis_6_2_6_group_group_check.stdout is not defined
|
||||
|
||||
- name: "6.2.6 | AUDIT | Ensure no duplicate group names exist | warning count"
|
||||
set_fact:
|
||||
control_number: "{{ control_number }} + [ 'rule_6.2.6' ]"
|
||||
warn_count: "{{ warn_count | int + 1 }}"
|
||||
when: rhel9cis_6_2_6_group_group_check.stdout is not defined
|
||||
when:
|
||||
- rhel9cis_rule_6_2_6
|
||||
tags:
|
||||
|
|
@ -163,23 +194,23 @@
|
|||
block:
|
||||
- name: "6.2.7 | AUDIT | Ensure root PATH Integrity | Determine empty value"
|
||||
shell: 'echo $PATH | grep ::'
|
||||
changed_when: False
|
||||
changed_when: false
|
||||
failed_when: rhel9cis_6_2_7_path_colon.rc == 0
|
||||
check_mode: no
|
||||
check_mode: false
|
||||
register: rhel9cis_6_2_7_path_colon
|
||||
|
||||
- name: "6.2.7 | AUDIT | Ensure root PATH Integrity | Determin colon end"
|
||||
shell: 'echo $PATH | grep :$'
|
||||
changed_when: False
|
||||
changed_when: false
|
||||
failed_when: rhel9cis_6_2_7_path_colon_end.rc == 0
|
||||
check_mode: no
|
||||
check_mode: false
|
||||
register: rhel9cis_6_2_7_path_colon_end
|
||||
|
||||
- name: "6.2.7 | AUDIT | Ensure root PATH Integrity | Determine dot in path"
|
||||
shell: "/bin/bash --login -c 'env | grep ^PATH=' | sed -e 's/PATH=//' -e 's/::/:/' -e 's/:$//' -e 's/:/\\n/g'"
|
||||
changed_when: False
|
||||
changed_when: false
|
||||
failed_when: '"." in rhel9cis_6_2_7_dot_in_path.stdout_lines'
|
||||
check_mode: no
|
||||
check_mode: false
|
||||
register: rhel9cis_6_2_7_dot_in_path
|
||||
|
||||
- name: "6.2.7 | AUDIT | Ensure root PATH Integrity | Alert on empty value, colon end, and dot in path"
|
||||
|
|
@ -230,7 +261,7 @@
|
|||
stat:
|
||||
path: "{{ item }}"
|
||||
register: rhel_08_6_2_9_audit
|
||||
with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid | int ) | selectattr('uid', '<', max_int_uid | int ) | map(attribute='dir') | list }}"
|
||||
with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid | int ) | selectattr('uid', '<=', max_int_uid | int ) | map(attribute='dir') | list }}"
|
||||
|
||||
- name: "6.2.9 | AUDIT | Ensure all users' home directories exist"
|
||||
command: find -H {{ item.0 | quote }} -not -type l -perm /027
|
||||
|
|
@ -249,7 +280,7 @@
|
|||
- name: "6.2.9 | PATCH | Ensure all users' home directories exist"
|
||||
file:
|
||||
path: "{{ item.0 }}"
|
||||
recurse: yes
|
||||
recurse: true
|
||||
mode: a-st,g-w,o-rwx
|
||||
register: rhel_08_6_2_9_patch
|
||||
when:
|
||||
|
|
@ -265,12 +296,13 @@
|
|||
- name: "6.2.9 | PATCH | Ensure all users' home directories exist"
|
||||
acl:
|
||||
path: "{{ item.0 }}"
|
||||
default: yes
|
||||
default: true
|
||||
state: present
|
||||
recursive: yes
|
||||
recursive: true
|
||||
etype: "{{ item.1.etype }}"
|
||||
permissions: "{{ item.1.mode }}"
|
||||
when: not system_is_container
|
||||
when:
|
||||
- not system_is_container
|
||||
with_nested:
|
||||
- "{{ (ansible_check_mode | ternary(rhel_08_6_2_9_patch_audit, rhel_08_6_2_9_patch)).results |
|
||||
rejectattr('skipped', 'defined') | map(attribute='item') | map('first') | list }}"
|
||||
|
|
@ -299,7 +331,8 @@
|
|||
loop_control:
|
||||
label: "{{ rhel9cis_passwd_label }}"
|
||||
when:
|
||||
- min_int_uid | int <= item.uid
|
||||
- item.uid >= min_int_uid | int
|
||||
- item.id != 'nobody'
|
||||
- rhel9cis_rule_6_2_10
|
||||
- item.id != 'nobody'
|
||||
- (item.id != 'tss' and item.dir != '/dev/null')
|
||||
|
|
@ -317,7 +350,7 @@
|
|||
- name: "6.2.11 | AUDIT | Ensure users' home directories permissions are 750 or more restrictive"
|
||||
stat:
|
||||
path: "{{ item }}"
|
||||
with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid | int ) | selectattr('uid', '<', max_int_uid | int ) | map(attribute='dir') | list }}"
|
||||
with_items: "{{ rhel9cis_passwd | selectattr('uid', '>=', min_int_uid | int) | selectattr('uid', '<=', max_int_uid | int) | map(attribute='dir') | list }}"
|
||||
register: rhel_08_6_2_11_audit
|
||||
|
||||
- name: "6.2.11 | AUDIT | Ensure users' home directories permissions are 750 or more restrictive"
|
||||
|
|
@ -337,7 +370,7 @@
|
|||
- name: "6.2.11 | PATCH | Ensure users' home directories permissions are 750 or more restrictive"
|
||||
file:
|
||||
path: "{{ item.0 }}"
|
||||
recurse: yes
|
||||
recurse: true
|
||||
mode: a-st,g-w,o-rwx
|
||||
register: rhel_08_6_2_11_patch
|
||||
when:
|
||||
|
|
@ -353,12 +386,13 @@
|
|||
- name: "6.2.11 | PATCH | Ensure users' home directories permissions are 750 or more restrictive"
|
||||
acl:
|
||||
path: "{{ item.0 }}"
|
||||
default: yes
|
||||
default: true
|
||||
state: present
|
||||
recursive: yes
|
||||
recursive: true
|
||||
etype: "{{ item.1.etype }}"
|
||||
permissions: "{{ item.1.mode }}"
|
||||
when: not system_is_container
|
||||
when:
|
||||
- not system_is_container
|
||||
with_nested:
|
||||
- "{{ (ansible_check_mode | ternary(rhel_08_6_2_11_patch_audit, rhel_08_6_2_11_patch)).results |
|
||||
rejectattr('skipped', 'defined') | map(attribute='item') | map('first') | list }}"
|
||||
|
|
@ -429,8 +463,8 @@
|
|||
|
||||
- name: "6.2.14 | PATCH | Ensure no users have .forward files"
|
||||
file:
|
||||
path: "~{{ item }}/.forward"
|
||||
state: absent
|
||||
dest: "~{{ item }}/.forward"
|
||||
with_items:
|
||||
- "{{ users.stdout_lines }}"
|
||||
when:
|
||||
|
|
@ -446,8 +480,8 @@
|
|||
|
||||
- name: "6.2.15 | PATCH | Ensure no users have .netrc files"
|
||||
file:
|
||||
path: "~{{ item }}/.netrc"
|
||||
state: absent
|
||||
dest: "~{{ item }}/.netrc"
|
||||
with_items:
|
||||
- "{{ users.stdout_lines }}"
|
||||
when:
|
||||
|
|
@ -463,8 +497,8 @@
|
|||
|
||||
- name: "6.2.16 | PATCH | Ensure no users have .rhosts files"
|
||||
file:
|
||||
path: "~{{ item }}/.rhosts"
|
||||
state: absent
|
||||
dest: "~{{ item }}/.rhosts"
|
||||
with_items: "{{ users.stdout_lines }}"
|
||||
when:
|
||||
- rhel9cis_rule_6_2_16
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue