mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
ids-functions.pl: Introduce get_ruleset_date() function.
This function is used to get the creation date of the stored rules files of a given provider. Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
@@ -1354,6 +1354,35 @@ END
|
||||
close(FILE);
|
||||
}
|
||||
|
||||
#
|
||||
## Function to get the ruleset date for a given provider.
|
||||
##
|
||||
## The function simply return the creation date in a human read-able format
|
||||
## of the stored providers rulesfile.
|
||||
#
|
||||
sub get_ruleset_date($) {
|
||||
my ($provider) = @_;
|
||||
|
||||
# Load neccessary perl modules for file stat and to format the timestamp.
|
||||
use File::stat;
|
||||
use POSIX qw( strftime );
|
||||
|
||||
# Get the stored rulesfile for this provider.
|
||||
my $stored_rulesfile = &_get_dl_rulesfile($provider);
|
||||
|
||||
# Call stat on the rulestarball.
|
||||
my $stat = stat("$stored_rulesfile");
|
||||
|
||||
# Get timestamp the file creation.
|
||||
my $mtime = $stat->mtime;
|
||||
|
||||
# Convert into human read-able format.
|
||||
my $date = strftime('%Y-%m-%d %H:%M:%S', localtime($mtime));
|
||||
|
||||
# Return the date.
|
||||
return $date;
|
||||
}
|
||||
|
||||
#
|
||||
## Function to gather the version of suricata.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user