CMP-4479: Fix manual remediation script discovery for rules with dashes/underscores#80
Conversation
|
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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
|
@vickeybrown: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Problem
Manual remediation scripts were not being discovered and executed for rules
like:
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:
characters
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: