}
}
- # Open oinkmaster main include file for provider modifications.
- open(OINKM_INCL_FILE, ">", "$IDS::oinkmaster_provider_includes_file") or die "Could not open $IDS::oinkmaster_provider_includes_file. $!\n";
-
- # Print file header and notice about autogenerated file.
- print OINKM_INCL_FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
-
# Get enabled providers.
my @enabled_providers = &IDS::get_enabled_providers();
# Hash to store the used-enabled and disabled sids.
my %enabled_disabled_sids;
- # Generate modified sids file name for the current processed provider.
- my $providers_modified_sids_file = &IDS::get_oinkmaster_provider_modified_sids_file($provider);
+ # Get name of the file which holds the ruleset modification of the provider.
+ my $modifications_file = &IDS::get_provider_ruleset_modifications_file($provider);
- # Check if a modified sids file for this provider exists.
- if (-f $providers_modified_sids_file) {
- # Read-in the file for enabled/disabled sids.
- %enabled_disabled_sids = &IDS::read_enabled_disabled_sids_file($providers_modified_sids_file);
- }
+ # Read-in modifications file, if exists.
+ &General::readhash("$modifications_file", \%enabled_disabled_sids) if (-f "$modifications_file");
# Loop through the hash of idsrules.
foreach my $rulefile (keys %idsrules) {
# Check if the hash for enabled/disabled sids contains any entries.
if (%enabled_disabled_sids) {
- # Open providers modified sids file for writing.
- open(PROVIDER_MOD_FILE, ">$providers_modified_sids_file") or die "Could not write to $providers_modified_sids_file. $!\n";
-
- # Write header to the files.
- print PROVIDER_MOD_FILE "#Autogenerated file. Any custom changes will be overwritten!\n";
-
- # Loop through the hash.
- foreach my $sid (keys %enabled_disabled_sids) {
- # Check if the sid is enabled.
- if ($enabled_disabled_sids{$sid} eq "enabled") {
- # Print the sid to the enabled_sids file.
- print PROVIDER_MOD_FILE "enablesid $sid\n";
- # Check if the sid is disabled.
- } elsif ($enabled_disabled_sids{$sid} eq "disabled") {
- # Print the sid to the disabled_sids file.
- print PROVIDER_MOD_FILE "disablesid $sid\n";
- # Something strange happende - skip the current sid.
- } else {
- next;
- }
- }
-
- # Close file handle for the providers modified sids file.
- close(PROVIDER_MOD_FILE);
-
- # Add the file to the oinkmasters include file.
- print OINKM_INCL_FILE "include $providers_modified_sids_file\n";
+ # Write the modifications file.
+ &General::writehash("$modifications_file", \%enabled_disabled_sids);
}
}
- # Close the file handle after writing.
- close(OINKM_INCL_FILE);
-
# Handle enabled / disabled rulefiles.
#