-
Notifications
You must be signed in to change notification settings - Fork 708
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
Ubuntu 24.04 6.1.2.1.2 Ensure systemd-journal-upload authentication #12852
base: master
Are you sure you want to change the base?
Conversation
Hi @ericeberry. Thanks for your PR. I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor changes
...ng/journald/systemd_journal_upload_server_tls/tests/journald-conf-servercert-missing.fail.sh
Outdated
Show resolved
Hide resolved
linux_os/guide/system/logging/journald/systemd_journal_upload_server_tls/oval/shared.xml
Show resolved
Hide resolved
5bed8f1
to
53a6846
Compare
This datastream diff is auto generated by the check Click here to see the full diffNew content has different text for rule 'xccdf_org.ssgproject.content_rule_systemd_journal_upload_server_tls'.
--- xccdf_org.ssgproject.content_rule_systemd_journal_upload_server_tls
+++ xccdf_org.ssgproject.content_rule_systemd_journal_upload_server_tls
@@ -1,6 +1,6 @@
[title]:
-Configure systemd-journal-upload TLS parameters: ServerKeyFile,ServerCertificateFile and TrustedCertificateFile
+Configure systemd-journal-upload TLS parameters: ServerKeyFile, ServerCertificateFile and TrustedCertificateFile
[description]:
SUSE Linux Enterprise Micro 5 must offload rsyslog messages for networked systems in real time and
OCIL for rule 'xccdf_org.ssgproject.content_rule_systemd_journal_upload_server_tls' differs.
--- ocil:ssg-systemd_journal_upload_server_tls_ocil:questionnaire:1
+++ ocil:ssg-systemd_journal_upload_server_tls_ocil:questionnaire:1
@@ -1,5 +1,5 @@
To ensure logs are sent securely to a remote host, examine the file
-/etc/systemd/journal-upload.conf.
+.
ServerKeyFile should be present:
ServerKeyFile=
ServerCertificateFile should be present:
bash remediation for rule 'xccdf_org.ssgproject.content_rule_systemd_journal_upload_server_tls' differs.
--- xccdf_org.ssgproject.content_rule_systemd_journal_upload_server_tls
+++ xccdf_org.ssgproject.content_rule_systemd_journal_upload_server_tls
@@ -1,5 +1,7 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel-default; then
+
+var_journal_upload_conf_file=''
var_journal_upload_server_key_file=''
@@ -13,16 +15,16 @@
# If the key exists, change it. Otherwise, add it to the config_file.
# We search for the key string followed by a word boundary (matched by \>),
# so if we search for 'setting', 'setting2' won't match.
-if LC_ALL=C grep -q -m 1 -i -e "^ServerKeyFile\\>" "/etc/systemd/journal-upload.conf"; then
+if LC_ALL=C grep -q -m 1 -i -e "^ServerKeyFile\\>" "$var_journal_upload_conf_file"; then
escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^ServerKeyFile\\>.*/$escaped_formatted_output/gi" "/etc/systemd/journal-upload.conf"
+ LC_ALL=C sed -i --follow-symlinks "s/^ServerKeyFile\\>.*/$escaped_formatted_output/gi" "$var_journal_upload_conf_file"
else
- if [[ -s "/etc/systemd/journal-upload.conf" ]] && [[ -n "$(tail -c 1 -- "/etc/systemd/journal-upload.conf" || true)" ]]; then
- LC_ALL=C sed -i --follow-symlinks '$a'\\ "/etc/systemd/journal-upload.conf"
+ if [[ -s "$var_journal_upload_conf_file" ]] && [[ -n "$(tail -c 1 -- "$var_journal_upload_conf_file" || true)" ]]; then
+ LC_ALL=C sed -i --follow-symlinks '$a'\\ "$var_journal_upload_conf_file"
fi
cce="CCE-94080-9"
- printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "/etc/systemd/journal-upload.conf" >> "/etc/systemd/journal-upload.conf"
- printf '%s\n' "$formatted_output" >> "/etc/systemd/journal-upload.conf"
+ printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "$var_journal_upload_conf_file" >> "$var_journal_upload_conf_file"
+ printf '%s\n' "$formatted_output" >> "$var_journal_upload_conf_file"
fi
var_journal_upload_server_certificate_file=''
@@ -37,16 +39,16 @@
# If the key exists, change it. Otherwise, add it to the config_file.
# We search for the key string followed by a word boundary (matched by \>),
# so if we search for 'setting', 'setting2' won't match.
-if LC_ALL=C grep -q -m 1 -i -e "^ServerCertificateFile\\>" "/etc/systemd/journal-upload.conf"; then
+if LC_ALL=C grep -q -m 1 -i -e "^ServerCertificateFile\\>" "$var_journal_upload_conf_file"; then
escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^ServerCertificateFile\\>.*/$escaped_formatted_output/gi" "/etc/systemd/journal-upload.conf"
+ LC_ALL=C sed -i --follow-symlinks "s/^ServerCertificateFile\\>.*/$escaped_formatted_output/gi" "$var_journal_upload_conf_file"
else
- if [[ -s "/etc/systemd/journal-upload.conf" ]] && [[ -n "$(tail -c 1 -- "/etc/systemd/journal-upload.conf" || true)" ]]; then
- LC_ALL=C sed -i --follow-symlinks '$a'\\ "/etc/systemd/journal-upload.conf"
+ if [[ -s "$var_journal_upload_conf_file" ]] && [[ -n "$(tail -c 1 -- "$var_journal_upload_conf_file" || true)" ]]; then
+ LC_ALL=C sed -i --follow-symlinks '$a'\\ "$var_journal_upload_conf_file"
fi
cce="CCE-94080-9"
- printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "/etc/systemd/journal-upload.conf" >> "/etc/systemd/journal-upload.conf"
- printf '%s\n' "$formatted_output" >> "/etc/systemd/journal-upload.conf"
+ printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "$var_journal_upload_conf_file" >> "$var_journal_upload_conf_file"
+ printf '%s\n' "$formatted_output" >> "$var_journal_upload_conf_file"
fi
var_journal_upload_server_trusted_certificate_file=''
@@ -61,16 +63,16 @@
# If the key exists, change it. Otherwise, add it to the config_file.
# We search for the key string followed by a word boundary (matched by \>),
# so if we search for 'setting', 'setting2' won't match.
-if LC_ALL=C grep -q -m 1 -i -e "^TrustedCertificateFile\\>" "/etc/systemd/journal-upload.conf"; then
+if LC_ALL=C grep -q -m 1 -i -e "^TrustedCertificateFile\\>" "$var_journal_upload_conf_file"; then
escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^TrustedCertificateFile\\>.*/$escaped_formatted_output/gi" "/etc/systemd/journal-upload.conf"
+ LC_ALL=C sed -i --follow-symlinks "s/^TrustedCertificateFile\\>.*/$escaped_formatted_output/gi" "$var_journal_upload_conf_file"
else
- if [[ -s "/etc/systemd/journal-upload.conf" ]] && [[ -n "$(tail -c 1 -- "/etc/systemd/journal-upload.conf" || true)" ]]; then
- LC_ALL=C sed -i --follow-symlinks '$a'\\ "/etc/systemd/journal-upload.conf"
+ if [[ -s "$var_journal_upload_conf_file" ]] && [[ -n "$(tail -c 1 -- "$var_journal_upload_conf_file" || true)" ]]; then
+ LC_ALL=C sed -i --follow-symlinks '$a'\\ "$var_journal_upload_conf_file"
fi
cce="CCE-94080-9"
- printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "/etc/systemd/journal-upload.conf" >> "/etc/systemd/journal-upload.conf"
- printf '%s\n' "$formatted_output" >> "/etc/systemd/journal-upload.conf"
+ printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "$var_journal_upload_conf_file" >> "$var_journal_upload_conf_file"
+ printf '%s\n' "$formatted_output" >> "$var_journal_upload_conf_file"
fi
else
OCIL for rule 'xccdf_org.ssgproject.content_rule_systemd_journal_upload_url' differs.
--- ocil:ssg-systemd_journal_upload_url_ocil:questionnaire:1
+++ ocil:ssg-systemd_journal_upload_url_ocil:questionnaire:1
@@ -1,5 +1,5 @@
To ensure logs are sent to a remote host, examine the file
-/etc/systemd/journal-upload.conf.
+.
URL should be present:
URL=
Is it the case that systemd-journal-upload URL is missing or commented in /etc/systemd/journal-upload.conf?
bash remediation for rule 'xccdf_org.ssgproject.content_rule_systemd_journal_upload_url' differs.
--- xccdf_org.ssgproject.content_rule_systemd_journal_upload_url
+++ xccdf_org.ssgproject.content_rule_systemd_journal_upload_url
@@ -1,5 +1,7 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel-default; then
+
+var_journal_upload_conf_file=''
var_journal_upload_url=''
@@ -13,16 +15,16 @@
# If the key exists, change it. Otherwise, add it to the config_file.
# We search for the key string followed by a word boundary (matched by \>),
# so if we search for 'setting', 'setting2' won't match.
-if LC_ALL=C grep -q -m 1 -i -e "^URL\\>" "/etc/systemd/journal-upload.conf"; then
+if LC_ALL=C grep -q -m 1 -i -e "^URL\\>" "$var_journal_upload_conf_file"; then
escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^URL\\>.*/$escaped_formatted_output/gi" "/etc/systemd/journal-upload.conf"
+ LC_ALL=C sed -i --follow-symlinks "s/^URL\\>.*/$escaped_formatted_output/gi" "$var_journal_upload_conf_file"
else
- if [[ -s "/etc/systemd/journal-upload.conf" ]] && [[ -n "$(tail -c 1 -- "/etc/systemd/journal-upload.conf" || true)" ]]; then
- LC_ALL=C sed -i --follow-symlinks '$a'\\ "/etc/systemd/journal-upload.conf"
+ if [[ -s "$var_journal_upload_conf_file" ]] && [[ -n "$(tail -c 1 -- "$var_journal_upload_conf_file" || true)" ]]; then
+ LC_ALL=C sed -i --follow-symlinks '$a'\\ "$var_journal_upload_conf_file"
fi
cce="CCE-94081-7"
- printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "/etc/systemd/journal-upload.conf" >> "/etc/systemd/journal-upload.conf"
- printf '%s\n' "$formatted_output" >> "/etc/systemd/journal-upload.conf"
+ printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "$var_journal_upload_conf_file" >> "$var_journal_upload_conf_file"
+ printf '%s\n' "$formatted_output" >> "$var_journal_upload_conf_file"
fi
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes needed
{{{ bash_instantiate_variables("var_journal_upload_server_key_file") }}} | ||
{{{ bash_replace_or_append('/etc/systemd/journal-upload.conf', '^ServerKeyFile', "$var_journal_upload_server_key_file", '%s=%s') }}} | ||
{{{ bash_replace_or_append('$var_journal_upload_conf_file', '^ServerKeyFile', "$var_journal_upload_server_key_file", '%s=%s') }}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes would affect slmicro too.
Use a ubuntu-specific remediation file (ubuntu.sh) or place the code inside conditionals, e.g.
{{% if 'ubuntu' in product %}}
{{{ bash_instantiate_variables("var_journal_upload_conf_file") }}}
{{% else %}}
var_journal_upload_conf_file=/etc/systemd/journal-upload.conf
{{% endif %}}
That said, I couldn't find the XCCDF variable var_journal_upload_conf_file
in the codebase.
If you want to introduce a new variable you need to create it, analogous to /linux_os/guide/system/logging/journald/var_journal_upload_url.var
.
For this specific case, I wouldn't recommend using an XCCDF variable though, since config file locations are not something that we generally let the users specify at runtime. Config file paths are mostly hardcoded into the rules. If they differ across OS-es they can be defined via conditionals or via Jinja variables defined in product.yml
files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the file you were looking for (that I created): https://github.com/ComplianceAsCode/content/blob/53a6846f6f0f92cc4bbafd56246c32af110f6e8c/linux_os/guide/system/logging/journald/var_journal_upload_conf_file.var
Doesn't the default setting take care of the slmicro case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably 95% of the time, I would think they use the default filename (/etc/systemd/journal-update.conf). But I think the new way of configuring is to create a file in the /etc/systemd/journal-update.conf.d directory now. I needed to be able to change the name of the file for the tests so that I could specify files in the conf.d directory.
linux_os/guide/system/logging/journald/systemd_journal_upload_server_tls/rule.yml
Outdated
Show resolved
Hide resolved
linux_os/guide/system/logging/journald/systemd_journal_upload_server_tls/rule.yml
Outdated
Show resolved
Hide resolved
|
||
{{{ bash_instantiate_variables("var_journal_upload_conf_file") }}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See first comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't setting the default in the var_journal_upload_conf_file.var handle the slmicro case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compile slmicro5 and it looks like it is ok.
Code Climate has analyzed commit c15a18c 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 61.9% (0.0% change). View more on Code Climate. |
Description:
Rationale: