]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ids.cgi: Set state of used rulefile to on if it contains rules
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 11 Sep 2018 10:00:31 +0000 (12:00 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Tue, 11 Sep 2018 10:00:31 +0000 (12:00 +0200)
Only set the state of a used rulefile to "on" if it is present in
the %idsrules hash. This happens if it contains at least one rule.

This prevents from showing a rulefile in the ruleset section if, it
does not exist anymore or does not contains any rules at all.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index 55f45c5c83c604e7911abf9900b9b03f97712b42..edf67963b2da9b2f00ece94df530f4e05fdb63d7 100644 (file)
@@ -300,8 +300,13 @@ if(-f $idsusedrulefilesfile) {
                if ($line =~ /.*- (.*)/) {
                        my $rulefile = $1;
 
-                       # Add the rulefile to the %idsrules hash.
-                       $idsrules{$rulefile}{'Rulefile'}{'State'} = "on";
+                       # 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";
+                       }
                }
        }
 }