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

Regexp does not correctly detect PermitUserEnvironment for MEDIUM | RHEL-08-010830 | PATCH | #314

Closed
moncapitain opened this issue Nov 14, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@moncapitain
Copy link

moncapitain commented Nov 14, 2024

Describe the Issue
The ansible play for detecting PermitUserEnvironment in the /etc/ssh/sshd_config:
regexp: '(?i)^#?PermitUserEnvironment'
Does not appear to correctly detect the "#PermitUserEnvironment" entry.
Expected Behavior
The expected behavior for this ansible play would be to uncomment #PermitUserEnvironment no to PermitUserEnvironment no.

Actual Behavior
Because the regexp does not appear to even find #PermitUserEnvironment it does not remove the comment.

Control(s) Affected
Because this ansible play does detect #PermitUserEnvironment it does not remove the comment so therefore the stig is not applied.

Environment (please complete the following information):

  • branch being used: [main]
  • Ansible Version: [core 2.16.3]
  • Host Python Version: [Python 3.12.3]
  • Ansible Server Python Version: [Python 3.12.3]
  • Additional Details:

Additional Notes
Anything additional goes here

Possible Solution
Possible solution would be to replace the regexp entry with, have not tested this as of yet:
regexp: '^(#)?PermitUserEnvironment\b'

@moncapitain moncapitain added the bug Something isn't working label Nov 14, 2024
@moncapitain
Copy link
Author

Please close this issue, something else is occurring in the environment that I have not yet fully researched.

@moncapitain
Copy link
Author

This is not a bug.

@dglinder
Copy link

This is not a bug.

Can you elaborate? I'm opening an issue on this same task as the current REGEX doesn't correctly adjust when the line in the sshd_config is simply:

#PermitUserEnvironment no`
``

In this case the `regex:` in the `lineinfile:` module matches that line (with the leading `#`), and sees that it's already `no` and assumes it is ok.

I'm not sure what corner cases the '(?i)^#?PermitUserEnvironment' regex was trying to handle, but changing the `regex:` (remove the `#?`) appears to work as intended.

See issue #316 for my notes.

@moncapitain
Copy link
Author

moncapitain commented Dec 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants