From: Stefan Schantl Date: Thu, 2 Aug 2018 07:07:12 +0000 (+0200) Subject: ids.cgi: Generate suricata compatiple used-rulefiles file X-Git-Tag: v2.23-core131~117^2~173^2~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=101c888174285f4d4e599902c7645d2e834ea027;p=ipfire-2.x.git ids.cgi: Generate suricata compatiple used-rulefiles file * Rename filename to suricata-used-rulefiles.yaml * Adjust file generation as a yaml file to be compatible with suricata * Adjust code to correctly read-in and parse the changed file Signed-off-by: Stefan Schantl --- diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi index 2ada96f520..b42ede2ae0 100644 --- a/html/cgi-bin/ids.cgi +++ b/html/cgi-bin/ids.cgi @@ -47,7 +47,7 @@ my %selected=(); # Get netsettings. &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); -my $idsusedrulefilesfile = "$IDS::settingsdir/ids-used-rulefiles.conf"; +my $idsusedrulefilesfile = "$IDS::settingsdir/suricata-used-rulefiles.yaml"; my $errormessage; &Header::showhttpheaders(); @@ -130,7 +130,7 @@ if(-f $idsusedrulefilesfile) { next if ($line =~ /^\s*$/); # Gather rule sid and message from the ruleline. - if ($line =~ /.*include \$RULE_PATH\/(.*)/) { + if ($line =~ /.*- (.*)/) { my $rulefile = $1; # Add the rulefile to the %idsrules hash. @@ -234,6 +234,10 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) { # Open file for used rulefiles. open (FILE, ">$idsusedrulefilesfile") or die "Could not write to $idsusedrulefilesfile. $!\n"; + # Write yaml header to the file. + print FILE "%YAML 1.1\n"; + print FILE "---\n\n"; + # Write header to file. print FILE "#Autogenerated file. Any custom changes will be overwritten!\n"; @@ -241,7 +245,7 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) { if (@enabled_rulefiles) { # Loop through the array of rulefiles which should be loaded and write the to the file. foreach my $file (@enabled_rulefiles) { - print FILE "include \$RULE_PATH/$file\n"; + print FILE " - $file\n"; } }