Skip to content

Commit 1adc7bd

Browse files
Merge pull request #326 from ansible-lockdown/pub_Jan26
Jan26 updates
2 parents d97c226 + c1ee5d1 commit 1adc7bd

5 files changed

Lines changed: 28 additions & 10 deletions

File tree

.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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
### Do not migrate
66

7+
# Jan26
8+
pre-commits
9+
#325 nopasswd for sudoers options added
10+
chrony template tidied up
11+
712
# Dec 25 update
813
pre-commits
914

defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,12 @@ ubtu22cis_sshd_deny_groups: ""
909909
# CIS recommends `sudo` or, if LDAP functionality is required, `sudo-ldap`.
910910
ubtu22cis_sudo_package: "sudo"
911911

912+
## control 5.2.4 sudoers NOPASSWD
913+
# This will leave NOPASSWD intact for these users
914+
ubtu22cis_sudoers_exclude_nopasswd_list:
915+
- ec2-user
916+
- vagrant
917+
912918
## Control 5.2.3
913919
# This variable defines the path and file name of the sudo log file.
914920
ubtu22cis_sudo_logfile: "/var/log/sudo.log"

tasks/section_5/cis_5.2.x.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,22 @@
5353
- sudo
5454
- rule_5.2.4
5555
- NIST800-53R5_AC-6
56-
ansible.builtin.replace:
57-
path: "{{ item }}"
58-
regexp: '^([^#|{% if system_is_ec2 %}ec2-user{% endif %}].*)NOPASSWD(.*)'
59-
replace: '\1PASSWD\2'
60-
validate: '/usr/sbin/visudo -cf %s'
61-
loop: "{{ prelim_sudoers_files.stdout_lines }}"
56+
block:
57+
- name: "5.2.4 | AUDIT | Ensure users must provide password for escalation | discover accts with NOPASSWD"
58+
ansible.builtin.shell: grep -Ei '(nopasswd)' /etc/sudoers /etc/sudoers.d/* | cut -d':' -f1
59+
become: true
60+
changed_when: false
61+
failed_when: false
62+
register: discovered_sudoers_nopasswd
63+
64+
- name: "5.2.4 | PATCH | Ensure users must provide password for escalation"
65+
when: discovered_sudoers_nopasswd.stdout | length > 0
66+
ansible.builtin.replace:
67+
path: "{{ item }}"
68+
regexp: '^((?!#|{% for name in ubtu22cis_sudoers_exclude_nopasswd_list %}{{ name }}{% if not loop.last -%}|{%- endif -%}{% endfor %}).*)NOPASSWD(.*)'
69+
replace: '\1PASSWD\2'
70+
validate: '/usr/sbin/visudo -cf %s'
71+
loop: "{{ discovered_sudoers_nopasswd.stdout_lines }}"
6272

6373
- name: "5.2.5 | PATCH | Ensure re-authentication for privilege escalation is not disabled globally"
6474
when: ubtu22cis_rule_5_2_5

templates/chrony.conf.j2

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Welcome to the chrony configuration file. See chrony.conf(5) for more
2-
# information about usuable directives.
2+
# information about useable directives.
33

44
# This will use (up to):
55
# - 4 sources from ntp.ubuntu.com which some are ipv6 enabled
@@ -89,5 +89,3 @@ logchange 0.5
8989
# chrony postinst based on what it found in /etc/default/rcS. You may
9090
# change it if necessary.
9191
rtconutc
92-
93-
user {{ ubtu22cis_chrony_user }}

0 commit comments

Comments
 (0)