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

Move daemon.* to /var/log/messages #12433

Conversation

Mab879
Copy link
Member

@Mab879 Mab879 commented Sep 26, 2024

Description:

Move daemon.* to /var/log/messages

Rationale:

Based on feedback from maintainers.

@Mab879 Mab879 added the Update Rule Issues or pull requests related to Rules updates. label Sep 26, 2024
@Mab879 Mab879 added this to the 0.1.75 milestone Sep 26, 2024
Copy link

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

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

Click here to see the full diff
New content has different text for rule 'xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring'.
--- xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring
+++ xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring
@@ -11,7 +11,9 @@
 /etc/rsyslog.d/*.conf file should contain a match for the following
 selectors: auth.*, authpriv.*, and daemon.*. If
 not, use the following as an example configuration:
-auth.*;authpriv.*;daemon.*                              /var/log/secure
+
+    auth.*;authpriv.*                              /var/log/secure
+    daemon.*                                       /var/log/messages
 
 [reference]:
 CCI-000067

bash remediation for rule 'xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring' differs.
--- xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring
+++ xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring
@@ -2,25 +2,26 @@
 if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
 
 declare -A REMOTE_METHODS=( ['auth.*']='^[^#]*auth\.\*.*$' ['authpriv.*']='^[^#]*authpriv\.\*.*$' ['daemon.*']='^[^#]*daemon\.\*.*$' )
+declare -A LOCATIONS=( ['auth.*']='/var/log/secure' ['authpriv.*']='/var/log/secure' ['daemon.*']='/var/log/messages' )
 
 if [[ ! -f /etc/rsyslog.conf ]]; then
 	# Something is not right, create the file
 	touch /etc/rsyslog.conf
 fi
 
-APPEND_LINE=$(sed -rn '/^\S+\s+\/var\/log\/secure$/p' /etc/rsyslog.conf)
 
 # Loop through the remote methods associative array
 for K in "${!REMOTE_METHODS[@]}"
 do
 	# Check to see if selector/value exists
 	if ! grep -rq "${REMOTE_METHODS[$K]}" /etc/rsyslog.*; then
+        APPEND_LINE=$(sed -rn "/^\S+\s+\${LOCATIONS[$K]}$/p" /etc/rsyslog.conf)
 		# Make sure we have a line to insert after, otherwise append to end
 		if [[ ! -z ${APPEND_LINE} ]]; then
 			# Add selector to file
 			sed -r -i "0,/^(\S+\s+\/var\/log\/secure$)/s//\1\n${K} \/var\/log\/secure/" /etc/rsyslog.conf
 		else
-			echo "${K} /var/log/secure" >> /etc/rsyslog.conf
+			echo "${K} ${LOCATIONS[$K]}" >> /etc/rsyslog.conf
 		fi
 	fi
 done

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring' differs.
--- xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring
+++ xccdf_org.ssgproject.content_rule_rsyslog_remote_access_monitoring
@@ -5,10 +5,13 @@
     remote_methods:
     - selector: auth.*
       regexp: ^.*auth\.\*.*$
+      location: /var/log/secure
     - selector: authpriv.*
       regexp: ^.*authpriv\.\*.*$
+      location: /var/log/secure
     - selector: daemon.*
       regexp: ^.*daemon\.\*.*$
+      location: /var/log/messages
   when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
   tags:
   - CCE-83426-7
@@ -100,7 +103,7 @@
 - name: 'Ensure remote access methods are monitored in Rsyslog: Configure'
   lineinfile:
     path: /etc/rsyslog.conf
-    line: '{{ item.item.0.selector }} /var/log/secure'
+    line: '{{ item.item.0.selector }} {{ item.item.0.location }}'
     insertafter: ^.*\/var\/log\/secure.*$
     create: true
   loop: '{{ remote_method_values.results }}'

Copy link

github-actions bot commented Sep 26, 2024

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:12433
This image was built from commit: 17ba62c

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:12433

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:12433 make deploy-local

@Mab879 Mab879 marked this pull request as draft September 27, 2024 16:42
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Sep 27, 2024
@Mab879 Mab879 force-pushed the update_rsyslog_remote_access_monitoring branch from 177f81a to f986b7a Compare September 27, 2024 16:44
@Mab879 Mab879 marked this pull request as ready for review September 27, 2024 16:44
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Sep 27, 2024
@@ -0,0 +1,29 @@
#!/bin/bash
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo in the test scenario file name

for K in ${!REMOTE_METHODS[@]}
do
if grep -q "${REMOTE_METHODS[$K]}" ${rsyslog_d_file}; then
sed -i "/${REMOTE_METHODS[$K]}/d" ${rsyslog_d_file}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The curly braces aren't needed if the variable isn't an array.

touch /etc/rsyslog.conf
fi

echo "auth.*,authpriv.* /var/log/secure" >> $RSYSLOG_CONF
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should there be a comma or a semicolon between the asterisk and a? The rule description has a semicolon and here you have a comma.

@jan-cerny jan-cerny self-assigned this Sep 30, 2024
Copy link

codeclimate bot commented Sep 30, 2024

Code Climate has analyzed commit 17ba62c 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 59.5% (0.0% change).

View more on Code Climate.

@jan-cerny
Copy link
Collaborator

/packit build

@jan-cerny jan-cerny merged commit 3568eae into ComplianceAsCode:master Oct 2, 2024
97 of 100 checks passed
@Mab879 Mab879 deleted the update_rsyslog_remote_access_monitoring branch October 2, 2024 14:49
jan-cerny pushed a commit to jan-cerny/scap-security-guide that referenced this pull request Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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