-
Notifications
You must be signed in to change notification settings - Fork 745
Fix oval and remediations for journald-upload rules #13050
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
Fix oval and remediations for journald-upload rules #13050
Conversation
- fix commenting by replacing broken macros with sed - fix missing section in config file by switching to macro bash_ensure_ini_config - improve OVAL to check for correct section
Hi @mpurg. 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. |
This datastream diff is auto generated by the check Click here to see the full diffbash 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,8 +1,5 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel-default; then
-
-var_journal_upload_conf_file=/etc/systemd/journal-upload.conf
-
var_journal_upload_server_key_file=''
@@ -16,16 +13,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\\>" "$var_journal_upload_conf_file"; then
+if LC_ALL=C grep -q -m 1 -i -e "^ServerKeyFile\\>" "/etc/systemd/journal-upload.conf"; then
escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^ServerKeyFile\\>.*/$escaped_formatted_output/gi" "$var_journal_upload_conf_file"
+ LC_ALL=C sed -i --follow-symlinks "s/^ServerKeyFile\\>.*/$escaped_formatted_output/gi" "/etc/systemd/journal-upload.conf"
else
- if [[ -s "$var_journal_upload_conf_file" ]] &&am
8000
p; [[ -n "$(tail -c 1 -- "$var_journal_upload_conf_file" || true)" ]]; then
- LC_ALL=C sed -i --follow-symlinks '$a'\\ "$var_journal_upload_conf_file"
+ 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"
fi
cce="CCE-94080-9"
- 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"
+ 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"
fi
var_journal_upload_server_certificate_file=''
@@ -40,16 +37,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\\>" "$var_journal_upload_conf_file"; then
+if LC_ALL=C grep -q -m 1 -i -e "^ServerCertificateFile\\>" "/etc/systemd/journal-upload.conf"; then
escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^ServerCertificateFile\\>.*/$escaped_formatted_output/gi" "$var_journal_upload_conf_file"
+ LC_ALL=C sed -i --follow-symlinks "s/^ServerCertificateFile\\>.*/$escaped_formatted_output/gi" "/etc/systemd/journal-upload.conf"
else
- 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"
+ 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"
fi
cce="CCE-94080-9"
- 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"
+ 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"
fi
var_journal_upload_server_trusted_certificate_file=''
@@ -64,16 +61,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\\>" "$var_journal_upload_conf_file"; then
+if LC_ALL=C grep -q -m 1 -i -e "^TrustedCertificateFile\\>" "/etc/systemd/journal-upload.conf"; then
escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^TrustedCertificateFile\\>.*/$escaped_formatted_output/gi" "$var_journal_upload_conf_file"
+ LC_ALL=C sed -i --follow-symlinks "s/^TrustedCertificateFile\\>.*/$escaped_formatted_output/gi" "/etc/systemd/journal-upload.conf"
else
- 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"
+ 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"
fi
cce="CCE-94080-9"
- 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"
+ 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"
fi
else
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,8 +1,5 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel-default; then
-
-var_journal_upload_conf_file=/etc/systemd/journal-upload.conf
-
var_journal_upload_url=''
@@ -16,16 +13,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\\>" "$var_journal_upload_conf_file"; then
+if LC_ALL=C grep -q -m 1 -i -e "^URL\\>" "/etc/systemd/journal-upload.conf"; then
escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^URL\\>.*/$escaped_formatted_output/gi" "$var_journal_upload_conf_file"
+ LC_ALL=C sed -i --follow-symlinks "s/^URL\\>.*/$escaped_formatted_output/gi" "/etc/systemd/journal-upload.conf"
else
- 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"
+ 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"
fi
cce="CCE-94081-7"
- 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"
+ 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"
fi
else |
Code Climate has analyzed commit a597754 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. |
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.
lgtm, thanks!
Description: