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

Improve rule file_permssions_crontab #12652

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

jan-cerny
Copy link
Collaborator

@jan-cerny jan-cerny commented Nov 29, 2024

This change solves problem of failing rule file_permissions_crontab
when the crontabs RPM package isn't installed. This situation happens
namely when builidng a CS9 bootable container image because the
base image doesn't contain the crontabs RPM package.

In profiles which contain rules checking permissions on files that are
provided by crontabs, we will install the crontabs package by
installing the cronie package which provides the cron service and
has crontabs as dependency. This will be achieved by adding the rule
package_cron_installed to these profiles.

Notice that the cronie package will be installed as a result of rule
package_cron_installed which installs either cron or cronie
based on the product name. This rule is fixed by this commit because
the correct package name for RHEL 9 is cronie as well.

Review Hints:

Build and boot a CS 9 bootable container image hardened with STIG profile. Then, run a verification scan of the running VM.

@jan-cerny jan-cerny added CIS CIS Benchmark related. STIG STIG Benchmark related. Image Mode Bootable containers and Image Mode RHEL labels Nov 29, 2024
@jan-cerny jan-cerny added this to the 0.1.76 milestone Nov 29, 2024
@jan-cerny jan-cerny requested a review from a team as a code owner November 29, 2024 12:22
Copy link

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

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

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@jan-cerny jan-cerny force-pushed the file_permissions_crontabs branch from 7c79e12 to ee51ec7 Compare November 29, 2024 13:10
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.

The changes look good other than the STIG changes.

@@ -958,6 +958,7 @@ controls:
- medium
title: RHEL 9 cron configuration directories must have a mode of 0700 or less permissive.
rules:
- package_crontabs_installed
Copy link
Member

Choose a reason for hiding this comment

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

This isn't in the STIG. Why should be added?

See https://stigaview.com/products/rhel9/v2r2/RHEL-09-232040/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! I have changed the PR to add package_cron_installed instead.

@Mab879 Mab879 self-assigned this Dec 2, 2024
This change solves problem of failing rule `file_permissions_crontab`
when the `crontabs` RPM package isn't installed. This situation happens
namely when builidng a CS9 bootable container image because the
base image doesn't contain the crontabs RPM package.

In profiles which contain rules checking permissions on files that are
provided by `crontabs`, we will install the `crontabs` package by
installing the `cronie` package which provides the `cron` service and
has `crontabs` as dependency. This will be achieved by adding the rule
`package_cron_installed` to these profiles.

Notice that the `cronie` package will be installed as a result of rule
`package_cron_installed` which installs either `cron` or `cronie`
based on the product name. This rule is fixed by this commit because
the correct package name for RHEL 9 is `cronie` as well.
@jan-cerny jan-cerny force-pushed the file_permissions_crontabs branch from ee51ec7 to c8d0381 Compare December 3, 2024 09:12
@jan-cerny
Copy link
Collaborator Author

I have removed the new rule from this PR. I have changed the PR to add package_cron_installed instead.

I have rebased this PR on the top of the latest upstream master branch.

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.

I still have question on the STIG change.

controls/stig_rhel9.yml Show resolved Hide resolved
Copy link

github-actions bot commented Dec 4, 2024

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
New content has different text for rule 'xccdf_org.ssgproject.content_rule_package_cron_installed'.
--- xccdf_org.ssgproject.content_rule_package_cron_installed
+++ xccdf_org.ssgproject.content_rule_package_cron_installed
@@ -39,6 +39,9 @@
 DSS06.06
 
 [reference]:
+CCI-000366
+
+[reference]:
 164.308(a)(4)(i)
 
 [reference]:
@@ -217,6 +220,9 @@
 
 [reference]:
 PR.PT-3
+
+[reference]:
+SRG-OS-000480-GPOS-00227
 
 [rationale]:
 The cron service allow periodic job execution, needed for almost all administrative tasks and services (software update, log rotating, etc.). Access to cron service should be restricted to administrative accounts only.

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.

The CI failures look valid.

Copy link

codeclimate bot commented Dec 5, 2024

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

View more on Code Climate.

@Mab879
Copy link
Member

Mab879 commented Dec 10, 2024

Waving Automatus tests since they are not applicable to containers.

@Mab879 Mab879 merged commit b3b1560 into ComplianceAsCode:master Dec 10, 2024
102 of 105 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. Image Mode Bootable containers and Image Mode RHEL STIG STIG Benchmark related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants