From 44d41fd692ea695708c9cd51ecbf1fab2c7a5c28 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sun, 10 Apr 2022 11:23:49 +0200 Subject: [PATCH] ids.cgi: Add oinkmaster_web () function. This function is used to regenerate the entire ruleset similar to the one from ids-functions, but is enhanced to print additional status messages. Signed-off-by: Stefan Schantl --- html/cgi-bin/ids.cgi | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi index 56bb5712ef..856f7e3d9e 100644 --- a/html/cgi-bin/ids.cgi +++ b/html/cgi-bin/ids.cgi @@ -1863,6 +1863,64 @@ sub _close_working_notice () { &Header::closepage(); } +# +## Function which locks the webpage and basically does the same as the +## oinkmaster function, but provides a lot of HTML formated status output. +# +sub oinkmaster_web () { + my @enabled_providers = &IDS::get_enabled_providers(); + + # Lock the webpage and print message. + &_open_working_notice("$Lang::tr{'ids apply ruleset changes'}"); + + # Check if the files in rulesdir have the correct permissions. + &IDS::_check_rulesdir_permissions(); + + print "

\n"; + + # Cleanup the rules directory before filling it with the new rulests. + &_add_to_notice("Remove old rule structures..."); + &IDS::_cleanup_rulesdir(); + + # Loop through the array of enabled providers. + foreach my $provider (@enabled_providers) { + &_add_to_notice("Extracting ruleset for provider: $provider"); + # Call the extractruleset function. + &IDS::extractruleset($provider); + } + + # Call function to process the ruleset and do all modifications. + &_add_to_notice("Adjust rules and add user defined customizations..."); + &IDS::process_ruleset(@enabled_providers); + + # Call function to merge the classification files. + &_add_to_notice("Merging classifications ..."); + &IDS::merge_classifications(@enabled_providers); + + # Call function to merge the sid to message mapping files. + &_add_to_notice("Merging sid to message files ..."); + &IDS::merge_sid_msg(@enabled_providers); + + # Cleanup temporary directory. + &_add_to_notice("Cleanup temporary directory ..."); + &IDS::cleanup_tmp_directory(); + + # Finished - print a notice. + &_add_to_notice("Finished..."); + + # Close the working notice. + &_close_working_notice(); +} + +# +## Tiny private function to add a given message to a notice table. +# +sub _add_to_notice ($) { + my ($message) = @_; + + print "
  • $message
  • \n"; +} + # ## A tiny function to perform a reload of the webpage after one second. # -- 2.39.5