Skip to content

expand chronyd_specify_remote_server to be aligned with CIS#14241

Merged
jan-cerny merged 4 commits intoComplianceAsCode:masterfrom
vojtapolasek:improve_chronyd_specify_remote_servers
Dec 19, 2025
Merged

expand chronyd_specify_remote_server to be aligned with CIS#14241
jan-cerny merged 4 commits intoComplianceAsCode:masterfrom
vojtapolasek:improve_chronyd_specify_remote_servers

Conversation

@vojtapolasek
Copy link
Collaborator

Description:

  • expand the rule to read confdir and 'sourcedir' directives from the main chrony config file and examining files within these directories for server or pool directives
  • add appropriate test scenarios
  • modify description and ocil

Rationale:

  • This is a valid use case covered by CIS profiles for RHEL 10 (version 1.0.1) and RHEL 8 (version 4).

Review Hints:

Use automatus.

These use cases are described for example in CIS for RHEL 10, section 2.3.2.
@vojtapolasek vojtapolasek added this to the 0.1.80 milestone Dec 15, 2025
@vojtapolasek vojtapolasek added the Update Rule Issues or pull requests related to Rules updates. label Dec 15, 2025
@vojtapolasek vojtapolasek added the CIS CIS Benchmark related. label Dec 15, 2025
@jan-cerny jan-cerny self-assigned this Dec 15, 2025
EOF

# Create empty sources.d directory
mkdir -p /etc/chrony/sources.d
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this directory already exists? I think the directory should be erased before.

@@ -1,21 +1,107 @@
<def-group>
<definition class="compliance" id="chronyd_specify_remote_server" version="1">
<definition class="compliance" id="chronyd_specify_remote_server" version="2">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule is a part of many profiles in many products. Do all of these profiles allow chrony to use sourcedir and confdir?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a feature of Chrony. And it is supported for long time.

<tt>sourcedir</tt> or <tt>confdir</tt> directives in <tt>{{{ chrony_conf_path }}}</tt>.
When using <tt>sourcedir</tt>, create <tt>.sources</tt> files in the specified directory:
<pre># In {{{ chrony_conf_path }}}:
sourcedir /etc/chrony/sources.d
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the remediations namely Ansible remediation should be improved so that they would remove problematic items from files in sourcedir or confdir.

@github-actions
Copy link

github-actions bot commented Dec 15, 2025

ATEX Test Results

Test artifacts have been submitted to Testing Farm.

Results: View Test Results
Workflow Run: View Workflow Details

This comment was automatically generated by the ATEX workflow.


# Create conf.d directory and file
mkdir -p /etc/chrony/conf.d
echo "pool 1.pool.ntp.org" > /etc/chrony/conf.d/ntp-servers.conf
Copy link
Contributor

@Arden97 Arden97 Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, that a good practice for writing tests for such rules would be to remove configuration entries from configs (including sub directories) that are unrelated to the current test. For example, clearing the content of /etc/chrony/conf.d before writing pool entry into the file will ensure that test is passing because pool entry exist in this particular file and not because it found similar entry somewhere else in the chrony_conf_path or /etc/chrony/conf.d.

@openshift-ci
Copy link

openshift-ci bot commented Dec 18, 2025

@vojtapolasek: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-openshift-node-compliance cd70d32 link true /test e2e-aws-openshift-node-compliance

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

Copy link
Contributor

@Arden97 Arden97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated chronyd_specify_remote_server tests to remove configuration entries from configs (including subdirectories) that are unrelated to the current test (more information is in my comment). All of these tests are passing on local environment.

I've also updated the Ansible remediation to align with CIS and to be capable of being executed standalone. The failing tests are not caused by any code changes but rather infrastructure problems. Overall, I think this PR is ready for merge.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the changes and I have run automatus test locally with both Bash and Ansible remediations.

@jan-cerny jan-cerny merged commit 76fc535 into ComplianceAsCode:master Dec 19, 2025
139 of 142 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CIS CIS Benchmark related. Update Rule Issues or pull requests related to Rules updates.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants