]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
suricata-report-cron: Send reports to custom recipients if configured
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 3 Feb 2026 19:01:10 +0000 (19:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 3 Feb 2026 19:01:10 +0000 (19:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/suricata/suricata-report-cron

index 3aa4cc8f89896df17f82755dc7cbde8b6a921509..eb802a8cb423c13f5532ca2f45cc2a879af80987 100644 (file)
@@ -27,7 +27,6 @@ readhash CONFIG "/var/ipfire/suricata/settings"
 
 send_report() {
        local args=( "$@" )
-       local address
 
        # Add the email sender
        if [ -n "${CONFIG[EMAIL_SENDER]}" ]; then
@@ -39,13 +38,6 @@ send_report() {
                return 2
        fi
 
-       local IFS=','
-
-       # Append the email recipients
-       for address in ${CONFIG[EMAIL_RECIPIENTS]}; do
-               args+=( "--email-recipient=${address}" )
-       done
-
        # Generate the report
        if ! suricata-report-generator "${args[@]}"; then
                return 1
@@ -69,7 +61,7 @@ send_monthly_report() {
        local m="$(date --date="last month" +"%m")"
 
        # Send the report
-       send_report --year="${y}" --month="${m}"
+       send_report --year="${y}" --month="${m}" $(fetch_recipients monthly)
 }
 
 send_weekly_report() {
@@ -87,7 +79,7 @@ send_weekly_report() {
        local w="$(date --date="last week" +"%V")"
 
        # Send the report
-       send_report --year="${y}" --week="${w}"
+       send_report --year="${y}" --week="${w}" $(fetch_recipients weekly)
 }
 
 # Sends a daily report for "yesterday"
@@ -107,7 +99,24 @@ send_daily_report() {
        local d="$(date --date="yesterday" +"%d")"
 
        # Send the report
-       send_report --year="${y}" --month="${m}" --day="${d}"
+       send_report --year="${y}" --month="${m}" --day="${d}" $(fetch_recipients daily)
+}
+
+fetch_recipients() {
+       local interval="${1}"
+
+       local recipients="${CONFIG[EMAIL_RECIPIENTS_REPORT_${interval^^}]:-${CONFIG[EMAIL_RECIPIENTS]}}"
+
+       # Parse this as an array
+       read -ra recipients <<< "${recipients//,/ }"
+
+       # Return all recipients
+       local recipient
+       for recipient in ${recipients[@]}; do
+               echo "--email-recipient=${recipient}"
+       done
+
+       return 0
 }
 
 main() {