Skip to content

Conversation

@Arden97
Copy link
Contributor

@Arden97 Arden97 commented Oct 29, 2025

Description:

  • This pull request enhances the OVAL check for rsyslog remote logging configuration to properly detect RainerScript action() statements that span multiple lines
  • The regex pattern rsyslog_remote_loghost_rainer_regex now includes the s flag (dotall mode), which allows the . metacharacter to match newline characters
  • This enables the pattern to match RainerScript action() configurations where parameters are split across multiple lines for readability, which is a common formatting practice in rsyslog configurations
  • Added a new test case remote_configured_rainer_newline.pass.sh that validates detection of multiline RainerScript action configurations

Rationale:

  • The previous regex pattern with only the (?m) (multiline) flag could match patterns where ^ and $ anchors work across lines, but the .* portions could not span newlines

  • Fixes # RHEL-104207

Review Hints:

  • use automatus to verify, that remote_configured_rainer_multiline test is passing
  • use automatus to test following rules (both bash and ansible remediations):
    • rsyslog_remote_loghost
    • rsyslog_remote_tls
    • rsyslog_cron_logging
    • rsyslog_encrypt_offload_actionsendstreamdriverauthmode
    • rsyslog_encrypt_offload_actionsendstreamdrivermode
    • rsyslog_encrypt_offload_defaultnetstreamdriver

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Oct 29, 2025
@openshift-ci
Copy link

openshift-ci bot commented Oct 29, 2025

Hi @Arden97. Thanks for your PR.

I'm waiting for a github.com 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. Regular contributors should join the org to skip this step.

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.

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.

@Arden97 Arden97 changed the title Add multiline support for RainerScript action detection in rsysslog_remote_loghost rule Add multiline support for RainerScript action detection in rsyslog_remote_loghost rule Oct 29, 2025
@jan-cerny jan-cerny added the bugfix Fixes to reported bugs. label Oct 30, 2025
Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

It looks fine. The automatus test scenarios pass locally for me.

Two things that came to my mind:

  1. Please check if there aren't any other similar rules that would need the same modification. I know that there are multiple rules for rsyslog configuration in the project and they might suffer from the same problem.

  2. Consider creating another test scenario that would create the same configuration file as the example of the configuration file the reporter of the bug provided in the Jira ticket. I think that would be a good regression test.

@jan-cerny jan-cerny added this to the 0.1.79 milestone Oct 30, 2025
@jan-cerny jan-cerny self-assigned this Oct 30, 2025
@Arden97
Copy link
Contributor Author

Arden97 commented Nov 5, 2025

OVAL checks and tests of the following rules were updated to support both legacy and RainerScript syntax (multi-line included):

  • rsyslog_cron_logging
  • rsyslog_encrypt_offload_actionsendstreamdriverauthmode
  • rsyslog_encrypt_offload_actionsendstreamdrivermode
  • rsyslog_encrypt_offload_defaultnetstreamdriver

@Arden97 Arden97 marked this pull request as draft November 5, 2025 09:28
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Nov 5, 2025
@Arden97
Copy link
Contributor Author

Arden97 commented Nov 5, 2025

Testing scenario remote_configured_rainer_multiline_azuremonitoragent for rsyslog_remote_loghost rule was created. It specifically tests the case described in RHEL-104207.



{{#
This macro sets up the rsyslog environment for testing rsyslog_encrypt_offload_actionsendstreamdriverauthmode rule.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to put macros like this to shared/macros/20-test-scenarios.jinja.

{{%- endmacro -%}}


{{%- macro setup_rsyslog_encrypt_offload_actionsendstreamdriverauthmode() -%}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Undocumented macro

It ensures the rsyslog directory structure and rsyslog conf file exist, then removes any existing
multilined and legacy format entries.
#}}
{{%- macro setup_rsyslog_cron_logging () -%}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

coding style

else
echo "$LOGHOST_LINE" >> "$CONF_FILE"
fi
{{{ setup_rsyslog_remote_loghost("*.* @@192.168.122.1:5000") }}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing end of file

@@ -0,0 +1,27 @@
#!/bin/bash
# packages = rsyslog

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# This TS is a regression test of https://issues.redhat.com/browse/RHEL-104207.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

@Arden97 So far looks good. Do you plan to make the PR as ready for a review or is there anything else that you plan to do?

@Arden97
Copy link
Contributor Author

Arden97 commented Nov 7, 2025

@Arden97 So far looks good. Do you plan to make the PR as ready for a review or is there anything else that you plan to do?

I'm currently working on updating ansible remediations for changed ensure_rsyslog_log_file_configuration rules. Will make this PR ready for review later today

@Arden97 Arden97 force-pushed the scap_rainerscript_format branch from 49e6850 to c16d5b2 Compare November 7, 2025 19:52
@Arden97 Arden97 marked this pull request as ready for review November 7, 2025 21:06
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes to reported bugs. needs-ok-to-test Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants