diff --git a/shared/macros/10-ansible.jinja b/shared/macros/10-ansible.jinja
index 7d600a4d20a..8f3d19a3afc 100644
--- a/shared/macros/10-ansible.jinja
+++ b/shared/macros/10-ansible.jinja
@@ -274,6 +274,9 @@ value: :code:`Setting={{ varname1 }}`
ansible.builtin.file:
path: {{{ config_file }}}
mode: '0600'
+ state: touch
+ modification_time: preserve
+ access_time: preserve
{{%- else %}}
{{{ ansible_set_config_file(msg, "/etc/ssh/ssh_config", parameter, value=value, create="yes", prefix_regex='(?i)^\s*', validate="", insert_before="BOF", rule_title=rule_title) }}}
{{%- endif %}}
diff --git a/shared/templates/rsyslog_logfiles_attributes_modify/ansible.template b/shared/templates/rsyslog_logfiles_attributes_modify/ansible.template
index 2ebf9b3cf1f..5fe77f3903e 100644
--- a/shared/templates/rsyslog_logfiles_attributes_modify/ansible.template
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/ansible.template
@@ -50,7 +50,7 @@
ansible.builtin.shell: |
{{%- if not 'debian' in product %}}
set -o pipefail{{% endif %}}
- grep -oP '^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*\.*$' {{ item.1.path }} | \
+ grep -oP '^[^(\s|#|\$)]+[\s]*.*[\s]+-?(/+[^:;\s]+);*\.*$' {{ item.1.path }} | \
awk '{print $NF}' | \
sed -e 's/^-//' || true
loop: "{{ rsyslog_config_files.results | default([]) | subelements('files') }}"
@@ -62,10 +62,11 @@
ansible.builtin.shell: |
{{%- if not 'debian' in product %}}
set -o pipefail{{% endif %}}
- grep -ozP "action\s*\(\s*type\s*=\s*\"omfile\"[^\)]*\)" {{ item.1.path }} | \
- grep -aoP "\bFile\s*=\s*\"([/[:alnum:][:punct:]]*)\"\s*\)" | \
+ grep -iozP "action\s*\(\s*type\s*=\s*\"omfile\"[^\)]*\)" {{ item.1.path }} | \
+ grep -iaoP "\bFile\s*=\s*\"([/[:alnum:][:punct:]]*)\"\s*\)" | \
grep -oE "\"([/[:alnum:][:punct:]]*)\"" | \
- tr -d "\""|| true
+ tr -d "\"" | \
+ grep -v '^/dev/' || true
loop: "{{ rsyslog_config_files.results | default([]) | subelements('files') }}"
register: log_files_new
changed_when: False
diff --git a/shared/templates/rsyslog_logfiles_attributes_modify/bash.template b/shared/templates/rsyslog_logfiles_attributes_modify/bash.template
index 338360f75d4..7a9e8824707 100644
--- a/shared/templates/rsyslog_logfiles_attributes_modify/bash.template
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/bash.template
@@ -77,11 +77,12 @@ done
# extract possibly multiline action omfile expressions
# extract File="logfile" expression
# match only "logfile" expression
+# exclude /dev/* paths (e.g., /dev/console)
for LOG_FILE in "${RSYSLOG_CONFIG_FILES[@]}"
do
ACTION_OMFILE_LINES=$(grep -iozP "action\s*\(\s*type\s*=\s*\"omfile\"[^\)]*\)" "${LOG_FILE}")
OMFILE_LINES=$(echo "${ACTION_OMFILE_LINES}"| grep -iaoP "\bFile\s*=\s*\"([/[:alnum:][:punct:]]*)\"\s*\)")
- LOG_FILE_PATHS+=("$(echo "${OMFILE_LINES}"| grep -oE "\"([/[:alnum:][:punct:]]*)\""|tr -d "\"")")
+ LOG_FILE_PATHS+=("$(echo "${OMFILE_LINES}"| grep -oE "\"([/[:alnum:][:punct:]]*)\""|tr -d "\"" | grep -v "^/dev/")")
done
# Ensure the correct attribute if file exists
diff --git a/shared/templates/rsyslog_logfiles_attributes_modify/oval.template b/shared/templates/rsyslog_logfiles_attributes_modify/oval.template
index dcca7cb92ec..50ecec6a078 100644
--- a/shared/templates/rsyslog_logfiles_attributes_modify/oval.template
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/oval.template
@@ -82,9 +82,11 @@
* contains at least one slash '/' character, and simultaneously doesn't contain any
of ';', ':' and space characters,
* the chunk was retrieved from a row not starting with space, '#', or '$' characters
+ * for newer versions of Rsyslog, there is now only the RainerScript syntax and the
+ regex now matches both syntaxes.
-->
^\s*[^(\s|#|\$)]+\s+.*(?:\bFile="|\s|\/|-)(\/[^:;\s"]+).*$
+ operation="pattern match">^\s*[^#$].*?(?:\b[Ff]ile="([^"\s]+)"|[\s]+-?(\/[^:;\s]+)).*$
1
state_{{{ _RULE_ID }}}_ignore_include_paths
@@ -94,9 +96,10 @@
+ from the list of objects found. Also exclude lines that are part of multiline include
+ statements (lines starting with whitespace followed by file=) and /dev/* device files. -->
(?:file="[^\s;]+"|\$IncludeConfig[\s]+[^\s;]+|\/dev\/.*)
+ operation="pattern match">(?:include\([\n\s]*\b[Ff]ile="[^\s;]+"|\$IncludeConfig[\s]+[^\s;]+|^\s+\b[Ff]ile="|\/dev\/.*)