Skip to content

Commit

Permalink
Add ansible remediation for sudo_remove_nopasswd.
Browse files Browse the repository at this point in the history
Add test scenarios for sudo_remove_nopasswd.
  • Loading branch information
ggbecker committed Sep 7, 2020
1 parent 1ed9c05 commit a92bd92
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# platform = multi_platform_all
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low

- name: Find /etc/sudoers.d/ files
find:
paths:
- /etc/sudoers.d/
register: sudoers

- name: "Remove lines containing NOPASSWD from sudoers files"
lineinfile:
regexp: '^(?!#).*[\s]+NOPASSWD[\s]*\:.*$'
state: absent
path: "{{ item.path }}"
validate: /usr/sbin/visudo -cf %s
with_items:
- { path: /etc/sudoers }
- "{{ sudoers.files }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# profiles = xccdf_org.ssgproject.content_profile_stig

rm -f /etc/sudoers
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers
chmod 440 /etc/sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# profiles = xccdf_org.ssgproject.content_profile_stig

echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
chmod 440 /etc/sudoers

mkdir /etc/sudoers.d/
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/sudoers
chmod 440 /etc/sudoers.d/sudoers

0 comments on commit a92bd92

Please sign in to comment.