-
Notifications
You must be signed in to change notification settings - Fork 708
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
Ubuntu 24.04: Implement 2.3.1.1 Ensure a single time synchronization daemon is in use #12823
Merged
+179
−7
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
linux_os/guide/services/ntp/ntp_single_service_active/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<def-group> | ||
<!-- Check that exactly one time synchronization service is active --> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
{{{ oval_metadata("Ensure a Single Time Synchronization Service is in Use") }}} | ||
<criteria> | ||
<criterion comment="exactly one time synchronization service is active" | ||
test_ref="test_{{{ rule_id }}}_single_active_timesync"/> | ||
</criteria> | ||
</definition> | ||
|
||
<!-- Objects and states to identify active time synchronization services --> | ||
<linux:systemdunitproperty_object id="obj_{{{ rule_id }}}_timesync_services" version="1" | ||
comment="All active time synchronization services"> | ||
<linux:unit operation="pattern match">^(chrony|systemd-timesyncd).service$</linux:unit> | ||
<linux:property>ActiveState</linux:property> | ||
<filter action="include">ste_{{{ rule_id }}}_timesync_services</filter> | ||
</linux:systemdunitproperty_object> | ||
|
||
<linux:systemdunitproperty_state id="ste_{{{ rule_id }}}_timesync_services" version="1"> | ||
<linux:value>active</linux:value> | ||
</linux:systemdunitproperty_state> | ||
|
||
<!-- Count active time synchronization services --> | ||
<local_variable id="var_{{{ rule_id }}}_timesync_active_count" datatype="int" version="1" | ||
comment="Number of currently active time synchronization services"> | ||
<count> | ||
<regex_capture pattern="^active$"> | ||
<object_component item_field="value" object_ref="obj_{{{ rule_id }}}_timesync_services"/> | ||
</regex_capture> | ||
</count> | ||
</local_variable> | ||
|
||
<!-- Test that count equals one --> | ||
<ind:variable_test id="test_{{{ rule_id }}}_single_active_timesync" version="1" check="all" | ||
comment="Verify exactly one time synchronization service is active"> | ||
<ind:object object_ref="obj_{{{ rule_id }}}_count"/> | ||
<ind:state state_ref="ste_{{{ rule_id }}}_count"/> | ||
</ind:variable_test> | ||
|
||
<ind:variable_object id="obj_{{{ rule_id }}}_count" version="1"> | ||
<ind:var_ref>var_{{{ rule_id }}}_timesync_active_count</ind:var_ref> | ||
</ind:variable_object> | ||
|
||
<ind:variable_state id="ste_{{{ rule_id }}}_count" version="1"> | ||
<ind:value operation="equals" datatype="int">1</ind:value> | ||
</ind:variable_state> | ||
</def-group> |
33 changes: 33 additions & 0 deletions
33
linux_os/guide/services/ntp/ntp_single_service_active/rule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
documentation_complete: true | ||
|
||
title: 'Ensure a Single Time Synchronization Service is in Use' | ||
|
||
description: |- | ||
The system must have exactly one active time synchronization service to avoid conflicts | ||
and ensure consistent time synchronization. Only one of the following services should be | ||
enabled and active at any time: | ||
<ul> | ||
<li>chrony - A versatile NTP implementation</li> | ||
<li>systemd-timesyncd - A lightweight NTP client</li> | ||
</ul> | ||
Having zero active time synchronization services leaves the system without accurate | ||
time synchronization, while having multiple active services can lead to unexpected and | ||
unreliable results. | ||
|
||
rationale: |- | ||
Running multiple time synchronization services simultaneously can lead to conflicts | ||
in time synchronization, unpredictable behavior, and unreliable results. A single service | ||
ensures consistent and accurate time synchronization. | ||
|
||
Having no active time synchronization service leaves the system without accurate | ||
time synchronization, which can affect security mechanisms, log consistency, and forensic | ||
investigations. | ||
|
||
severity: medium | ||
|
||
platform: machine | ||
|
||
warnings: | ||
- general: |- | ||
This rule does not come with a remediation. There are specific rules | ||
for enabling each time synchronization service, which should be used instead. |
15 changes: 15 additions & 0 deletions
15
linux_os/guide/services/ntp/ntp_single_service_active/tests/multiple.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
# remediation = none | ||
|
||
{{{ bash_package_install("chrony") }}} | ||
{{{ bash_package_install("systemd-timesyncd") }}} | ||
|
||
systemctl stop chrony.service | ||
systemctl stop systemd-timesyncd.service | ||
systemctl disable chrony.service | ||
systemctl disable systemd-timesyncd.service | ||
|
||
systemctl start chrony.service | ||
systemctl start systemd-timesyncd.service | ||
systemctl enable chrony.service | ||
systemctl enable systemd-timesyncd.service |
10 changes: 10 additions & 0 deletions
10
linux_os/guide/services/ntp/ntp_single_service_active/tests/none.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
# remediation = none | ||
|
||
{{{ bash_package_install("chrony") }}} | ||
{{{ bash_package_install("systemd-timesyncd") }}} | ||
|
||
systemctl stop chrony.service | ||
systemctl stop systemd-timesyncd.service | ||
systemctl disable chrony.service | ||
systemctl disable systemd-timesyncd.service |
13 changes: 13 additions & 0 deletions
13
linux_os/guide/services/ntp/ntp_single_service_active/tests/single.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# remediation = none | ||
|
||
{{{ bash_package_install("chrony") }}} | ||
{{{ bash_package_install("systemd-timesyncd") }}} | ||
|
||
systemctl stop chrony.service | ||
systemctl stop systemd-timesyncd.service | ||
systemctl disable chrony.service | ||
systemctl disable systemd-timesyncd.service | ||
|
||
systemctl start chrony.service | ||
systemctl enable chrony.service |
23 changes: 23 additions & 0 deletions
23
linux_os/guide/services/ntp/service_chronyd_disabled/rule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
documentation_complete: true | ||
|
||
title: 'The Chronyd service is disabled' | ||
|
||
description: |- | ||
{{{ describe_service_disable(service="chrony") }}} | ||
|
||
rationale: |- | ||
Disabling the <tt>chrony</tt> service ensures that there is | ||
only single one time service running. | ||
|
||
severity: medium | ||
|
||
platform: package[chrony] | ||
|
||
template: | ||
name: service_disabled | ||
vars: | ||
packagename: chrony | ||
servicename: chronyd | ||
servicename@ubuntu2004: chrony | ||
servicename@ubuntu2204: chrony | ||
servicename@debian12: chrony |
25 changes: 25 additions & 0 deletions
25
linux_os/guide/services/ntp/service_timesyncd_disabled/rule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
documentation_complete: true | ||
|
||
|
||
title: 'Disable systemd_timesyncd Service' | ||
|
||
description: |- | ||
{{{ describe_service_disable(service="systemd_timesyncd") }}} | ||
|
||
rationale: |- | ||
Disabling the <tt>systemd_timesyncd</tt> service ensures that there is | ||
only single one time service running. | ||
<br /><br /> | ||
Additional information on Ubuntu network time protocol is | ||
available at | ||
{{{ weblink(link="https://ubuntu.com/server/docs/about-time-synchronisation") }}}. | ||
|
||
severity: medium | ||
|
||
platform: package[systemd-timesyncd] | ||
|
||
template: | ||
name: service_disabled | ||
vars: | ||
servicename: systemd-timesyncd | ||
packagename: systemd-timesyncd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This rule should not enforce any specific service.
It should only check whether the system has a single timesync service that is active,
analogous to https://github.com/ComplianceAsCode/content/pull/12822/files
In the profile we should enable only one service and disable the other
so this rule passes by default as you did here, but I think we should:
service_chrony_enabled/service_timesyncd_disabled
to 2.3.3.3service_timesyncd_enabled/service_chronyd_disabled
to 2.3.2.2 and disable them