mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
gsb now saves the base url in tx.1 when match a full url
This commit is contained in:
parent
0c81610818
commit
8642c01344
@ -192,15 +192,16 @@ int convert_to_int(const char c)
|
||||
return n;
|
||||
}
|
||||
|
||||
/* \brief Set a match to tx.0
|
||||
/* \brief Set a match to tx.N
|
||||
*
|
||||
* \param msr
|
||||
* \param capture
|
||||
* \param match
|
||||
* \param msr Pointer to modsec resource
|
||||
* \param capture If ON match will be saved
|
||||
* \param match Pointer to captured string
|
||||
*\parm tx_n The tx number to save the data
|
||||
*
|
||||
* \retval 0 On Sucess|Fail
|
||||
*/
|
||||
int set_match_to_tx(modsec_rec *msr, int capture, const char *match) {
|
||||
int set_match_to_tx(modsec_rec *msr, int capture, const char *match, int tx_n) {
|
||||
|
||||
if (capture) {
|
||||
int i;
|
||||
@ -208,7 +209,7 @@ int set_match_to_tx(modsec_rec *msr, int capture, const char *match) {
|
||||
|
||||
if (s == NULL) return -1;
|
||||
|
||||
s->name = "0";
|
||||
s->name = apr_psprintf(msr->mp,"%d", tx_n);
|
||||
s->name_len = strlen(s->name);
|
||||
s->value = apr_pstrdup(msr->mp, match);
|
||||
if (s->value == NULL) return -1;
|
||||
@ -216,16 +217,17 @@ int set_match_to_tx(modsec_rec *msr, int capture, const char *match) {
|
||||
apr_table_setn(msr->tx_vars, s->name, (void *)s);
|
||||
|
||||
if (msr->txcfg->debuglog_level >= 9) {
|
||||
msr_log(msr, 9, "Added phrase match to TX.0: %s",
|
||||
log_escape_nq_ex(msr->mp, s->value, s->value_len));
|
||||
msr_log(msr, 9, "Added phrase match to TX.%d: %s",
|
||||
tx_n, log_escape_nq_ex(msr->mp, s->value, s->value_len));
|
||||
}
|
||||
|
||||
/* Unset the remaining ones (from previous invocations). */
|
||||
for(i = 1; i <= 9; i++) {
|
||||
/*
|
||||
for(i = 0; i <= 9; i++) {
|
||||
char buf[2];
|
||||
apr_snprintf(buf, sizeof(buf), "%d", i);
|
||||
apr_table_unset(msr->tx_vars, buf);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -92,7 +92,7 @@ int DSOLOCAL decode_base64_ext(char *plain_text, const char *input, int input_le
|
||||
|
||||
int DSOLOCAL convert_to_int(const char c);
|
||||
|
||||
int DSOLOCAL set_match_to_tx(modsec_rec *msr, int capture, const char *match);
|
||||
int DSOLOCAL set_match_to_tx(modsec_rec *msr, int capture, const char *match, int tx_n);
|
||||
|
||||
int DSOLOCAL js_decode_nonstrict_inplace(unsigned char *input, long int input_len);
|
||||
|
||||
|
@ -1429,11 +1429,18 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
|
||||
ret = verify_gsb(gsb, rule, match, match_length);
|
||||
|
||||
if(ret > 0) {
|
||||
set_match_to_tx(msr, capture, match);
|
||||
set_match_to_tx(msr, capture, match, 0);
|
||||
if (! *error_msg) {
|
||||
*error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
|
||||
log_escape_nq(msr->mp, match));
|
||||
}
|
||||
|
||||
str = apr_pstrdup(rule->ruleset->mp,match);
|
||||
|
||||
base = apr_strtok(str,"/",&savedptr);
|
||||
if(base != NULL)
|
||||
set_match_to_tx(msr, capture, base, 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1451,11 +1458,18 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
|
||||
ret = verify_gsb(gsb, rule, canon, canon_length);
|
||||
|
||||
if(ret > 0) {
|
||||
set_match_to_tx(msr, capture, match);
|
||||
set_match_to_tx(msr, capture, match, 0);
|
||||
if (! *error_msg) {
|
||||
*error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
|
||||
log_escape_nq(msr->mp, canon));
|
||||
}
|
||||
|
||||
str = apr_pstrdup(rule->ruleset->mp,match);
|
||||
|
||||
base = apr_strtok(str,"/",&savedptr);
|
||||
if(base != NULL)
|
||||
set_match_to_tx(msr, capture, base, 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1482,7 +1496,7 @@ static int msre_op_gsbLookup_execute(modsec_rec *msr, msre_rule *rule, msre_var
|
||||
ret = verify_gsb(gsb, rule, canon, canon_length);
|
||||
|
||||
if(ret > 0) {
|
||||
set_match_to_tx(msr, capture, canon);
|
||||
set_match_to_tx(msr, capture, canon, 0);
|
||||
if (! *error_msg) {
|
||||
*error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
|
||||
log_escape_nq(msr->mp, canon));
|
||||
|
Loading…
x
Reference in New Issue
Block a user