Skip to content

CMP-4479: Fix manual remediation script discovery for rules with dashes/underscores#80

Open
vickeybrown wants to merge 1 commit into
ComplianceAsCode:mainfrom
vickeybrown:fix-manual-remediation-rule-matching-clean
Open

CMP-4479: Fix manual remediation script discovery for rules with dashes/underscores#80
vickeybrown wants to merge 1 commit into
ComplianceAsCode:mainfrom
vickeybrown:fix-manual-remediation-rule-matching-clean

Conversation

@vickeybrown

Copy link
Copy Markdown

Problem

Manual remediation scripts were not being discovered and executed for rules
like:

  • ocp4-cis-idp-is-configured
  • ocp4-cis-audit-log-forwarding-enabled

This caused CI test failures where these rules were expected to PASS after
remediation but remained FAIL because the remediation scripts never ran.

Root Cause

The convertRuleNameToRegex() function had a bug in its logic:

  1. It called regexp.QuoteMeta(ruleName) first to escape special regex
    characters
  2. Then tried to replace - and _ with [-_] to match both dashes and
    underscores

The problem: regexp.QuoteMeta() does NOT escape - or _ because they are not
regex metacharacters outside of character classes. So the string replacements
looking for - and _ found nothing and did nothing.

Solution

Rewrote convertRuleNameToRegex() to build the pattern character-by-character:

  • For - or _ characters → insert [-_] to match either
  • For other characters → escape individually with QuoteMeta()

@openshift-ci

openshift-ci Bot commented Jul 7, 2026

Copy link
Copy Markdown

Hi @vickeybrown. 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.

@vickeybrown vickeybrown marked this pull request as ready for review July 7, 2026 13:58
@Anna-Koudelkova

Copy link
Copy Markdown
Collaborator

/ok-to-test

@openshift-ci

openshift-ci Bot commented Jul 7, 2026

Copy link
Copy Markdown

@vickeybrown: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ocp4-stig 7592006 link true /test e2e-aws-ocp4-stig
ci/prow/e2e-aws-rhcos4-moderate 7592006 link true /test e2e-aws-rhcos4-moderate
ci/prow/e2e-aws-openshift-node-compliance 7592006 link true /test e2e-aws-openshift-node-compliance
ci/prow/e2e-aws-openshift-platform-compliance 7592006 link true /test e2e-aws-openshift-platform-compliance
ci/prow/e2e-aws-ocp4-cis 7592006 link true /test e2e-aws-ocp4-cis

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants