]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
ids.cgi: Use get_used_rulesfiles function from ids-functions.pl.
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 31 Mar 2021 10:02:27 +0000 (12:02 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 19 Dec 2021 12:23:00 +0000 (13:23 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index b8bdd4fe2635b97a5f052b8f7996f0813d1c9e32..0a825425eb296bfc043dcc54372d47d859342658 100644 (file)
@@ -282,41 +282,16 @@ if ($cgiparams{'RULESET'}) {
        closedir(DIR);
 
        # Gather used rulefiles.
-       #
-       # Check if the file for activated rulefiles is not empty.
-       if(-f $IDS::used_rulefiles_file) {
-               # Open the file for used rulefile and read-in content.
-               open(FILE, $IDS::used_rulefiles_file) or die "Could not open $IDS::used_rulefiles_file. $!\n";
-
-               # Read-in content.
-               my @lines = <FILE>;
-
-               # Close file.
-               close(FILE);
-
-               # Loop through the array.
-               foreach my $line (@lines) {
-                       # Remove newlines.
-                       chomp($line);
-
-                       # Skip comments.
-                       next if ($line =~ /\#/);
-
-                       # Skip blank  lines.
-                       next if ($line =~ /^\s*$/);
-
-                       # Gather rule sid and message from the ruleline.
-                       if ($line =~ /.*- (.*)/) {
-                               my $rulefile = $1;
-
-                               # Check if the current rulefile exists in the %idsrules hash.
-                               # If not, the file probably does not exist anymore or contains
-                               # no rules.
-                               if($idsrules{$rulefile}) {
-                                       # Add the rulefile state to the %idsrules hash.
-                                       $idsrules{$rulefile}{'Rulefile'}{'State'} = "on";
-                               }
-                       }
+       my @used_rulesfiles = &IDS::get_used_rulesfiles();
+
+       # Loop through the array of used rulesfiles.
+       foreach my $rulesfile (@used_rulesfiles) {
+               # Check if the current rulefile exists in the %idsrules hash.
+               # If not, the file probably does not exist anymore or contains
+               # no rules.
+               if($idsrules{$rulefile}) {
+                       # Add the rulefile state to the %idsrules hash.
+                       $idsrules{$rulefile}{'Rulefile'}{'State'} = "on";
                }
        }
 }