-
Notifications
You must be signed in to change notification settings - Fork 685
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
Make the behavior of chronyd_sync_clock rule more consistent #12039
Conversation
Hi @alanmcanonical. 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 diffOVAL for rule 'xccdf_org.ssgproject.content_rule_chronyd_sync_clock' differs.
--- oval:ssg-chronyd_sync_clock:def:1
+++ oval:ssg-chronyd_sync_clock:def:1
@@ -1,2 +1,4 @@
criteria AND
+criteria OR
criterion oval:ssg-test_chronyd_sync_clock:tst:1
+criterion oval:ssg-test_chronyd_sync_clock_config_file_exists:tst:1
bash remediation for rule 'xccdf_org.ssgproject.content_rule_chronyd_sync_clock' differs.
--- xccdf_org.ssgproject.content_rule_chronyd_sync_clock
+++ xccdf_org.ssgproject.content_rule_chronyd_sync_clock
@@ -3,7 +3,7 @@
if [ -e "/etc/chrony/chrony.conf" ] ; then
- LC_ALL=C sed -i "/^\s*makestep 1 \-1/Id" "/etc/chrony/chrony.conf"
+ LC_ALL=C sed -i "/^\s*makestep /Id" "/etc/chrony/chrony.conf"
else
touch "/etc/chrony/chrony.conf"
fi
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_chronyd_sync_clock' differs.
--- xccdf_org.ssgproject.content_rule_chronyd_sync_clock
+++ xccdf_org.ssgproject.content_rule_chronyd_sync_clock
@@ -1,15 +1,37 @@
- name: Synchronize internal information system clocks
- lineinfile:
- path: /etc/chrony/chrony.conf
- create: true
- line: makestep 1 -1
- state: present
+ block:
+
+ - name: Check for duplicate values
+ lineinfile:
+ path: /etc/chrony/chrony.conf
+ create: true
+ regexp: '^\s*makestep '
+ state: absent
+ check_mode: true
+ changed_when: false
+ register: dupes
+
+ - name: Deduplicate values from /etc/chrony/chrony.conf
+ lineinfile:
+ path: /etc/chrony/chrony.conf
+ create: true
+ regexp: '^\s*makestep '
+ state: absent
+ when: dupes.found is defined and dupes.found > 1
+
+ - name: Insert correct line to /etc/chrony/chrony.conf
+ lineinfile:
+ path: /etc/chrony/chrony.conf
+ create: true
+ regexp: '^\s*makestep '
+ line: makestep 1 -1
+ state: present
when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
tags:
- DISA-STIG-UBTU-20-010436
- chronyd_sync_clock
+ - configure_strategy
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- - restrict_strategy |
🤖 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: |
Previous template lineinfile usage will append the configuration even when there is an existing line. Use key_value_pair_in_file to make sure its behavior.
d2e8212
to
fd8c3e9
Compare
Code Climate has analyzed commit fd8c3e9 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. |
@@ -2,7 +2,7 @@ | |||
# packages = chrony | |||
|
|||
{{% if product == 'ubuntu2204' -%}} | |||
echo "makestep 1 1" >> {{{ chrony_conf_path }}} | |||
echo "makestep 1 1" > {{{ chrony_conf_path }}} |
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.
any reason for not being an append?
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.
According to the latest doc, If multiple occurrences of key have conflicting values, the check will evaluate to fail.
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:
Rationale: