mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
ids-functions.pl: Drop downloader code for sourcefire based ruleset.
Even if the servers do not support HEAD requests, the remote filesize (content_length) can be obtained from the connection headers. This generic method works for all servers and therefore we do not need the code for handle sourcefire servers in a different way anymore. Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
@@ -354,43 +354,6 @@ sub downloadruleset ($) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Variable to store the filesize of the remote object.
|
|
||||||
my $remote_filesize;
|
|
||||||
|
|
||||||
# The sourcfire (snort rules) does not allow to send "HEAD" requests, so skip this check
|
|
||||||
# for this webserver.
|
|
||||||
#
|
|
||||||
# Check if the ruleset source contains "snort.org".
|
|
||||||
unless ($url =~ /\.snort\.org/) {
|
|
||||||
# Pass the requrested url to the downloader.
|
|
||||||
my $request = HTTP::Request->new(HEAD => $url);
|
|
||||||
|
|
||||||
# Accept the html header.
|
|
||||||
$request->header('Accept' => 'text/html');
|
|
||||||
|
|
||||||
# Perform the request and fetch the html header.
|
|
||||||
my $response = $downloader->request($request);
|
|
||||||
|
|
||||||
# Check if there was any error.
|
|
||||||
unless ($response->is_success) {
|
|
||||||
# Obtain error.
|
|
||||||
my $error = $response->status_line();
|
|
||||||
|
|
||||||
# Log error message.
|
|
||||||
&_log_to_syslog("Unable to download the ruleset. \($error\)");
|
|
||||||
|
|
||||||
# Return "1" - false.
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Assign the fetched header object.
|
|
||||||
my $header = $response->headers();
|
|
||||||
|
|
||||||
# Grab the remote file size from the object and store it in the
|
|
||||||
# variable.
|
|
||||||
$remote_filesize = $header->content_length;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Load perl module to deal with temporary files.
|
# Load perl module to deal with temporary files.
|
||||||
use File::Temp;
|
use File::Temp;
|
||||||
|
|
||||||
@@ -416,6 +379,12 @@ sub downloadruleset ($) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Obtain the connection headers.
|
||||||
|
my $headers = $response->headers;
|
||||||
|
|
||||||
|
# Get the remote size of the downloaded file.
|
||||||
|
my $remote_filesize = $headers->content_length;
|
||||||
|
|
||||||
# Load perl stat module.
|
# Load perl stat module.
|
||||||
use File::stat;
|
use File::stat;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user