Skip to content
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

Merged

Conversation

kdebisschop
Copy link
Contributor

Overall Review of Changes:

Several issues were noted with cis_4.3.x.yml

  • Some tasks insert new lines when functionally identical lines are already present in /etc/sudoers
  • Tasks should insert configuration lines at end of file so later lines do not override them
  • The tasks should be consistent in spacing within the file
  • Lines should not attempt to "emulate" tabs with multiple spaces

Issue Fixes:
Please list (using linking) any open issues this PR addresses

Enhancements:
Please list any enhancements/features that are not open issue tickets

How has this been tested?:
Please give an overview of how these changes were tested. If they were not please use N/A

insertafter: '^Defaults'
regexp: '^\s*Defaults\s+use_pty\s*$'
line: 'Defaults use_pty'
insertafter: 'EOF'
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

line: 'Defaults use_pty'
insertafter: '^Defaults'
regexp: '^\s*Defaults\s+use_pty\s*$'
line: 'Defaults use_pty'
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

regexp: '^Defaults use_'
line: 'Defaults use_pty'
insertafter: '^Defaults'
regexp: '^\s*Defaults\s+use_pty\s*$'
Copy link
Contributor Author

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.

Copy link
Member

@uk-bolly uk-bolly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent work thank you

@uk-bolly uk-bolly merged commit f082010 into ansible-lockdown:devel Dec 11, 2023
4 checks passed
@uk-bolly uk-bolly mentioned this pull request Dec 12, 2023
@kdebisschop kdebisschop deleted the CIS-4_3-sudo-multiple-concerns branch January 28, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants