forked from ComplianceAsCode/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ComplianceAsCode#11441 from jan-cerny/RHEL-1314
Add new rule file_cron_allow_exists
- Loading branch information
Showing
11 changed files
with
67 additions
and
5 deletions.
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
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
45 changes: 45 additions & 0 deletions
45
linux_os/guide/services/cron_and_at/restrict_at_cron_users/file_cron_allow_exists/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,45 @@ | ||
documentation_complete: true | ||
|
||
prodtype: rhel7,rhel8,rhel9 | ||
|
||
title: Ensure that /etc/cron.allow exists | ||
|
||
description: |- | ||
The file <tt>/etc/cron.allow</tt> should exist and should be used instead | ||
of <tt>/etc/cron.deny</tt>. | ||
rationale: |- | ||
Access to <tt>crontab</tt> should be restricted. | ||
It is easier to manage an allow list than a deny list. | ||
Therefore, <tt>/etc/cron.allow</tt> needs to be created and used instead of <tt>/etc/cron.deny</tt>. | ||
Regardless of the existence of any of these files, the root administrative user is always allowed to setup a crontab. | ||
severity: medium | ||
|
||
identifiers: | ||
cce@rhel7: CCE-86183-1 | ||
cce@rhel8: CCE-86184-9 | ||
cce@rhel9: CCE-86185-6 | ||
|
||
references: | ||
cis@rhel7: 5.1.8 | ||
cis@rhel8: 5.1.8 | ||
cis@rhel9: 5.1.8 | ||
|
||
ocil_clause: 'the file /etc/cron.allow does not exist' | ||
|
||
ocil: |- | ||
The file <tt>/etc/cron.allow</tt> should exist. | ||
This can be checked by running the following command: | ||
<pre> | ||
stat /etc/cron.allow | ||
</pre> | ||
and the output should list the file. | ||
template: | ||
name: file_existence | ||
vars: | ||
filepath: /etc/cron.allow | ||
exists: true | ||
fileuid: "0" | ||
filemode: "0600" |
2 changes: 2 additions & 0 deletions
2
...uide/services/cron_and_at/restrict_at_cron_users/file_cron_allow_exists/tests/dne.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,2 @@ | ||
#!/bin/bash | ||
rm -rf /etc/cron.allow |
2 changes: 2 additions & 0 deletions
2
...e/services/cron_and_at/restrict_at_cron_users/file_cron_allow_exists/tests/exists.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,2 @@ | ||
#!/bin/bash | ||
touch /etc/cron.allow |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_all | ||
# reboot = false | ||
# strategy = disable | ||
# complexity = low | ||
# disruption = low | ||
|
||
|
||
{{% if not EXISTS %}} | ||
if [[ -f {{{ FILEPATH }}} ]]; then | ||
rm {{{ FILEPATH }}} | ||
fi | ||
{{% else %}} | ||
touch {{{ FILEPATH }}} | ||
{{%- if FILEUID %}} | ||
chown {{{ FILEUID }}} {{{ FILEPATH }}} | ||
{{%- endif %}} | ||
{{%- if FILEMODE %}} | ||
chmod {{{ FILEMODE }}} {{{ FILEPATH }}} | ||
{{%- endif %}} | ||
{{% endif %}} |