Skip to content

Commit 98e6419

Browse files
authored
Merge pull request #214 from ansible-lockdown/devel
New release
2 parents 583e16f + f80e871 commit 98e6419

29 files changed

Lines changed: 275 additions & 86 deletions

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ repos:
3636
args: [ '--baseline', '.config/.secrets.baseline' ]
3737

3838
- repo: https://github.com/gitleaks/gitleaks
39-
rev: v8.18.1
39+
rev: v8.18.2
4040
hooks:
4141
- id: gitleaks
4242
args: ['--baseline-path', '.config/.gitleaks-report.json']
4343

4444
- repo: https://github.com/ansible-community/ansible-lint
45-
rev: v6.22.0
45+
rev: v24.2.0
4646
hooks:
4747
- id: ansible-lint
4848
name: Ansible-lint
@@ -61,6 +61,6 @@ repos:
6161
- ansible-core>=2.10.1
6262

6363
- repo: https://github.com/adrienverge/yamllint.git
64-
rev: v1.33.0 # or higher tag
64+
rev: v1.35.1 # or higher tag
6565
hooks:
6666
- id: yamllint

Changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
## Based on CIS V1.0.0
44

5+
### 1.0.9
6+
7+
- updated audit command to allow multiple groups from inventory
8+
- #144 usb-blacklisting - thanks to @paulquevedojdrf
9+
- #152 and #170 Added ssh validate to tasks - thanks to @dderemiah and @twadelij
10+
- #180 and #181 password reuse 5.3.4 - thanks to @DianaMariaDDM
11+
- #182 pwquality enhancement New variable to allow extended or minclass (default)options - thanks to @ma3s7ro
12+
- #184 Initial container config feedback required - thanks to @ipruteanu-sie
13+
- #204 reboot not idempotent - changed auditd and reboot logic update to 4.1.3.6 discovery - thanks to @bhuddah
14+
515
### 1.0.8
616

717
- updated goss binary to 0.4.4

defaults/main.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ubtu22cis_ask_passwd_to_boot: false
4040
# is executed on a container image and sets the variable
4141
# system_is_container the true. Otherwise, the default value
4242
# 'false' is left unchanged.
43-
system_is_container: false
43+
container_vars_file: is_container.yml
4444

4545
## Root user used
4646
# Root by default is not used unless setup by user
@@ -543,8 +543,10 @@ ubtu22cis_config_aide: true
543543
## When Initializing aide this can take longer on some systems
544544
# changing the values enables user to change to thier own requirements
545545
ubtu22cis_aide_init:
546-
async: 45 # Maximum Time in seconds
547-
poll: 0 # Polling Interval in seconds
546+
# Maximum Time in seconds
547+
async: 45
548+
# Polling Interval in seconds
549+
poll: 0
548550

549551
## Control 1.3.2
550552
# These are the crontab settings for periodical checking of the filesystem's integrity using AIDE.
@@ -597,7 +599,7 @@ ubtu22cis_set_boot_pass: false
597599

598600
ubtu22cis_grub_file: /boot/grub/grub.cfg
599601

600-
## 1.5.x
602+
## Controls 1.5.x
601603
# Ability to set file in which the kernel systcl changes are placed
602604
ubtu22cis_sysctl_kernel_conf: /etc/sysctl.d/98_cis_kernel.conf
603605

@@ -748,7 +750,7 @@ ubtu22cis_audit_back_log_limit: 8192
748750
# This should be set based on your sites policy. CIS does not provide a specific value.
749751
ubtu22cis_max_log_file_size: 10
750752

751-
## 4.1.3.x - Audit template
753+
## Controls 4.1.3.x - Audit template
752754
# This variable is set to true by tasks 4.1.3.1 to 4.1.3.20. As a result, the
753755
# audit settings are overwritten with the role's template. In order to exclude
754756
# specific rules, you must set the variable of form `ubtu22cis_rule_4_1_3_x` above
@@ -938,13 +940,33 @@ ubtu22cis_sudo_timestamp_timeout: 15
938940
# CIS requires that such a group be created (named according to site policy) and be kept empty.
939941
ubtu22cis_sugroup: nosugroup
940942

943+
## Control 5.4.1
944+
# This variable allows us to use either
945+
#
946+
947+
ubtu22cis_pwquality_minclass: true
948+
ubtu22cis_pwquality_minclass_value: '4'
949+
ubtu22cis_pwquality:
950+
- key: '#minclass'
951+
value: "{{ ubtu22cis_pwquality_minclass_value }}"
952+
- key: 'minlen'
953+
value: '14'
954+
- key: 'dcredit'
955+
value: '-1'
956+
- key: 'ucredit'
957+
value: '-1'
958+
- key: 'ocredit'
959+
value: '-1'
960+
- key: 'lcredit'
961+
value: '-1'
962+
941963
## Control 5.4.3
942964
# This variable represents the number of password change cycles, after which
943965
# a user can re-use a password.
944966
# CIS requires a value of 5 or more.
945967
ubtu22cis_pamd_pwhistory_remember: 5
946968

947-
# Control 5.4.2
969+
## Control 5.4.2
948970
# This can seriously break access to a system
949971
## The end state the file /etc/pam.d/common-auth need to be understood
950972
## If using external auth providers this will be very different
@@ -955,7 +977,7 @@ ubtu22cis_rule_5_4_2_faillock_config: |
955977
auth [default=die] pam_faillock.so authfail
956978
auth sufficient pam_faillock.so authsucc
957979
958-
# Control 5.4.4
980+
## Control 5.4.4
959981
# ubtu22cis_passwd_hash_algo is the hashing algorithm used
960982
ubtu22cis_passwd_hash_algo: yescrypt # pragma: allowlist secret
961983
# Set pam as well as login defs if PAM is required

handlers/main.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
22

3+
- name: Update_Initramfs
4+
ansible.builtin.shell: update-initramfs -u
5+
notify: change_requires_reboot
6+
37
- name: Remount tmp
48
ansible.posix.mount:
59
path: /tmp
@@ -39,6 +43,7 @@
3943
- name: Grub update
4044
ansible.builtin.shell: update-grub
4145
failed_when: false
46+
notify: change_requires_reboot
4247

4348
- name: Restart timeservice
4449
ansible.builtin.systemd:
@@ -110,31 +115,21 @@
110115
when:
111116
- '"No change" not in ubtu22cis_rule_4_1_3_21_augen_check.stdout'
112117

113-
- name: Auditd_immutable_check
114-
ansible.builtin.shell: grep -c "^-e 2" /etc/audit/rules.d/99_auditd.rules
115-
changed_when: false
116-
register: auditd_immutable_check
117-
118118
- name: Audit_immutable_fact
119119
ansible.builtin.debug:
120120
msg: "Reboot required for auditd to apply new rules as immutable set"
121121
notify: change_requires_reboot
122122
when:
123-
- auditd_immutable_check.stdout == '1'
123+
- audit_rules_updated.changed
124+
- auditd_immutable_check is defined
124125

125126
- name: Restart auditd
126127
ansible.builtin.shell: service auditd restart
127128
when:
128-
- audit_rules_updated.changed or
129-
rule_4_1_2_1.changed or
130-
rule_4_1_2_2.changed or
131-
rule_4_1_2_3.changed
129+
- audit_rules_updated is defined
132130
tags:
133131
- skip_ansible_lint
134132

135-
- name: remount tmp
136-
ansible.builtin.shell: mount -o remount /tmp
137-
138133
- name: restart sshd
139134
ansible.builtin.systemd:
140135
name: sshd

tasks/LE_audit_setup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- name: Pre Audit Setup | Set audit package name | ARM64
1111
ansible.builtin.set_fact:
1212
audit_pkg_arch_name: ARM64
13-
when: ansible_facts.machine == "arm64"
13+
when: ansible_facts.machine == "aarch64"
1414

1515
- name: Pre Audit Setup | Download audit binary
1616
ansible.builtin.get_url:

tasks/auditd.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
dest: /etc/audit/rules.d/99_auditd.rules
77
owner: root
88
group: root
9-
mode: '0600'
9+
mode: '0640'
1010
register: audit_rules_updated
1111
notify:
1212
- Auditd rules reload
13-
- Auditd_immutable_check
1413
- Audit_immutable_fact
1514
- Restart auditd
15+
- change_requires_reboot
1616
when: update_audit_template
1717

1818
- name: POST | Set up auditd user logging exceptions
@@ -25,19 +25,3 @@
2525
notify: Restart auditd
2626
when:
2727
- ubtu22cis_allow_auditd_uid_user_exclusions
28-
29-
# - name: "POST | AUDITD | Discover if auditd immutable - Set reboot required if auditd immutable"
30-
# block:
31-
# - name: "POST | AUDITD | Discover if auditd immutable - Set reboot required if auditd immutable | Get status"
32-
# ansible.builtin.shell: grep -c "^-e 2" /etc/audit/rules.d/99_auditd.rules
33-
# changed_when: false
34-
# failed_when: false
35-
# register: ubtu22cis_auditd_immutable_check
36-
37-
# - name: "POST | AUDITD | Discover if auditd immutable - Set reboot required if auditd immutable | Set reboot required"
38-
# ansible.builtin.debug:
39-
# msg: "Reboot required for auditd to apply new rules as immutable set"
40-
# notify: change_requires_reboot
41-
# when: ubtu22cis_auditd_immutable_check.stdout == '1'
42-
# when:
43-
# - ubtu22cis_audit_rules_update.changed

tasks/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,15 @@
208208
ansible.builtin.reboot:
209209
when:
210210
- not skip_reboot
211+
- change_requires_reboot
211212

212213
- name: Warning a reboot required but skip option set
213214
ansible.builtin.debug:
214215
msg: "Warning!! changes have been made that require a reboot to be implemented but skip reboot was set - Can affect compliance check results"
215216
changed_when: true
216217
when:
217218
- skip_reboot
219+
- change_requires_reboot
218220

219221
- name: Run post remediation audit
220222
ansible.builtin.import_tasks:

tasks/post_remediation_audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22

33
- name: Post Audit | Run post_remediation {{ benchmark }} audit
4-
ansible.builtin.shell: "{{ audit_conf_dir }}/run_audit.sh -v {{ audit_vars_path }} -o {{ post_audit_outfile }} -g {{ group_names }}"
4+
ansible.builtin.shell: "{{ audit_conf_dir }}/run_audit.sh -v {{ audit_vars_path }} -o {{ post_audit_outfile }} -g \"{{ group_names }}\""
55
changed_when: true
66
environment:
77
AUDIT_BIN: "{{ audit_bin }}"

tasks/pre_remediation_audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
mode: '0600'
7878

7979
- name: Pre Audit | Run pre_remediation {{ benchmark }} audit
80-
ansible.builtin.shell: "{{ audit_conf_dir }}/run_audit.sh -v {{ audit_vars_path }} -o {{ pre_audit_outfile }} -g {{ group_names }}"
80+
ansible.builtin.shell: "{{ audit_conf_dir }}/run_audit.sh -v {{ audit_vars_path }} -o {{ pre_audit_outfile }} -g \"{{ group_names }}\""
8181
changed_when: true
8282
environment:
8383
AUDIT_BIN: "{{ audit_bin }}"

tasks/prelim.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,16 @@
133133
- auditd
134134
- always
135135

136-
- name: "PRELIM | 5.3.4 | Find all sudoers files."
136+
- name: "PRELIM | Check if auditd is immutable before changes"
137+
ansible.builtin.shell: auditctl -l | grep -c '-e 2'
138+
changed_when: false
139+
failed_when: auditd_immutable_check.rc not in [ 0, 1 ]
140+
register: auditd_immutable_check
141+
when: "'auditd' in ansible_facts.packages"
142+
tags:
143+
- always
144+
145+
- name: "PRELIM | 5.3.4 | 5.3.5 | Find all sudoers files."
137146
ansible.builtin.shell: "find /etc/sudoers /etc/sudoers.d/ -type f ! -name '*~' ! -name '*.*'"
138147
changed_when: false
139148
failed_when: false
@@ -177,6 +186,12 @@
177186
grep -E -v '^(root|halt|sync|shutdown)' /etc/passwd | awk -F: '(!index($7, "sbin/nologin") && $7 != "/bin/false") { print $6 }'
178187
changed_when: false
179188
register: interactive_users_home
189+
when:
190+
- ubtu22cis_rule_6_2_11 or
191+
ubtu22cis_rule_6_2_13 or
192+
ubtu22cis_rule_6_2_14 or
193+
ubtu22cis_rule_6_2_15 or
194+
ubtu22cis_rule_6_2_16
180195
tags:
181196
- always
182197

@@ -207,16 +222,6 @@
207222
changed_when: false
208223
check_mode: false
209224
register: ubtu22cis_users
210-
when:
211-
- ubtu22cis_rule_6_2_14 or
212-
ubtu22cis_rule_6_2_15 or
213-
ubtu22cis_rule_6_2_16
214-
tags:
215-
- always
216-
217-
- name: "PRELIM | Recapture packages"
218-
ansible.builtin.package_facts:
219-
manager: auto
220225
tags:
221226
- always
222227

0 commit comments

Comments
 (0)