fix: host_silence proactive notify when event is None
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -114,6 +114,13 @@ def dispatch_host_silence_notifications(db: Session, results: list[HostSilenceSc
|
||||
for item in results:
|
||||
if not item.created:
|
||||
continue
|
||||
notify_problem(item.problem, event=None, db=db)
|
||||
sent += 1
|
||||
try:
|
||||
notify_problem(item.problem, event=None, db=db)
|
||||
sent += 1
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"host_silence notify failed host=%s problem_id=%s",
|
||||
item.hostname,
|
||||
item.problem.id,
|
||||
)
|
||||
return sent
|
||||
|
||||
@@ -543,8 +543,6 @@ def format_problem_telegram_html(problem: Problem, event: Event | None = None) -
|
||||
msg += f"\n<b>{html_escape(problem.title)}</b>\n{html_escape(problem.summary)}"
|
||||
if event is not None:
|
||||
msg += f"\n\n<i>Триггер:</i> {html_escape(event.type)} ({html_escape(event.severity)})"
|
||||
elif problem.rule_id == "rule:host_silence":
|
||||
msg += "\n\n<i>Триггер:</i> периодическая проверка SAC (host_silence scan)"
|
||||
if event.type in (
|
||||
"rdp.login.success",
|
||||
"rdp.login.failed",
|
||||
@@ -557,4 +555,6 @@ def format_problem_telegram_html(problem: Problem, event: Event | None = None) -
|
||||
"smb.admin_share.access",
|
||||
):
|
||||
msg += "\n" + _format_event_body_html(event)
|
||||
elif problem.rule_id == "rule:host_silence":
|
||||
msg += "\n\n<i>Триггер:</i> периодическая проверка SAC (host_silence scan)"
|
||||
return append_notification_source_html(msg, generated_by="sac")
|
||||
|
||||
Reference in New Issue
Block a user