Skip to content

Commit 609dca5

Browse files
Merge pull request #134 from ansible-lockdown/Jan26_updates
Jan26 updates
2 parents 11a5255 + ddae237 commit 609dca5

File tree

5 files changed

+45
-22
lines changed

5 files changed

+45
-22
lines changed

.ansible-lint

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22

3-
parseable: true
43
quiet: true
54
skip_list:
65
- 'package-latest'

Changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
## Based on CIS v1.0.0
44

55
## based on benchmark CIS 1.0.0
6+
7+
### Jan26 updates
8+
pre-commit
9+
#92 readdressed thanks to @bizrad and @jbruno
10+
#127 addressed thanks to @rronneburger incl #84
11+
#129 addressed thanks to @stelucz
12+
#131 thanks to @Jurka007
13+
14+
### Dec26_updates
15+
616
precommit update Public issues address
717

818
4.2.5 ufw port variables and improvements to include ntp and protocol options

tasks/section_5/cis_5.4.1.x.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@
3333
- name: "5.4.1.1 | AUDIT | Ensure password expiration is configured | Add warning if ansible user found as break connection"
3434
when:
3535
- ubtu24cis_disruption_high
36-
- ansible_user in discovered_passwd_max_days.stdout
36+
- (ansible_user | default(ansible_env.USER)) in discovered_passwd_max_days.stdout
3737
ansible.builtin.debug:
3838
msg: "Warning!! Your ansible user found to be not compliant with maxdays - Manual intervention required"
3939

4040
- name: 5.4.1.1 | AUDIT | Ensure password expiration is configured | Warn count"
4141
when:
4242
- ubtu24cis_disruption_high
43-
- ansible_user in discovered_passwd_max_days.stdout
43+
- (ansible_user | default(ansible_env.USER)) in discovered_passwd_max_days.stdout
4444
ansible.builtin.import_tasks:
4545
file: warning_facts.yml
4646

4747
- name: "5.4.1.1 | PATCH | Ensure password expiration is configured | Set existing users PASS_MAX_DAYS"
4848
when:
4949
- ubtu24cis_disruption_high
50-
- item != (ansible_user)
50+
- item != (ansible_user | default(ansible_env.USER))
5151
ansible.builtin.command: "chage --maxdays {{ ubtu24cis_pass_max_days }} {{ item }}"
5252
failed_when: false
5353
changed_when: discovered_passwd_max_days.stdout | length > 0
@@ -81,21 +81,21 @@
8181
- name: "5.4.1.2 | AUDIT | Ensure minimum password age is configured | Add warning if ansible user found as break connection"
8282
when:
8383
- ubtu24cis_disruption_high
84-
- ansible_user in discovered_passwd_min_days.stdout
84+
- (ansible_user | default(ansible_env.USER)) in discovered_passwd_min_days.stdout
8585
ansible.builtin.debug:
8686
msg: "Warning!! Your ansible user found to be not compliant with mindays - Manual intervention required"
8787

8888
- name: "5.4.1.2 | AUDIT | Ensure minimum password age is configured | Warn count"
8989
when:
9090
- ubtu24cis_disruption_high
91-
- ansible_user in discovered_passwd_min_days.stdout
91+
- (ansible_user | default(ansible_env.USER)) in discovered_passwd_min_days.stdout
9292
ansible.builtin.import_tasks:
9393
file: warning_facts.yml
9494

9595
- name: "5.4.1.2 | PATCH | Ensure minimum password age is configured | Set existing users PASS_MIN_DAYS"
9696
when:
9797
- ubtu24cis_disruption_high
98-
- item != (ansible_user)
98+
- item != (ansible_user | default(ansible_env.USER))
9999
ansible.builtin.command: chage --mindays {{ ubtu24cis_pass_min_days }} {{ item }}
100100
failed_when: false
101101
changed_when: discovered_passwd_min_days.stdout | length > 0
@@ -128,7 +128,7 @@
128128
- name: "5.4.1.3 | PATCH | Ensure password expiration warning days is configured | Set existing users PASS_WARN_AGE"
129129
when:
130130
- ubtu24cis_disruption_high
131-
- item != (ansible_user)
131+
- item != (ansible_user | default(ansible_env.USER))
132132
ansible.builtin.command: chage --warndays {{ ubtu24cis_pass_warn_age }} {{ item }}
133133
failed_when: false
134134
changed_when: discovered_passwd_warn_days.stdout | length > 0

tasks/section_5/cis_5.4.3.x.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,33 @@
2727
- shell
2828
- rule_5.4.3.2
2929
- NIST800-53R5_NA
30-
ansible.builtin.blockinfile:
31-
path: "{{ item.path }}"
32-
state: "{{ item.state }}"
33-
marker: "# {mark} - CIS benchmark - Ansible-lockdown"
34-
create: true
35-
mode: 'go-wx'
36-
block: |
37-
TMOUT={{ ubtu24cis_shell_session_timeout }}
38-
readonly TMOUT
39-
export TMOUT
40-
loop:
41-
- { path: "{{ ubtu24cis_shell_session_file }}", state: present }
42-
- { path: /etc/profile, state: "{{ (ubtu24cis_shell_session_file == '/etc/profile') | ternary('present', 'absent') }}" }
30+
block:
31+
- name: "5.4.3.2 | AUDIT | Ensure default user shell timeout is configured | Get shell timeout files"
32+
ansible.builtin.stat:
33+
path: "{{ ubtu24cis_shell_session_file }}"
34+
register: discovered_shell_session_file
35+
36+
- name: "5.4.3.2 | AUDIT | Ensure default user shell timeout is configured | Remove shell timeout files"
37+
when: discovered_shell_session_file.stat.exists
38+
ansible.builtin.replace:
39+
path: "{{ ubtu24cis_shell_session_file }}"
40+
regexp: '# Logout Timeout\nexport TMOUT=0\nreadonly TMOUT\n'
41+
replace: '# Logout Timeout\n'
42+
43+
- name: "5.4.3.2 | PATCH | Ensure default user shell timeout is configured | Set shell timeout"
44+
ansible.builtin.blockinfile:
45+
path: "{{ item.path }}"
46+
state: "{{ item.state }}"
47+
marker: "# {mark} - CIS benchmark - Ansible-lockdown"
48+
create: true
49+
mode: 'u-x,go-wx'
50+
block: |
51+
TMOUT={{ ubtu24cis_shell_session_timeout }}
52+
readonly TMOUT
53+
export TMOUT
54+
loop:
55+
- { path: "{{ ubtu24cis_shell_session_file }}", state: present }
56+
- { path: /etc/profile, state: "{{ (ubtu24cis_shell_session_file == '/etc/profile') | ternary('present', 'absent') }}" }
4357

4458
- name: "5.4.3.3 | PATCH | Ensure default user umask is configured"
4559
when: ubtu24cis_rule_5_4_3_3

templates/ansible_vars_goss.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ ubtu24cis_desktop_required: {{ ubtu24cis_desktop_required }}
470470
## Section 1
471471

472472
# If system uses squashfs e.gf. snap package manager set true
473-
ubtu24cis_squashfs_skip:{% if prelim_squashfs_builtin.rc == 0 or prelim_snap_pkg_mgr.rc == 0 %} true{% else %} false{% endif %}
473+
ubtu24cis_squashfs_skip:{% if (prelim_squashfs_builtin.rc | default(1)) == 0 or (prelim_snap_pkg_mgr.rc | default(1)) == 0 %} true{% else %} false{% endif %}
474474

475475
## Controls 1.3.1.3 and 1.3.1.4 Ensure all AppArmor Profiles are in enforce (1.3.1.3/4) or complain (1.3.1.3) mode
476476

0 commit comments

Comments
 (0)