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

put exec back to configure_bashrc_exec_tmux #11561

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

vojtapolasek
Copy link
Collaborator

Description:

  • modify the rule so that the "exec" is used in the command
  • remove it from RHEL 9 STIG and assign configure_bashrc_tmux instead

Rationale:

  • the exec command in the rule plays quite an important role. If the exec is present, then exiting tmux will drop user into a login shell. Without exec, it will drop to regular shell, so that the screen locking mechanism might be not effective.

@vojtapolasek vojtapolasek added RHEL9 Red Hat Enterprise Linux 9 product related. Update Rule Issues or pull requests related to Rules updates. STIG STIG Benchmark related. labels Feb 8, 2024
@vojtapolasek vojtapolasek added this to the 0.1.73 milestone Feb 8, 2024
Copy link

github-actions bot commented Feb 8, 2024

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

Click here to see the full diff
OCIL for rule 'xccdf_org.ssgproject.content_rule_configure_bashrc_exec_tmux' differs.
--- ocil:ssg-configure_bashrc_exec_tmux_ocil:questionnaire:1
+++ ocil:ssg-configure_bashrc_exec_tmux_ocil:questionnaire:1
@@ -4,7 +4,7 @@
 
 $ sudo grep tmux /etc/bashrc /etc/profile.d/*
 
-/etc/profile.d/tmux.sh:  case "$name" in (sshd|login) tmux ;; esac
+/etc/profile.d/tmux.sh:  case "$name" in (sshd|login) exec tmux ;; esac
 
 Review the tmux script by using the following example:
 
@@ -13,7 +13,7 @@
 if [ "$PS1" ]; then
 parent=$(ps -o ppid= -p $$)
 name=$(ps -o comm= -p $parent)
-case "$name" in (sshd|login) tmux ;; esac
+case "$name" in (sshd|login) exec tmux ;; esac
 fi
 
 If the shell file is not configured as the example above, is commented out, or is missing, this is a finding.

bash remediation for rule 'xccdf_org.ssgproject.content_rule_configure_bashrc_exec_tmux' differs.
--- xccdf_org.ssgproject.content_rule_configure_bashrc_exec_tmux
+++ xccdf_org.ssgproject.content_rule_configure_bashrc_exec_tmux
@@ -1,12 +1,12 @@
 # Remediation is applicable only in certain platforms
 if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ] && { rpm --quiet -q tmux; }; then
 
-if ! grep -x '  case "$name" in sshd|login) tmux ;; esac' /etc/bashrc; then
+if ! grep -x '  case "$name" in sshd|login) exec tmux ;; esac' /etc/bashrc; then
     cat >> /etc/profile.d/tmux.sh <<'EOF'
 if [ "$PS1" ]; then
   parent=$(ps -o ppid= -p $$)
   name=$(ps -o comm= -p $parent)
-  case "$name" in sshd|login) tmux ;; esac
+  case "$name" in sshd|login) exec tmux ;; esac
 fi
 EOF
     chmod 0644 /etc/profile.d/tmux.sh

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_configure_bashrc_exec_tmux' differs.
--- xccdf_org.ssgproject.content_rule_configure_bashrc_exec_tmux
+++ xccdf_org.ssgproject.content_rule_configure_bashrc_exec_tmux
@@ -15,7 +15,7 @@
   ansible.builtin.find:
     paths: /etc
     patterns: bashrc
-    contains: .*case "$name" in sshd|login\) tmux ;; esac.*
+    contains: .*case "$name" in sshd|login\) exec tmux ;; esac.*
   register: tmux_in_bashrc
   when:
   - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
@@ -34,7 +34,7 @@
   ansible.builtin.find:
     paths: /etc/profile.d
     patterns: '*.sh'
-    contains: .*case "$name" in sshd|login\) tmux ;; esac.*
+    contains: .*case "$name" in sshd|login\) exec tmux ;; esac.*
   register: tmux_in_profile_d
   when:
   - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
@@ -55,7 +55,7 @@
       if [ "$PS1" ]; then
         parent=$(ps -o ppid= -p $$)
         name=$(ps -o comm= -p $parent)
-        case "$name" in sshd|login) tmux ;; esac
+        case "$name" in sshd|login) exec tmux ;; esac
       fi
     create: true
   when:

Copy link

github-actions bot commented Feb 8, 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

codeclimate bot commented Feb 8, 2024

Code Climate has analyzed commit ee739c5 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 Feb 8, 2024
@Mab879
Copy link
Member

Mab879 commented Feb 8, 2024

/retest-required

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.

Thanks!

@Mab879
Copy link
Member

Mab879 commented Feb 8, 2024

Waving Automatus for SLE15 as it appears not be applicable for the platform.

@Mab879 Mab879 merged commit 85d5c88 into ComplianceAsCode:master Feb 8, 2024
42 of 43 checks passed
jan-cerny added a commit to jan-cerny/contest that referenced this pull request Feb 9, 2024
After merging ComplianceAsCode/content#11561,
the rule configure_bashrc_tmux is included in RHEL 9 STIG, therefore,
the waiver applicability should be extended to RHEL 9.
This problem has been reported by:
ComplianceAsCode/content#11569
comps pushed a commit to RHSecurityCompliance/contest that referenced this pull request Feb 9, 2024
After merging ComplianceAsCode/content#11561,
the rule configure_bashrc_tmux is included in RHEL 9 STIG, therefore,
the waiver applicability should be extended to RHEL 9.
This problem has been reported by:
ComplianceAsCode/content#11569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RHEL9 Red Hat Enterprise Linux 9 product related. STIG STIG Benchmark related. Update Rule Issues or pull requests related to Rules updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants