digitalwave / msc_pyparser

A ModSecurity rules parser
GNU General Public License v3.0
26 stars 9 forks source link

Counter variables without "variable part" are missing quote type #17

Closed theseion closed 2 years ago

theseion commented 2 years ago

A line with a "naked" counter (&ARGS) will not have it's quote type set (it should be no_quote. The quote type is being set correctly, when the variable has a "variable part", e.g. &ARGS:lisa.

Example:

import msc_pyparser
mparser = msc_pyparser.MSCParser()
mparser.parser.parse('SecRule &ARGS "@rx foo" "id:12"', debug = False)
print(mparser.configlines)

Output:

[{'type': 'SecRule', 'lineno': 1, 'variables': [{'variable': 'ARGS', 'variable_part': '', 'quote_type': '', 'negated': False, 'counter': True}], 'operator': '@rx', 'operator_argument': 'foo', 'actions': [{'act_name': 'id', 'lineno': 1, 'act_quote': 'no_quote', 'act_arg': '12', 'act_arg_val': '', 'act_arg_val_param': '', 'act_arg_val_param_val': ''}], 'chained': False, 'operator_negated': False, 'oplineno': 1}]
airween commented 2 years ago

Hi @theseion,

thanks for the report. Can you check first the 84b4e0? If it's right, I'll make a new release with version v1.1.2.

theseion commented 2 years ago

That works! Thanks a lot!

airween commented 2 years ago

Thanks, I'm going to close this issue and make a new release.

Thanks again Max!