8000 Fix oval and remediations for journald-upload rules by mpurg · Pull Request #13050 · ComplianceAsCode/content · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

mpurg
Copy link
Contributor
@mpurg mpurg commented Feb 14, 2025

Description:

  • fix missing section in config file by switching to macro bash_ensure_ini_config
  • fix commenting by replacing broken macro with sed (macro searches for keywords ending in space and fails when keyword ends with '=')
  • improve OVAL to check for correct section

- 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
Copy link
openshift-ci bot commented Feb 14, 2025

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Feb 14, 2025
Copy link

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

Click here to see the full diff
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,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

@dodys dodys requested a review from a team February 14, 2025 15:11
@dodys dodys self-assigned this Feb 14, 2025
@dodys dodys added OVAL OVAL update. Related to the systems assessments. Bash Bash remediation update. Ubuntu Ubuntu product related. labels Feb 14, 2025
@dodys dodys added this to the 0.1.77 milestone Feb 14, 2025
Copy link
codeclimate bot commented Feb 14, 2025

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.

Copy link
Contributor
@dodys dodys 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!

@dodys dodys merged commit 0efad68 into ComplianceAsCode:master Feb 17, 2025
94 of 102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bash Bash remediation update. needs-ok-to-test Used by openshift-ci bot. OVAL OVAL update. Related to the systems assessments. Ubuntu Ubuntu product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0