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

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
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