Skip to content

Commit b6e061e

Browse files
author
Felipe Zimmerle
committed
FuzzyHash: if disable giving an run time error instead of config
FuzzyHash operator is optional and only installed if the headers for libfuzzy was found in the system. Otherwise, the FuzzyHash operator is disable during the compilation. After this commit, if some rules tries to use it, ModSecurity will produce an runtime error not a config time error, allowing the web server to procede normal with its operations.
1 parent e5aea89 commit b6e061e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

apache2/re_operators.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,12 +3789,9 @@ static int msre_op_fuzzy_hash_init(msre_rule *rule, char **error_msg)
37893789

37903790
rule->op_param_data = param_data;
37913791
#else
3792-
*error_msg = apr_psprintf(rule->ruleset->mp, "ModSecurity was not " \
3793-
"compiled with ssdeep support.");
3794-
37953792
rule->op_param_data = NULL;
37963793

3797-
return -1;
3794+
return 1;
37983795
#endif
37993796
return 1;
38003797

@@ -3852,6 +3849,12 @@ static int msre_op_fuzzy_hash_execute(modsec_rec *msr, msre_rule *rule,
38523849
}
38533850

38543851
fclose(fp);
3852+
#else
3853+
*error_msg = apr_psprintf(rule->ruleset->mp, "ModSecurity was not " \
3854+
"compiled with ssdeep support.");
3855+
3856+
return -1;
3857+
38553858
#endif
38563859

38573860
/* No match. */

tests/regression/misc/30-fuzzyHash.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
SecRule REQUEST_BODY "\@fuzzyHash $ENV{CONF_DIR}/ssdeep.txt 1" "id:192372,log,deny"
1313
),
1414
match_log => {
15-
error => [ qr/ModSecurity: Access denied with code 403 \(phase 2\)\. Fuzzy hash of REQUEST_BODY matched with 96:MbQ1L0LDX8GPI8ov3D2D9zd6.*"modsecurity.conf-recommended"/, 1],
16-
debug => [ qr/Access denied with code 403 \(phase 2\)\. Fuzzy hash of REQUEST_BODY matched with 96:MbQ1L0LDX8GPI8ov3D2D9zd6.*"modsecurity.conf-recommended"/, 1],
15+
error => [ qr/ModSecurity: Access denied with code 403 \(phase 2\)\. Fuzzy hash of REQUEST_BODY matched with 96:MbQ1L0LDX8GPI8ov3D2D9zd6.*"modsecurity.conf-recommended"|ModSecurity was not compiled with ssdeep support./, 1],
16+
debug => [ qr/Access denied with code 403 \(phase 2\)\. Fuzzy hash of REQUEST_BODY matched with 96:MbQ1L0LDX8GPI8ov3D2D9zd6.*"modsecurity.conf-recommended"|ModSecurity was not compiled with ssdeep support./, 1],
1717
},
1818
match_response => {
19-
status => qr/^403$/,
19+
status => qr/^403|200$/,
2020
},
2121
request => new HTTP::Request(
2222
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/index.html",

0 commit comments

Comments
 (0)