mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Add quoting to unparsed rule generation.
This commit is contained in:
parent
cdcb3bdb14
commit
e357bb55af
@ -1286,6 +1286,7 @@ static const char *cmd_rule_inheritance(cmd_parms *cmd, void *_dcfg, int flag) {
|
||||
static const char *cmd_rule_script(cmd_parms *cmd, void *_dcfg, const char *p1,
|
||||
const char *p2)
|
||||
{
|
||||
// TODO Support script filenames relative to the configuration file.
|
||||
return add_rule(cmd, (directory_config *)_dcfg, RULE_TYPE_LUA, p1, p2, NULL);
|
||||
}
|
||||
#endif
|
||||
|
30
apache2/re.c
30
apache2/re.c
@ -1232,13 +1232,26 @@ msre_rule *msre_rule_create(msre_ruleset *ruleset,
|
||||
|
||||
/* Add the unparsed rule */
|
||||
if ((strcmp(SECACTION_TARGETS, targets) == 0) && (strcmp(SECACTION_ARGS, args) == 0)) {
|
||||
rule->unparsed = apr_pstrcat(ruleset->mp, "SecAction", " \"", actions, "\"", NULL);
|
||||
rule->unparsed = apr_psprintf(ruleset->mp, "SecAction \"%s\"",
|
||||
log_escape(ruleset->mp, actions));
|
||||
}
|
||||
else if ((strcmp(SECMARKER_TARGETS, targets) == 0) && (strcmp(SECMARKER_ARGS, args) == 0) && (strncmp(SECMARKER_BASE_ACTIONS, actions, strlen(SECMARKER_BASE_ACTIONS)) == 0)) {
|
||||
rule->unparsed = apr_pstrcat(ruleset->mp, "SecMarker", " \"", (actions + strlen(SECMARKER_BASE_ACTIONS)), "\"", NULL);
|
||||
else
|
||||
if ((strcmp(SECMARKER_TARGETS, targets) == 0)
|
||||
&& (strcmp(SECMARKER_ARGS, args) == 0)
|
||||
&& (strncmp(SECMARKER_BASE_ACTIONS, actions, strlen(SECMARKER_BASE_ACTIONS)) == 0))
|
||||
{
|
||||
rule->unparsed = apr_psprintf(ruleset->mp, "SecMarker \"%s\"",
|
||||
log_escape(ruleset->mp, actions + strlen(SECMARKER_BASE_ACTIONS)));
|
||||
}
|
||||
else {
|
||||
rule->unparsed = apr_pstrcat(ruleset->mp, "SecRule", " \"", targets, "\" \"", args, "\"", (actions != NULL ? " \"" : ""), (actions != NULL ? actions : ""), (actions != NULL ? "\"" : ""), NULL);
|
||||
if (actions == NULL) {
|
||||
rule->unparsed = apr_psprintf(ruleset->mp, "SecRule \"%s\" \"%s\"",
|
||||
log_escape(ruleset->mp, targets), log_escape(ruleset->mp, args));
|
||||
} else {
|
||||
rule->unparsed = apr_psprintf(ruleset->mp, "SecRule \"%s\" \"%s\" \"%s\"",
|
||||
log_escape(ruleset->mp, targets), log_escape(ruleset->mp, args),
|
||||
log_escape(ruleset->mp, actions));
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse targets */
|
||||
@ -1323,8 +1336,13 @@ msre_rule *msre_rule_lua_create(msre_ruleset *ruleset,
|
||||
|
||||
rule->type = RULE_TYPE_LUA;
|
||||
|
||||
rule->unparsed = apr_pstrcat(ruleset->mp, "SecRuleScript ", script_filename,
|
||||
(actions != NULL ? " ACTIONS" : ""), NULL);
|
||||
if (actions == NULL) {
|
||||
rule->unparsed = apr_psprintf(ruleset->mp, "SecRuleScript \"%s\"",
|
||||
script_filename);
|
||||
} else {
|
||||
rule->unparsed = apr_psprintf(ruleset->mp, "SecRuleScript \"%s\" \"%s\"",
|
||||
script_filename, log_escape(ruleset->mp, actions));
|
||||
}
|
||||
|
||||
/* Compile script. */
|
||||
*error_msg = lua_compile(&rule->script, script_filename, ruleset->mp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user