Skip to content

file_ownerships_var_log: handle systems without a syslog user - #15118

Merged
jan-cerny merged 2 commits into
ComplianceAsCode:masterfrom
israel-villar:fix/var-log-ownership-without-syslog-user
Sep 16, 2026
Merged

jan-cerny merged 2 commits into
ComplianceAsCode:masterfrom
israel-villar:fix/var-log-ownership-without-syslog-user

Conversation

@israel-villar

Copy link
Copy Markdown
Contributor

Description:

  • Split the OVAL criteria of file_ownerships_var_log into two branches:
    • a dedicated syslog user exists → require owner root or syslog (unchanged behaviour);
    • no syslog user → require owner root only.
  • The syslog uid local_variable is now only referenced in the branch where it is guaranteed to have a value. Definition version bumped to 2.

Rationale:

  • On systems that use syslog-ng instead of rsyslog there is no dedicated syslog user, so the local_variable that reads its uid from /etc/passwd has no value.
  • An OVAL state that references a variable with no values evaluates to error. As a result, on such a system any non-root-owned file under /var/log made the whole rule report error instead of a meaningful pass/fail.

Review Hints:

  • OVAL-only change in file_ownerships_var_log/oval/shared.xml.
  • ./build_product debian13 rhel9 ubuntu2404 sle15 --datastream, ctest and OVAL schema validation pass.
  • Verified on a Debian 13 + syslog-ng host: the rule changes from error to a real fail/pass.

The OVAL read the syslog uid from /etc/passwd into a local_variable and
compared every /var/log file's owner against it. On systems that use
syslog-ng instead of rsyslog there is no 'syslog' user, so the variable
had no value and any non-root-owned file made the whole check evaluate to
'error' instead of a real pass/fail.

Split the criteria: when a dedicated syslog user exists, require owner
root or syslog (unchanged); when it does not, require owner root only.
The syslog uid variable is now only evaluated in the branch where it has
a value.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015YN4ez6hrFpegisiLLo3zx
@openshift-ci openshift-ci Bot added the needs-ok-to-test Used by openshift-ci bot. label Sep 10, 2026
@openshift-ci

openshift-ci Bot commented Sep 10, 2026

Copy link
Copy Markdown

Hi @israel-villar. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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-sigs/prow repository.

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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

Click here to see the full diff
OVAL for rule 'xccdf_org.ssgproject.content_rule_file_ownerships_var_log' differs.
--- oval:ssg-file_ownerships_var_log:def:1
+++ oval:ssg-file_ownerships_var_log:def:1
@@ -1,2 +1,7 @@
+criteria OR
 criteria AND
+criterion oval:ssg-file_ownerships_var_log_test_syslog_user_present:tst:1
 criterion oval:ssg-test_file_ownership_var_log:tst:1
+criteria AND
+criterion oval:ssg-file_ownerships_var_log_test_syslog_user_absent:tst:1
+criterion oval:ssg-file_ownerships_var_log_test_file_ownership_var_log_root_only:tst:1

New data stream adds bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownerships_var_log'.

@jan-cerny jan-cerny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a tests scenario covering the new no-syslog situation?

…iation, enable on Debian

Add Automatus test scenarios covering the no-dedicated-syslog-user case
(e.g. syslog-ng instead of rsyslog), addressing jan-cerny's review
comment on PR ComplianceAsCode#15118.

While testing, the new fail scenario exposed a real bug in the bash
remediation: 'find ! -user syslog' fails outright (exit 1, no files
processed) when the 'syslog' user does not exist, so remediation
silently did nothing on such systems. Only add the '-user syslog'
exclusion to the find command when that user actually exists.

The bash remediation was also restricted to Ubuntu only, even though
the OVAL check already applies to Debian. The remediation logic is
generic (no Ubuntu-specific behavior), so extend it to
multi_platform_debian too -- fitting, since the no-syslog-user
(syslog-ng) case is more typical of Debian than Ubuntu. The two new
test scenarios are scoped to both platforms; the pre-existing
scenarios are left Ubuntu-only to keep this change focused.

Verified via Automatus (Docker):
- ubuntu2404: all 8 scenarios pass with bash remediation.
- debian13: the 2 new scenarios pass with bash remediation; the other
  6 are correctly skipped as not applicable (still Ubuntu-only).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ARJshBwZJW1AiYFotscgT
@israel-villar

Copy link
Copy Markdown
Contributor Author

Added the test scenarios for the no-syslog-user case. Testing them also surfaced a bug in the bash remediation (it broke when there's no syslog user) and showed the remediation could apply to Debian too, so I fixed both.

@jan-cerny jan-cerny self-assigned this Sep 16, 2026
@jan-cerny jan-cerny added this to the 0.1.83 milestone Sep 16, 2026
@jan-cerny
jan-cerny merged commit 7cf8163 into ComplianceAsCode:master Sep 16, 2026
61 of 62 checks passed
@israel-villar
israel-villar deleted the fix/var-log-ownership-without-syslog-user branch September 16, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants