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

Allow spaces in rule sudo_custom_logfile #11433

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

jan-cerny
Copy link
Collaborator

We should allow spaces around equal sign in /etc/sudoers. The following should be a valid configuration.

Defaults logfile = /var/log/sudo

Also adds a test scenario that serves as a regression test.

Resolves: https://issues.redhat.com/browse/RHEL-1904

We should allow spaces around equal sign in /etc/sudoers.
The following should be a valid configuration.

Defaults logfile = /var/log/sudo

Also adds a test scenario that serves as a regression test.

Resolves: https://issues.redhat.com/browse/RHEL-1904
@jan-cerny jan-cerny added bugfix Fixes to reported bugs. Update Rule Issues or pull requests related to Rules updates. labels Jan 9, 2024
@jan-cerny jan-cerny added this to the 0.1.72 milestone Jan 9, 2024
Copy link

github-actions bot commented Jan 9, 2024

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Copy link

github-actions bot commented Jan 9, 2024

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_sudo_custom_logfile' differs.
--- xccdf_org.ssgproject.content_rule_sudo_custom_logfile
+++ xccdf_org.ssgproject.content_rule_sudo_custom_logfile
@@ -6,7 +6,7 @@
 
 if /usr/sbin/visudo -qcf /etc/sudoers; then
     cp /etc/sudoers /etc/sudoers.bak
-    if ! grep -P '^[\s]*Defaults[\s]*\blogfile=("(?:\\"|\\\\|[^"\\\n])*"\B|[^"](?:(?:\\,|\\"|\\ |\\\\|[^", \\\n])*)\b)\b.*$' /etc/sudoers; then
+    if ! grep -P '^[\s]*Defaults[\s]*\blogfile\s*=\s*("(?:\\"|\\\\|[^"\\\n])*"\B|[^"](?:(?:\\,|\\"|\\ |\\\\|[^", \\\n])*)\b)\b.*$' /etc/sudoers; then
         # sudoers file doesn't define Option logfile
         echo "Defaults logfile=${var_sudo_logfile}" >> /etc/sudoers
     else

Copy link

codeclimate bot commented Jan 9, 2024

Code Climate has analyzed commit 62068fa and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 58.4% (0.0% change).

View more on Code Climate.

@Mab879 Mab879 self-assigned this Jan 9, 2024
Copy link
Member

@Mab879 Mab879 left a comment

Choose a reason for hiding this comment

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

LGTM.

Automatus tests pass locally.

@Mab879 Mab879 merged commit 45ab494 into ComplianceAsCode:master Jan 9, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes to reported bugs. Update Rule Issues or pull requests related to Rules updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants