mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Newer apaches default to text/plain instead of null.
Make matching files a bit more robust.
This commit is contained in:
parent
21f305095c
commit
326208d02c
@ -33,7 +33,7 @@
|
||||
SecDebugLog $ENV{DEBUG_LOG}
|
||||
SecDebugLogLevel 9
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecRule RESPONSE_BODY "TEST" "phase:4,deny"
|
||||
),
|
||||
match_log => {
|
||||
@ -54,7 +54,7 @@
|
||||
SecDebugLog $ENV{DEBUG_LOG}
|
||||
SecDebugLogLevel 9
|
||||
SecResponseBodyAccess Off
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecRule RESPONSE_BODY "TEST" "phase:4,deny"
|
||||
),
|
||||
match_log => {
|
||||
@ -76,7 +76,7 @@
|
||||
conf => qq(
|
||||
SecRuleEngine On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecResponseBodyLimit 8192
|
||||
),
|
||||
match_log => {
|
||||
@ -95,7 +95,7 @@
|
||||
conf => qq(
|
||||
SecRuleEngine On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecResponseBodyLimit 9000
|
||||
),
|
||||
match_log => {
|
||||
@ -114,7 +114,7 @@
|
||||
conf => qq(
|
||||
SecRuleEngine On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecResponseBodyLimit 8000
|
||||
),
|
||||
match_log => {
|
||||
@ -135,7 +135,7 @@
|
||||
conf => qq(
|
||||
SecRuleEngine On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecResponseBodyLimit 5
|
||||
SecResponseBodyLimitAction Reject
|
||||
),
|
||||
@ -155,7 +155,7 @@
|
||||
conf => qq(
|
||||
SecRuleEngine On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecResponseBodyLimit 5
|
||||
SecDebugLog $ENV{DEBUG_LOG}
|
||||
SecDebugLogLevel 4
|
||||
|
@ -8,7 +8,7 @@
|
||||
SecRuleEngine On
|
||||
SecRequestBodyAccess On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecRule REQUEST_LINE "^POST" "phase:1,pass,log,auditlog"
|
||||
SecRule ARGS "val1" "phase:1,pass,log,auditlog"
|
||||
SecRule RESPONSE_HEADERS:Last-Modified "." "phase:1,pass,log,auditlog"
|
||||
@ -38,7 +38,7 @@
|
||||
SecRuleEngine On
|
||||
SecRequestBodyAccess On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecRule REQUEST_LINE "^POST" "phase:2,pass,log,auditlog"
|
||||
SecRule ARGS "val1" "phase:2,pass,log,auditlog"
|
||||
SecRule RESPONSE_HEADERS:Last-Modified "." "phase:2,pass,log,auditlog"
|
||||
@ -68,7 +68,7 @@
|
||||
SecRuleEngine On
|
||||
SecRequestBodyAccess On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecRule REQUEST_LINE "^POST" "phase:3,pass,log,auditlog"
|
||||
SecRule ARGS "val1" "phase:3,pass,log,auditlog"
|
||||
SecRule RESPONSE_HEADERS:Last-Modified "." "phase:3,pass,log,auditlog"
|
||||
@ -98,7 +98,9 @@
|
||||
SecRuleEngine On
|
||||
SecRequestBodyAccess On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecDebugLog "$ENV{DEBUG_LOG}"
|
||||
SecDebugLogLevel 9
|
||||
SecRule REQUEST_LINE "^POST" "phase:4,pass,log,auditlog"
|
||||
SecRule ARGS "val1" "phase:4,pass,log,auditlog"
|
||||
SecRule RESPONSE_HEADERS:Last-Modified "." "phase:4,pass,log,auditlog"
|
||||
@ -127,7 +129,7 @@
|
||||
SecRuleEngine On
|
||||
SecRequestBodyAccess On
|
||||
SecResponseBodyAccess On
|
||||
SecResponseBodyMimeType null
|
||||
SecResponseBodyMimeType text/plain null
|
||||
SecRule REQUEST_LINE "^POST" "phase:5,pass,log,auditlog"
|
||||
SecRule ARGS "val1" "phase:5,pass,log,auditlog"
|
||||
SecRule RESPONSE_HEADERS:Last-Modified "." "phase:5,pass,log,auditlog"
|
||||
|
@ -416,6 +416,11 @@ sub match_log {
|
||||
|
||||
msg("Warning: Empty regular expression.") if (!defined $re or $re eq "");
|
||||
|
||||
unless (defined $fh) {
|
||||
msg("Error: File \"$name\" is not opened for matching.");
|
||||
return;
|
||||
}
|
||||
|
||||
$timeout = 0 unless (defined $timeout);
|
||||
|
||||
do {
|
||||
@ -432,10 +437,16 @@ sub match_log {
|
||||
sub match_file {
|
||||
my($neg,$fn) = ($_[0] =~ m/^(-?)(.*)$/);
|
||||
unless (exists $FILE{$fn}) {
|
||||
eval {
|
||||
$FILE{$fn}{fn} = $fn;
|
||||
$FILE{$fn}{fd} = new FileHandle($fn, O_RDONLY);
|
||||
$FILE{$fn}{fd} = new FileHandle($fn, O_RDONLY) or die "$!\n";
|
||||
$FILE{$fn}{fd}->blocking(0);
|
||||
$FILE{$fn}{buf} = "";
|
||||
};
|
||||
if ($@) {
|
||||
msg("Warning: Failed to open file \"$fn\": $@");
|
||||
return;
|
||||
}
|
||||
}
|
||||
return match_log($_[0], $_[1]); # timeout makes no sense
|
||||
}
|
||||
@ -650,38 +661,60 @@ sub httpd_reset_fd {
|
||||
}
|
||||
|
||||
# Error
|
||||
eval {
|
||||
$FILE{error}{fn} = $opt{E};
|
||||
$FILE{error}{fd} = new FileHandle($opt{E}, O_RDWR|O_CREAT);
|
||||
$FILE{error}{fd} = new FileHandle($opt{E}, O_RDWR|O_CREAT) or die "$!\n";
|
||||
$FILE{error}{fd}->blocking(0);
|
||||
$FILE{error}{fd}->sysseek(0, 2);
|
||||
$FILE{error}{buf} = "";
|
||||
};
|
||||
if ($@) {
|
||||
msg("Warning: Failed to open file \"$opt{E}\": $@");
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Audit
|
||||
eval {
|
||||
$FILE{audit}{fn} = $opt{A};
|
||||
$FILE{audit}{fd} = new FileHandle($opt{A}, O_RDWR|O_CREAT);
|
||||
$FILE{audit}{fd} = new FileHandle($opt{A}, O_RDWR|O_CREAT) or die "$!\n";
|
||||
$FILE{audit}{fd}->blocking(0);
|
||||
$FILE{audit}{fd}->sysseek(0, 2);
|
||||
$FILE{audit}{buf} = "";
|
||||
};
|
||||
if ($@) {
|
||||
msg("Warning: Failed to open file \"$opt{A}\": $@");
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Debug
|
||||
eval {
|
||||
$FILE{debug}{fn} = $opt{D};
|
||||
$FILE{debug}{fd} = new FileHandle($opt{D}, O_RDWR|O_CREAT);
|
||||
$FILE{debug}{fd} = new FileHandle($opt{D}, O_RDWR|O_CREAT) or die "$!\n";
|
||||
$FILE{debug}{fd}->blocking(0);
|
||||
$FILE{debug}{fd}->sysseek(0, 2);
|
||||
$FILE{debug}{buf} = "";
|
||||
};
|
||||
if ($@) {
|
||||
msg("Warning: Failed to open file \"$opt{D}\": $@");
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Any extras listed in "match_log"
|
||||
if ($t and exists $t->{match_log}) {
|
||||
for my $k (keys %{ $t->{match_log} || {} }) {
|
||||
my($neg,$fn) = ($k =~ m/^(-?)(.*)$/);
|
||||
next if (!$fn or exists $FILE{$fn});
|
||||
#dbg("Opening additional log: $fn");
|
||||
eval {
|
||||
$FILE{$fn}{fn} = $fn;
|
||||
$FILE{$fn}{fd} = new FileHandle($fn, O_RDWR|O_CREAT);
|
||||
$FILE{$fn}{fd} = new FileHandle($fn, O_RDWR|O_CREAT) or die "$!\n";
|
||||
$FILE{$fn}{fd}->blocking(0);
|
||||
$FILE{$fn}{fd}->sysseek(0, 2);
|
||||
$FILE{$fn}{buf} = "";
|
||||
|
||||
};
|
||||
if ($@) {
|
||||
msg("Warning: Failed to open file \"$fn\": $@");
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user