Proposal: Support multiple rule instances from template rules - #96
Conversation
…fferent configurations - Add templateRuleKey to rule definition config - Add custom CLI objects to handle custom rules based on templates
|
Hi @felipebz, thanks for maintaining this project and for your ongoing work on zpa-cli 👍 We’re currently looking into integrating zpa-cli into our CI/CD pipelines, and this change would be really valuable for us. Supporting multiple regex rules based on the regex-template-rule would allow us to define several rules instead of being limited to a single regex rule today. Would you mind taking a look at this PR when you have a moment? It would help us a lot in moving forward with the integration. Thanks again for your work and support! |
|
Hi @TimoWiddauCC and @AndreasIgelCC, I'm really sorry for the very long delay here, and thank you both for your patience. I finally had the time to properly review the PR. The approach looks good, and keeping the implementation contained in zpa-cli is a nice fit for the current architecture. Thank you for taking the time to implement this and contribute it back to the project. Thanks again, and apologies once more for making you wait so long. |
|
Hi @felipebz, |
Issue
Currently, the ZPA CLI configuration supports configuration of a single instance for a rule only. The configuration key also needs to match the rule name for detection (related: #89). This limitation prevents users from defining multiple instances of the same rule with different configurations like for XPath rules.
Proposed solution
This PR introduces the
templateRuleKeyfield in the CLI configuration file. This allows users to create multiple rule instances from a single template rule with different parameters. This enables support for multiple rules with different configuration. The implementation is written to avoid changes to zpa-core. If zpa-core would be extended, some code here could be de-duplicated / removed again.Example
Users can now configure rule instances from a template like this:
{ "rules": { "CustomXPath_SelectStar": { "level": "minor", "templateRuleKey": "XPath", "parameters": { "xpathQuery": "//SELECT_COLUMN/MULTIPLICATION", "message": "SELECT * used in query" } }, "CustomXPath_SelectStar_SecondRule": { "level": "minor", "templateRuleKey": "zpa:XPath", "parameters": { "xpathQuery": "//SELECT_COLUMN/MULTIPLICATION", "message": "SELECT * used in query - second rule" } } } }