-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ansible remediation for sudo_remove_nopasswd.
Add test scenarios for sudo_remove_nopasswd.
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
linux_os/guide/system/software/sudo/sudo_remove_nopasswd/ansible/shared.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" |
6 changes: 6 additions & 0 deletions
6
linux_os/guide/system/software/sudo/sudo_remove_nopasswd/tests/correct_value.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
9 changes: 9 additions & 0 deletions
9
linux_os/guide/system/software/sudo/sudo_remove_nopasswd/tests/wrong_value.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |