From: Stefan Schantl Date: Fri, 2 Apr 2021 09:21:00 +0000 (+0200) Subject: ids.cgi: Add code to handle the reset of a provider to it's defaults. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ada485ce99deefc5b48388ef090dd2c09bf40023;p=people%2Fstevee%2Fipfire-2.x.git ids.cgi: Add code to handle the reset of a provider to it's defaults. Signed-off-by: Stefan Schantl --- diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi index b8c02341fb..a8f5b64297 100644 --- a/html/cgi-bin/ids.cgi +++ b/html/cgi-bin/ids.cgi @@ -539,6 +539,61 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'ids apply'}) { &reload(); } } + +# Reset a provider to it's defaults. +} elsif ($cgiparams{'PROVIDERS'} eq "$Lang::tr{'ids reset provider'}") { + # Grab provider handle from cgihash. + my $provider = $cgiparams{'PROVIDER'}; + + # Lock the webpage and print message. + &working_notice("$Lang::tr{'ids apply ruleset changes'}"); + + # Create new empty file for used rulefiles + # for this provider. + &IDS::write_used_provider_rulefiles_file($provider); + + # Call function to get the path and name for the given providers + # oinkmaster modified sids file. + my $provider_modified_sids_file = &IDS::get_oinkmaster_provider_modified_sids_file($provider); + + # Check if the file exists. + if (-f $provider_modified_sids_file) { + # Remove the file, as requested. + unlink("$provider_modified_sids_file"); + } + + # Alter the oinkmaster provider includes file and remove the provider. + &IDS::alter_oinkmaster_provider_includes_file("remove", $provider); + + # Regenerate ruleset. + &IDS::oinkmaster(); + + # Check if the IDS is running. + if(&IDS::ids_is_running()) { + # Get enabled providers. + my @enabled_providers = &IDS::get_enabled_providers(); + + # Get amount of enabled providers. + my $amount = @enabled_providers; + + # Check if at least one enabled provider remains. + if ($amount >= 1) { + # Call suricatactrl to perform a reload. + &IDS::call_suricatactrl("restart"); + + # Stop suricata if no enabled provider remains. + } else { + # Call suricatactrel to perform the stop. + &IDS::call_suricatactrl("stop"); + } + } + + # Undefine providers flag. + undef($cgiparams{'PROVIDERS'}); + + # Reload page. + &reload(); + # Save IDS settings. } elsif ($cgiparams{'IDS'} eq $Lang::tr{'save'}) { my %oldidssettings;