ids.cgi: Always write config files for enabled/disabled rule files

If a single sid has been activated and then disabled without doing
any other ruleset modifications only one of the oinkmaster files
for enabled / disabled rules has been modified.

In this case it was possible, that the same sid, was part of the
file for enabled rules and part of the file for disabled rules at the
same time.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
Stefan Schantl
2017-12-12 20:16:26 +01:00
parent 466c67794b
commit 376595057b

View File

@@ -182,42 +182,42 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'update'}) {
}
}
# Open enabled sid's file for writing.
open(FILE, ">$enabled_sids_file") or die "Could not write to $enabled_sids_file. $!\n";
# Write header to file.
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
# Check if the enabled_sids array contains any sid's.
if (@enabled_sids) {
# Open enabled sid's file for writing.
open(FILE, ">$enabled_sids_file") or die "Could not write to $enabled_sids_file. $!\n";
# Write header to file.
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
# Loop through the array of enabled sids and write them to the file.
foreach my $sid (@enabled_sids) {
print FILE "enable_sid $sid\n";
print FILE "enablesid $sid\n";
}
# Close file after writing.
close(FILE);
}
# Close file after writing.
close(FILE);
# Open disabled sid's file for writing.
open(FILE, ">$disabled_sids_file") or die "Could not write to $disabled_sids_file. $!\n";
# Write header to file.
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
# Check if the enabled_sids array contains any sid's.
if (@disabled_sids) {
# Open disabled sid's file for writing.
open(FILE, ">$disabled_sids_file") or die "Could not write to $disabled_sids_file. $!\n";
if (@disabled_sids) {
# Loop through the array of disabled sids and write them to the file.
foreach my $sid (@disabled_sids) {
print FILE "disablesid $sid\n";
}
}
# Write header to file.
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
# Loop through the array of disabled sids and write them to the file.
foreach my $sid (@disabled_sids) {
print FILE "disable_sid $sid\n";
}
# Close file after writing.
close(FILE);
}
# Close file after writing.
close(FILE);
# Open file for used rulefiles.
open (FILE, ">$snortusedrulefilesfile") or die "Could not wirte to $snortusedrulefilesfile. $!\n";
open (FILE, ">$snortusedrulefilesfile") or die "Could not write to $snortusedrulefilesfile. $!\n";
# Write header to file.
print FILE "#Autogenerated file. Any custom changes will be overwritten!\n";