Fix config paths and regex for auditd_audispd_configure_remote_server#11857
Conversation
|
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. DetailsInstructions 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/test-infra 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_auditd_audispd_configure_remote_server' differs.
--- xccdf_org.ssgproject.content_rule_auditd_audispd_configure_remote_server
+++ xccdf_org.ssgproject.content_rule_auditd_audispd_configure_remote_server
@@ -8,27 +8,21 @@
-# Strip any search characters in the key arg so that the key can be replaced without
-# adding any search characters to the config file.
-stripped_key=$(sed 's/[\^=\$,;+]*//g' <<< "^remote_server")
+if [ -e "$AUDITCONFIG" ] ; then
+
+ LC_ALL=C sed -i "/^\s*remote_server\s*=\s*/Id" "$AUDITCONFIG"
+else
+ printf '%s\n' "Path '$AUDITCONFIG' wasn't found on this system. Refusing to continue." >&2
+ return 1
+fi
+# make sure file has newline at the end
+sed -i -e '$a\' "$AUDITCONFIG"
-# shellcheck disable=SC2059
-printf -v formatted_output "%s = %s" "$stripped_key" "$var_audispd_remote_server"
-
-# 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 "^remote_server\\>" "$AUDITCONFIG"; then
- escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output")
- LC_ALL=C sed -i --follow-symlinks "s/^remote_server\\>.*/$escaped_formatted_output/gi" "$AUDITCONFIG"
-else
- if [[ -s "$AUDITCONFIG" ]] && [[ -n "$(tail -c 1 -- "$AUDITCONFIG" || true)" ]]; then
- LC_ALL=C sed -i --follow-symlinks '$a'\\ "$AUDITCONFIG"
- fi
- cce="CCE-80925-1"
- printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "$AUDITCONFIG" >> "$AUDITCONFIG"
- printf '%s\n' "$formatted_output" >> "$AUDITCONFIG"
-fi
+cp "$AUDITCONFIG" "$AUDITCONFIG.bak"
+# Insert at the end of the file
+printf '%s\n' "remote_server = $var_audispd_remote_server" >> "$AUDITCONFIG"
+# Clean up after ourselves.
+rm "$AUDITCONFIG.bak"
else
>&2 echo 'Remediation is not applicable, nothing was done' |
|
🤖 A k8s content image for this PR is available at: Click here to see how to deploy itIf you alread have Compliance Operator deployed: Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and: |
17ef722 to
460d333
Compare
|
@mpurg there are some test failures, could you please investigate? |
460d333 to
f916f59
Compare
f916f59 to
5ec6469
Compare
|
@dodys , should work now. I updated |
|
Code Climate has analyzed commit 5ec6469 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.4% (0.0% change). View more on Code Climate. |
Description:
audispon Ubuntuauditd_audispd_configure_remote_serverto allow case-insensitive keywordsauditd_audispd_configure_remote_serverfor UbuntuRationale: