Merge branch 'ent-8032-giss-cambiar-comando-de-alerta-para-que-descarte-cualquier-string-que-no-parezca-una-direccion' into 'develop'

Add simple email address validation.

See merge request artica/pandorafms!4417
This commit is contained in:
Daniel Rodriguez 2021-09-22 12:33:18 +00:00
commit 1aabb11c8c
1 changed files with 7 additions and 0 deletions

View File

@ -1381,6 +1381,13 @@ sub pandora_execute_action ($$$$$$$$$;$) {
# Address # Address
$field1 = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module, $alert); $field1 = subst_alert_macros ($field1, \%macros, $pa_config, $dbh, $agent, $module, $alert);
# Simple email address validation. Prevents connections to the SMTP server when no address is provided.
if (index($field1, '@') == -1) {
logger($pa_config, "No valid email address provided for action '" . $action->{'name'} . "' alert '". $alert->{'name'} . "' agent '" . (defined ($agent) ? $agent->{'alias'} : 'N/A') . "'.", 10);
return;
}
# Subject # Subject
$field2 = subst_alert_macros ($field2, \%macros, $pa_config, $dbh, $agent, $module, $alert); $field2 = subst_alert_macros ($field2, \%macros, $pa_config, $dbh, $agent, $module, $alert);
# Message # Message