Skip to content
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

NTP related rules for CIS on Ubuntu 20.04 and 22.04 #10344

Merged
merged 7 commits into from
Mar 24, 2023

Conversation

dodys
Copy link
Contributor

@dodys dodys commented Mar 21, 2023

Description:

  • This PR does a few things:
    • Add packagename@ubuntu2204 to service_timesyncd_enabled
    • Add platform: not package[chrony] and not package[ntp] to service_timesyncd_enabled
    • Add platform: package[ntp] to service_ntp_enabled
    • Alter platform to platform: package[chrony] in service_chrony_enabled. Let me know if this should be an and instead
    • Add ubuntu2004 platform to some ntp rules and fix cis references
    • Add ntp related rules to ubuntu2004 cis_level1_server profile
    • Make timesyncd the default ntp in ubuntu2204 cis_level1_server profile

Rationale:

  • This is needed for CIS

@dodys dodys requested a review from a team as a code owner March 21, 2023 10:33
@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

sle12 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@github-actions
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_service_chronyd_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_chronyd_enabled
+++ xccdf_org.ssgproject.content_rule_service_chronyd_enabled
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
+if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ] && { rpm --quiet -q chrony; }; then
 
 SYSTEMCTL_EXEC='/usr/bin/systemctl'
 "$SYSTEMCTL_EXEC" unmask 'chronyd.service'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_service_chronyd_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_chronyd_enabled
+++ xccdf_org.ssgproject.content_rule_service_chronyd_enabled
@@ -1,3 +1,14 @@
+- name: Gather the package facts
+ package_facts:
+ manager: auto
+ tags:
+ - enable_strategy
+ - low_complexity
+ - low_disruption
+ - medium_severity
+ - no_reboot_needed
+ - service_chronyd_enabled
+
 - name: Enable service chronyd
 block:
 
@@ -13,7 +24,9 @@
 masked: 'no'
 when:
 - '"chrony" in ansible_facts.packages'
- when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ when:
+ - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ - '"chrony" in ansible_facts.packages'
 tags:
 - enable_strategy
 - low_complexity

bash remediation for rule 'xccdf_org.ssgproject.content_rule_service_ntp_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_ntp_enabled
+++ xccdf_org.ssgproject.content_rule_service_ntp_enabled
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
+if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ] && { rpm --quiet -q ntp; }; then
 
 SYSTEMCTL_EXEC='/usr/bin/systemctl'
 "$SYSTEMCTL_EXEC" unmask 'ntp.service'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_service_ntp_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_ntp_enabled
+++ xccdf_org.ssgproject.content_rule_service_ntp_enabled
@@ -1,3 +1,18 @@
+- name: Gather the package facts
+ package_facts:
+ manager: auto
+ tags:
+ - CCE-91657-7
+ - NIST-800-53-AU-8(1)(a)
+ - NIST-800-53-CM-6(a)
+ - PCI-DSS-Req-10.4
+ - enable_strategy
+ - high_severity
+ - low_complexity
+ - low_disruption
+ - no_reboot_needed
+ - service_ntp_enabled
+
 - name: Enable service ntp
 block:
 
@@ -13,7 +28,9 @@
 masked: 'no'
 when:
 - '"ntp" in ansible_facts.packages'
- when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ when:
+ - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ - '"ntp" in ansible_facts.packages'
 tags:
 - CCE-91657-7
 - NIST-800-53-AU-8(1)(a)

bash remediation for rule 'xccdf_org.ssgproject.content_rule_service_timesyncd_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_timesyncd_enabled
+++ xccdf_org.ssgproject.content_rule_service_timesyncd_enabled
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
+if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ] && { ( ! ( rpm --quiet -q chrony ) && ! ( rpm --quiet -q ntp ) ); }; then
 
 SYSTEMCTL_EXEC='/usr/bin/systemctl'
 "$SYSTEMCTL_EXEC" unmask 'systemd-timesyncd.service'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_service_timesyncd_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_timesyncd_enabled
+++ xccdf_org.ssgproject.content_rule_service_timesyncd_enabled
@@ -1,3 +1,18 @@
+- name: Gather the package facts
+ package_facts:
+ manager: auto
+ tags:
+ - CCE-91659-3
+ - NIST-800-53-AU-8(1)(a)
+ - NIST-800-53-CM-6(a)
+ - PCI-DSS-Req-10.4
+ - enable_strategy
+ - high_severity
+ - low_complexity
+ - low_disruption
+ - no_reboot_needed
+ - service_timesyncd_enabled
+
 - name: Enable service systemd-timesyncd
 block:
 
@@ -13,7 +28,10 @@
 masked: 'no'
 when:
 - '"systemd" in ansible_facts.packages'
- when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ when:
+ - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ - ( not ( "chrony" in ansible_facts.packages ) and not ( "ntp" in ansible_facts.packages
+ ) )
 tags:
 - CCE-91659-3
 - NIST-800-53-AU-8(1)(a)

@codeclimate
Copy link

codeclimate bot commented Mar 21, 2023

Code Climate has analyzed commit af5be42 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 51.8% (0.0% change).

View more on Code Climate.

@Mab879 Mab879 added this to the 0.1.67 milestone Mar 21, 2023
@Mab879 Mab879 added Ubuntu Ubuntu product related. CIS CIS Benchmark related. labels Mar 21, 2023
@dodys
Copy link
Contributor Author

dodys commented Mar 23, 2023

/retest

1 similar comment
@dodys
Copy link
Contributor Author

dodys commented Mar 24, 2023

/retest

@openshift-ci
Copy link

openshift-ci bot commented Mar 24, 2023

@dodys: The following tests 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-rhcos4-high af5be42 link true /test e2e-aws-rhcos4-high
ci/prow/e2e-aws-rhcos4-moderate af5be42 link true /test e2e-aws-rhcos4-moderate

Full PR test history. Your PR dashboard.

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

@Mab879 Mab879 added Update Rule Issues or pull requests related to Rules updates. Update Profile Issues or pull requests related to Profiles updates. labels Mar 24, 2023
@Mab879 Mab879 self-assigned this Mar 24, 2023
Copy link
Member

@Mab879 Mab879 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Automatus failures are expected due to the prodtypes of the rules that where changed and the nature of NTP. Waving the CODEOWNERS as @dodys cannot merge his own PRs.

@Mab879 Mab879 merged commit 8571d41 into ComplianceAsCode:master Mar 24, 2023
@dodys dodys deleted the ntp branch April 17, 2023 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CIS CIS Benchmark related. Ubuntu Ubuntu product related. Update Profile Issues or pull requests related to Profiles updates. Update Rule Issues or pull requests related to Rules updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants