Skip to content

Conversation

@LaibaBareera
Copy link
Collaborator

Summary
This PR fixes test expectations and handling for several CIS checks to improve accuracy and reduce false failures.

Changes

  • Check 2.2.18: Replace hyphen with underscore in the expected test string.
  • Check 4.1.1: When “package iptables is not installed” is detected, set the check value to false instead of true.
  • Checks 5.1.2 – 5.1.7: Treat checks as pass if the referenced file does not exist.

Rationale

  • Aligns test expectations with actual output formatting.
  • Prevents incorrect passing when iptables is missing.
  • Ensures file-based controls don’t fail when the target file is legitimately absent.

Results:
Check 2.2.18
Screenshot 2026-01-05 at 3 45 34 PM

Check 4.1.1
Screenshot 2026-01-05 at 3 47 15 PM

Check 5.1.2-5.1.7
Screenshot 2026-01-05 at 3 49 35 PM

Comment on lines 2298 to 2300
CRON_DAILY="/etc/cron.daily"
if [ ! -f "$CRON_DAILY" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIUC /etc/cron.daily is a folder. maybe I miss something
so do we need to use -d flag here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No it is file, I have checked it

Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, it's a bit strange:

$ docker run -it ubuntu:latest
root@d5af9ad306bf:/# ls -l /etc/ | grep cron
drwxr-xr-x 2 root root    4096 Sep 10 02:20 cron.d
drwxr-xr-x 2 root root    4096 Sep 10 02:20 cron.daily
root@d5af9ad306bf:/# ls /etc/cron.daily/
apt-compat  dpkg

if [ ! -f "$CRON_DAILY" ]; then
echo "cron_daily_missing"
elif stat -L "$CRON_DAILY" | grep -qE 'Access:\s+\(0700/drwx------\)\s+Uid:\s+\(\s*0/\s*root\)\s+Gid:\s+\(\s*0/\s*root\)'; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe is it make sense to convert permission checks to the numeric stat -Lc style used in 5.1.5–5.1.7 for consistency?

@afdesk afdesk self-requested a review January 9, 2026 13:08
if [ ! -f "$CRON_HOURLY" ]; then
echo "cron_hourly_missing"
elif stat -L "$CRON_HOURLY" | grep -qE 'Access:\s+\(0700/drwx------\)\s+Uid:\s+\(\s*0/\s*root\)\s+Gid:\s+\(\s*0/\s*root\)'; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

echo "cron_weekly_permission_ok"
CRON_WEEKLY="/etc/cron.weekly"
if [ ! -f "$CRON_WEEKLY" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

Comment on lines 2298 to 2300
CRON_DAILY="/etc/cron.daily"
if [ ! -f "$CRON_DAILY" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, it's a bit strange:

$ docker run -it ubuntu:latest
root@d5af9ad306bf:/# ls -l /etc/ | grep cron
drwxr-xr-x 2 root root    4096 Sep 10 02:20 cron.d
drwxr-xr-x 2 root root    4096 Sep 10 02:20 cron.daily
root@d5af9ad306bf:/# ls /etc/cron.daily/
apt-compat  dpkg

@afdesk afdesk merged commit dd376ac into main Jan 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants