Skip to content

Commit

Permalink
Restore regex test
Browse files Browse the repository at this point in the history
Also: really bad to create backup files in the sudoers directory
  • Loading branch information
ferricoxide committed Jul 2, 2024
1 parent 3788cf4 commit e0b2102
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ notify_{{ stig_id }}-skipSet:
Handler for {{ stig_id }} has been selected for skip.
{%- else %}
{%- for sudoer in sudoerFiles %}
{%- if sudoer != "/etc/sudoers.d/90-cloud-init-users" and
sudoer != "/etc/sudoers.d/ssm-agent-users" %}
{%- if (
sudoer != "/etc/sudoers.d/90-cloud-init-users" and
sudoer != "/etc/sudoers.d/ssm-agent-users"
) and
salt.file.search(sudoer, '^[a-zA-Z%@].*NOPASSWD') %}
Nuke NOPASSWD from sudoers ({{ stig_id }}) - {{ sudoer }}:
file.replace:
- name: '{{ sudoer }}'
- backup: False
- pattern: '^([a-zA-Z0-9_-][a-zA-Z0-9._-]*)(\s\s*.*)(NOPASSWD:[A-Za-z/_-]*)'
- repl: '# Set per STIG-ID {{ stig_id }}\n\1\2'
{%- elif (
Expand Down

0 comments on commit e0b2102

Please sign in to comment.