Hi all,
(sorry for the cross posting)
let me announce the msc_pyparser tool, a ModSecurity ruleset parser. msc_pyparser can made a full lexical and syntactic analisys on the rules (currently it tested only on CRS and some custom rules). Note, that msc_pyparser supports only four MSC keyword (and the comments) - see the docs.
Beyond these abilities, msc_pyparser builds an AST (abstract syntax tree), and made an own structure in memory - especially a list of dictionaries. Every dict item stores several datas about the recognized token, including number of line.
You can dump this structure (eg. JSON, YAML - or SQL), or can make any contextual depend modification. After this, you can save back the modified version to the original ModSecurity format.
There are some usefull examples in source.
I think this tool can helps you to maintain your rulesets, eg. merge with custom modifications, formatting, or - as above - make any context dependent changes. Please review the examples directory.
If you have any question, issue, bugreport or other feedback, please contact me at the given e-mail address in README, or open an issue on Github (do not disturb this list).
The tool available here:
https://github.com/digitalwave/msc_pyparsera.