]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ids.cgi: Add code for e-mail input validation
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 9 Aug 2025 15:50:48 +0000 (17:50 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Sep 2025 17:42:01 +0000 (18:42 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
14 files changed:
doc/language_issues.en
doc/language_issues.es
doc/language_issues.fr
doc/language_issues.it
doc/language_issues.nl
doc/language_issues.pl
doc/language_issues.ru
doc/language_issues.tr
doc/language_issues.tw
doc/language_issues.zh
doc/language_missings
html/cgi-bin/ids.cgi
langs/de/cgi-bin/de.pl
langs/en/cgi-bin/en.pl

index 15229c9fad1e92594cd8e340efafe1c988af77da..0c6a2fd84060c509248cb0914d3d71731e58b1ba 100644 (file)
@@ -1050,6 +1050,7 @@ WARNING: untranslated string: ids finished = Finished...
 WARNING: untranslated string: ids force ruleset update = Force ruleset update
 WARNING: untranslated string: ids hide = Hide
 WARNING: untranslated string: ids ignored hosts = Whitelisted Hosts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
 WARNING: untranslated string: ids log hits = Total of number of activated rules for
 WARNING: untranslated string: ids log viewer = IPS Log Viewer
 WARNING: untranslated string: ids logs = IPS Logs
@@ -1057,6 +1058,8 @@ WARNING: untranslated string: ids merge classifications = Merging classification
 WARNING: untranslated string: ids merge sid files = Merging sid to message files...
 WARNING: untranslated string: ids monitor traffic only = Monitor traffic only
 WARNING: untranslated string: ids monitored interfaces = Monitored Interfaces
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: ids no enabled ruleset provider = No enabled ruleset is available. Please activate or add one first.
 WARNING: untranslated string: ids no network zone = Please select at least one network zone to be monitored
 WARNING: untranslated string: ids provider = Provider
index 4335085aa350efba2a3e3ddde700e60b37a3c286..b6c1e0838a1e8c4c4bc3aef80be00c1313aa335f 100644 (file)
@@ -1060,6 +1060,9 @@ WARNING: untranslated string: ids email alerts = E-Mail alerts
 WARNING: untranslated string: ids email recipients = Recipients
 WARNING: untranslated string: ids email sender = Sender address
 WARNING: untranslated string: ids enable email alerts = Enable e-mail alerts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: ids provider eol = (EOL)
 WARNING: untranslated string: indirect target selection = Indirect target selection
 WARNING: untranslated string: info messages = unknown string
index 71ee9365d9f03f2c73cd56a7deec7b7a119c4c74..e47be8c457a0cc605e35d47cf7b9805cf1fec546 100644 (file)
@@ -1048,6 +1048,9 @@ WARNING: untranslated string: ids email alerts = E-Mail alerts
 WARNING: untranslated string: ids email recipients = Recipients
 WARNING: untranslated string: ids email sender = Sender address
 WARNING: untranslated string: ids enable email alerts = Enable e-mail alerts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: ids provider eol = (EOL)
 WARNING: untranslated string: ids rulesets = Rulesets
 WARNING: untranslated string: import connection = Import a Connection
index 7d208332168842a2ffb2e40ce94953d94f8cbc84..a8a5905abaffd4a4bb845016c6983b9bc6fdccb2 100644 (file)
@@ -1173,11 +1173,14 @@ WARNING: untranslated string: ids finished = Finished...
 WARNING: untranslated string: ids force ruleset update = Force ruleset update
 WARNING: untranslated string: ids hide = Hide
 WARNING: untranslated string: ids ignored hosts = Whitelisted Hosts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
 WARNING: untranslated string: ids log hits = Total of number of activated rules for
 WARNING: untranslated string: ids merge classifications = Merging classifications...
 WARNING: untranslated string: ids merge sid files = Merging sid to message files...
 WARNING: untranslated string: ids monitor traffic only = Monitor traffic only
 WARNING: untranslated string: ids monitored interfaces = Monitored Interfaces
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: ids no enabled ruleset provider = No enabled ruleset is available. Please activate or add one first.
 WARNING: untranslated string: ids no network zone = Please select at least one network zone to be monitored
 WARNING: untranslated string: ids provider = Provider
index cc8221a0836ad001651625ef92eed7dfbc3aa138..1ab12b7e030fa1e2cab2880b20e279c1a3086f28 100644 (file)
@@ -1179,11 +1179,14 @@ WARNING: untranslated string: ids finished = Finished...
 WARNING: untranslated string: ids force ruleset update = Force ruleset update
 WARNING: untranslated string: ids hide = Hide
 WARNING: untranslated string: ids ignored hosts = Whitelisted Hosts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
 WARNING: untranslated string: ids log hits = Total of number of activated rules for
 WARNING: untranslated string: ids merge classifications = Merging classifications...
 WARNING: untranslated string: ids merge sid files = Merging sid to message files...
 WARNING: untranslated string: ids monitor traffic only = Monitor traffic only
 WARNING: untranslated string: ids monitored interfaces = Monitored Interfaces
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: ids no enabled ruleset provider = No enabled ruleset is available. Please activate or add one first.
 WARNING: untranslated string: ids no network zone = Please select at least one network zone to be monitored
 WARNING: untranslated string: ids provider = Provider
index e37913baaaf7976c46aaf3fc27763276de7bdf91..c006f7e024483676df4dacd83eec112843e2c59b 100644 (file)
@@ -1298,11 +1298,14 @@ WARNING: untranslated string: ids finished = Finished...
 WARNING: untranslated string: ids force ruleset update = Force ruleset update
 WARNING: untranslated string: ids hide = Hide
 WARNING: untranslated string: ids ignored hosts = Whitelisted Hosts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
 WARNING: untranslated string: ids log hits = Total of number of activated rules for
 WARNING: untranslated string: ids merge classifications = Merging classifications...
 WARNING: untranslated string: ids merge sid files = Merging sid to message files...
 WARNING: untranslated string: ids monitor traffic only = Monitor traffic only
 WARNING: untranslated string: ids monitored interfaces = Monitored Interfaces
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: ids no enabled ruleset provider = No enabled ruleset is available. Please activate or add one first.
 WARNING: untranslated string: ids no network zone = Please select at least one network zone to be monitored
 WARNING: untranslated string: ids provider = Provider
index ac540365b7fddbdea9e6f01508e9ae12be6a76cc..a356d92544cdc900c45c6bbd186ec662c83fb54f 100644 (file)
@@ -1296,11 +1296,14 @@ WARNING: untranslated string: ids finished = Finished...
 WARNING: untranslated string: ids force ruleset update = Force ruleset update
 WARNING: untranslated string: ids hide = Hide
 WARNING: untranslated string: ids ignored hosts = Whitelisted Hosts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
 WARNING: untranslated string: ids log hits = Total of number of activated rules for
 WARNING: untranslated string: ids merge classifications = Merging classifications...
 WARNING: untranslated string: ids merge sid files = Merging sid to message files...
 WARNING: untranslated string: ids monitor traffic only = Monitor traffic only
 WARNING: untranslated string: ids monitored interfaces = Monitored Interfaces
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: ids no enabled ruleset provider = No enabled ruleset is available. Please activate or add one first.
 WARNING: untranslated string: ids no network zone = Please select at least one network zone to be monitored
 WARNING: untranslated string: ids provider = Provider
index 4cae8e3a25e0b71968275604064cd5e9e5fa56de..b5094edc1f0450382fec43c53d38261b31093b4b 100644 (file)
@@ -1117,11 +1117,14 @@ WARNING: untranslated string: ids finished = Finished...
 WARNING: untranslated string: ids force ruleset update = Force ruleset update
 WARNING: untranslated string: ids hide = Hide
 WARNING: untranslated string: ids ignored hosts = Whitelisted Hosts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
 WARNING: untranslated string: ids log hits = Total of number of activated rules for
 WARNING: untranslated string: ids merge classifications = Merging classifications...
 WARNING: untranslated string: ids merge sid files = Merging sid to message files...
 WARNING: untranslated string: ids monitor traffic only = Monitor traffic only
 WARNING: untranslated string: ids monitored interfaces = Monitored Interfaces
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: ids no enabled ruleset provider = No enabled ruleset is available. Please activate or add one first.
 WARNING: untranslated string: ids no network zone = Please select at least one network zone to be monitored
 WARNING: untranslated string: ids provider = Provider
index bd07542037b4889081080e29f9e7b8c1c4840338..0913d9cca7c243f27003580f048c641378c580fa 100644 (file)
@@ -1069,6 +1069,9 @@ WARNING: untranslated string: ids email alerts = E-Mail alerts
 WARNING: untranslated string: ids email recipients = Recipients
 WARNING: untranslated string: ids email sender = Sender address
 WARNING: untranslated string: ids enable email alerts = Enable e-mail alerts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: indirect target selection = Indirect target selection
 WARNING: untranslated string: info messages = unknown string
 WARNING: untranslated string: max bandwidth = Maximum bandwidth
index bd07542037b4889081080e29f9e7b8c1c4840338..0913d9cca7c243f27003580f048c641378c580fa 100644 (file)
@@ -1069,6 +1069,9 @@ WARNING: untranslated string: ids email alerts = E-Mail alerts
 WARNING: untranslated string: ids email recipients = Recipients
 WARNING: untranslated string: ids email sender = Sender address
 WARNING: untranslated string: ids enable email alerts = Enable e-mail alerts
+WARNING: untranslated string: ids invalid mail address = Is or contains an invalid mail address.
+WARNING: untranslated string: ids no email recipients = No email recipients given
+WARNING: untranslated string: ids no email sender = No sender email address specified
 WARNING: untranslated string: indirect target selection = Indirect target selection
 WARNING: untranslated string: info messages = unknown string
 WARNING: untranslated string: max bandwidth = Maximum bandwidth
index 22e84db3bae76713f9466b246ef3c751223c91eb..f253a8807b14022d4960b88c92b3e29291858f5b 100644 (file)
 < ids email recipients
 < ids email sender
 < ids enable email alerts
+< ids invalid mail address
+< ids no email recipients
+< ids no email sender
 < ids provider eol
 < indirect target selection
 < mdstat
 < ids email recipients
 < ids email sender
 < ids enable email alerts
+< ids invalid mail address
+< ids no email recipients
+< ids no email sender
 < ids provider eol
 < ids rulesets
 < ids unsupported provider
 < ids force ruleset update
 < ids hide
 < ids ignored hosts
+< ids invalid mail address
 < ids log hits
 < ids merge classifications
 < ids merge sid files
 < ids monitored interfaces
 < ids monitor traffic only
+< ids no email recipients
+< ids no email sender
 < ids no enabled ruleset provider
 < ids no network zone
 < ids provider
 < ids force ruleset update
 < ids hide
 < ids ignored hosts
+< ids invalid mail address
 < ids log hits
 < ids merge classifications
 < ids merge sid files
 < ids monitored interfaces
 < ids monitor traffic only
+< ids no email recipients
+< ids no email sender
 < ids no enabled ruleset provider
 < ids no network zone
 < ids provider
 < ids force ruleset update
 < ids hide
 < ids ignored hosts
+< ids invalid mail address
 < ids log hits
 < ids merge classifications
 < ids merge sid files
 < ids monitored interfaces
 < ids monitor traffic only
+< ids no email recipients
+< ids no email sender
 < ids no enabled ruleset provider
 < ids no network zone
 < ids provider
 < ids force ruleset update
 < ids hide
 < ids ignored hosts
+< ids invalid mail address
 < ids log hits
 < ids merge classifications
 < ids merge sid files
 < ids monitored interfaces
 < ids monitor traffic only
+< ids no email recipients
+< ids no email sender
 < ids no enabled ruleset provider
 < ids no network zone
 < ids provider
 < ids force ruleset update
 < ids hide
 < ids ignored hosts
+< ids invalid mail address
 < ids log hits
 < ids merge classifications
 < ids merge sid files
 < ids monitored interfaces
 < ids monitor traffic only
+< ids no email recipients
+< ids no email sender
 < ids no enabled ruleset provider
 < ids no network zone
 < ids provider
 < ids email recipients
 < ids email sender
 < ids enable email alerts
+< ids invalid mail address
+< ids no email recipients
+< ids no email sender
 < indirect target selection
 < max bandwidth
 < offloaded
 < ids email recipients
 < ids email sender
 < ids enable email alerts
+< ids invalid mail address
+< ids no email recipients
+< ids no email sender
 < indirect target selection
 < max bandwidth
 < offloaded
index 8d9fbfc16b42c343ebf15c4ecdef45c12c471dca..f341494737169e9e87baac7b8019498fd069fd11 100644 (file)
@@ -574,6 +574,29 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'ids apply'}) {
                }
        }
 
+       # Check if the e-mail feature should be used.
+       if ($cgiparams{'ENABLE_EMAIL'} eq "on") {
+               # Check if a sender mail address has been provided.
+               unless($cgiparams{'EMAIL_SENDER'}) {
+                       $errormessage = $Lang::tr{'ids no email sender'};
+               }
+
+               # Check if the given sender mail address is valid.
+               if (&_validate_mail_address($cgiparams{'EMAIL_SENDER'})) {
+                       $errormessage = "$cgiparams{'EMAIL_SENDER'} - $Lang::tr{'ids invalid mail address'}";
+               }
+
+               # Check if at least one mail recipient has been given.
+               unless($cgiparams{'EMAIL_RECIPIENTS'}) {
+                       $errormessage = $Lang::tr{'ids no email recipients'};
+               }
+
+               # Check if the given recipient mail address or addresses are valid.
+               if (&_validate_mail_address($cgiparams{'EMAIL_RECIPIENTS'})) {
+                       $errormessage = "$cgiparams{'EMAIL_RECIPIENTS'} - $Lang::tr{'ids invalid mail address'}";
+               }
+       }
+
        # Go on if there are no error messages.
        if (!$errormessage) {
                # Store settings into settings file.
@@ -589,6 +612,9 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'ids apply'}) {
        # Generate file to store the HTTP ports.
        &IDS::generate_http_ports_file();
 
+       # Generate report generator config file.
+       &IDS::generate_report_generator_config();
+
        # Check if the IDS currently is running.
        if(&IDS::ids_is_running()) {
                # Check if ENABLE_IDS is set to on.
@@ -1027,7 +1053,7 @@ print <<END
                <br>
 
                <form method='post' action='$ENV{'SCRIPT_NAME'}'>
-                       <table width='100%' border='0'>
+                       <table class='form' width='100%' border='0'>
                                <tr>
                                        <td colspan='$num_zones'>
                                                <input type='checkbox' name='ENABLE_IDS' $checked{'ENABLE_IDS'}{'on'}>&nbsp;$Lang::tr{'ids enable'}
@@ -2091,3 +2117,27 @@ sub _rulefile_to_category($) {
        # Return the converted filename.
         return $category;
 }
+
+#
+## Private function to validate if a given string contains one or
+## more valid mail addresses.
+#
+sub _validate_mail_address($) {
+       my ($address) = @_;
+
+       # Temporary array, which holds the single mail addresses.
+       my @temp;
+
+       # Split the string of mail addresses into single pieces and
+       # store them into the temporary array.
+       @temp = split(/\,/, $address);
+
+       # Loop through the array of mail addresses.
+       foreach my $addr (@temp) {
+               # Return 1 if the processed mail address is invalid.
+               return 1 unless($addr =~ '^([a-zA-Z][\w\_\.]{6,15})\@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,4})$');
+       }
+
+       # Return nothing if the address is valid.
+       return;
+}
index e1ed11a0e30aa278906153a89cd8714b64632b79..00da6a453b78192b0481f1973c2c56d25e6bb29b 100644 (file)
 'ids force ruleset update' => 'Regelset jetzt aktualisieren',
 'ids hide' => 'Verstecken',
 'ids ignored hosts' => 'Ausnahmeliste',
+'ids invalid mail address' => 'Ist oder enthält eine ungültige E-Mail Addresse',
 'ids log hits' => 'Gesamtanzahl der Regeltreffer für',
 'ids log viewer' => 'Protokoll des Einbruchsverhinderungssystems',
 'ids logs' => 'IPS-Protokolldateien',
 'ids merge sid files' => 'Sid-to-message Dateien zusammenführen...',
 'ids monitor traffic only' => 'Netzwerkpakete nur überprüfen (nicht verwerfen)',
 'ids monitored interfaces' => 'Überwachte Netzwerkzonen',
+'ids no email recipients' => 'Keine Empfänger-Addresse angegeben',
+'ids no email sender' => 'Keine Sender-Addresse angegeben',
 'ids no enabled ruleset provider' => 'Es ist kein aktivierter Provider verfügbar. Bitte aktivieren Sie einen oder fügen Sie einen Provider hinzu.',
 'ids no network zone' => 'Bitte wählen Sie mindestens eine zu überwachende Netzwerkzone aus',
 'ids oinkcode required' => 'Für den ausgewählten Regelsatz wird ein Abonnement oder ein Oinkcode benötigt',
index 1712ba2a1bc611540dfdc674100455b02b3e8fba..89989026b7c4fe6acb2d85fb2f517f82f77abf63 100644 (file)
 'ids force ruleset update' => 'Force ruleset update',
 'ids hide' => 'Hide',
 'ids ignored hosts' => 'Whitelisted Hosts',
+'ids invalid mail address' => 'Is or contains an invalid mail address.',
 'ids log hits' => 'Total of number of activated rules for',
 'ids log viewer' => 'IPS Log Viewer',
 'ids logs' => 'IPS Logs',
 'ids merge sid files' => 'Merging sid to message files...',
 'ids monitor traffic only' => 'Monitor traffic only',
 'ids monitored interfaces' => 'Monitored Interfaces',
+'ids no email recipients' => 'No email recipients given',
+'ids no email sender' => 'No sender email address specified',
 'ids no enabled ruleset provider' => 'No enabled ruleset is available. Please activate or add one first.',
 'ids no network zone' => 'Please select at least one network zone to be monitored',
 'ids provider' => 'Provider',