From 5e20d6cb28a87fca71abd9d4e0b811f6674fd39a Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Wed, 31 Mar 2021 12:16:24 +0200 Subject: [PATCH] ids-functions.pl: Introduce get_enabled_providers() function. This function simply returns an array with all enabled ruleset providers. Signed-off-by: Stefan Schantl --- config/cfgroot/ids-functions.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl index 1b074050b8..9424ce567f 100644 --- a/config/cfgroot/ids-functions.pl +++ b/config/cfgroot/ids-functions.pl @@ -163,6 +163,36 @@ sub get_ruleset_providers() { return sort(@providers); } +# +## Function to get a list of all enabled ruleset providers. +## +## They will be returned as an array. +# +sub get_enabled_providers () { + my %used_providers = (); + + # Array to store the enabled providers. + my @enabled_providers = (); + + # Read-in the providers config file. + &General::readhasharray("$providers_settings_file", \%used_providers); + + # Loop through the hash of used_providers. + foreach my $id (keys %used_providers) { + # Skip disabled providers. + next unless ($used_providers{$id}[3] eq "enabled"); + + # Grab the provider handle. + my $provider = "$used_providers{$id}[0]"; + + # Add the provider to the array of enabled providers. + push(@enabled_providers, $provider); + } + + # Return the array. + return @enabled_providers; +} + # ## Function for checking if at least 300MB of free disk space are available ## on the "/var" partition. -- 2.39.2