-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple issues with CIS 4.3.x sudo #118
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ | |
- name: "4.3.2 | PATCH | Ensure sudo commands use pty" | ||
ansible.builtin.lineinfile: | ||
path: /etc/sudoers | ||
regexp: '^Defaults use_' | ||
line: 'Defaults use_pty' | ||
insertafter: '^Defaults' | ||
regexp: '^\s*Defaults\s+use_pty\s*$' | ||
line: 'Defaults use_pty' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is spaced to look like the defaults in the distributed sudoers file, it should use a tab like those entries instead of using 8 spaces. For simplicity, since it is not unlikely contributors' editors will replace tabs with spaces, just use a single space. |
||
insertafter: 'EOF' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should insert at end of file, in particular the inserted directive should take precedence over "Defaults !use_pty" if that appears in an included file or in #includedir. |
||
when: | ||
- ubtu20cis_rule_4_3_2 | ||
tags: | ||
|
@@ -33,9 +33,9 @@ | |
- name: "4.3.3 | PATCH | Ensure sudo log file exists" | ||
ansible.builtin.lineinfile: | ||
path: /etc/sudoers | ||
regexp: '^Defaults logfile' | ||
line: 'Defaults logfile="{{ ubtu20cis_sudo_logfile }}"' | ||
insertafter: '^Defaults' | ||
regexp: '^\s*Defaults\s+logfile\s*=' | ||
line: 'Defaults logfile="{{ ubtu20cis_sudo_logfile }}"' | ||
insertafter: 'EOF' | ||
when: | ||
- ubtu20cis_rule_4_3_3 | ||
tags: | ||
|
@@ -89,15 +89,15 @@ | |
- name: "4.3.6 | PATCH | Ensure sudo authentication timeout is configured correctly | Set value if no results" | ||
ansible.builtin.lineinfile: | ||
path: /etc/sudoers | ||
regexp: 'Defaults timestamp_timeout=' | ||
regexp: '^\s*Defaults\s+timestamp_timeout\s*=' | ||
line: "Defaults timestamp_timeout={{ ubtu20cis_sudo_timestamp_timeout }}" | ||
validate: '/usr/sbin/visudo -cf %s' | ||
when: ubtu20cis_4_3_6_timeout_files.stdout | length == 0 | ||
|
||
- name: "4.3.6 | PATCH | Ensure sudo authentication timeout is configured correctly | Set value if has results" | ||
ansible.builtin.replace: | ||
path: "{{ item }}" | ||
regexp: 'timestamp_timeout=(\d+)' | ||
regexp: 'timestamp_timeout\s*=\s*(\d+)' | ||
replace: "timestamp_timeout={{ ubtu20cis_sudo_timestamp_timeout }}" | ||
validate: '/usr/sbin/visudo -cf %s' | ||
loop: "{{ ubtu20cis_4_3_6_timeout_files.stdout_lines }}" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look for a wider range of compatible regexps...in particular, I had a file that mirrored the format of the lines in the distribution file and used a tab to separate. Instead of calling it correct or replacing the line, it added a new line.