feat: SAC Telegram settings view, notify_problem severity gate, exclusive docs

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-29 15:57:35 +10:00
parent 117390cbca
commit e0ba384705
11 changed files with 291 additions and 9 deletions
+25 -1
View File
@@ -46,6 +46,30 @@ $SacSpoolDir = "D:\Soft\Logs\sac-spool"
- `UseSAC≠off` — обязательны `SAC_URL`, `SAC_API_KEY`; HTTP `GET {base}/health` OK.
- `--check-sac` / `Test-SacConnection` — отправка `agent.test`, ожидание **HTTP 201** (повтор с тем же `event_id`**409**, тоже успех для spool).
### 1.3.1. Telegram и email при `UseSAC=exclusive`
При **`exclusive`** агент **не** шлёт Telegram/email — оператору нужны оповещения **из SAC** (`backend/app/services/telegram_notify.py`).
На сервере SAC в **`/opt/security-alert-center/config/sac-api.env`** (см. `deploy/env.native.example`):
```env
TELEGRAM_ENABLED=true
TELEGRAM_BOT_TOKEN=<bot>
TELEGRAM_CHAT_ID=<chat>
# warning — failed login, sudo, problems; high — только high/critical
TELEGRAM_MIN_SEVERITY=warning
```
| Severity события | `warning` | `high` (по умолчанию в example) |
|------------------|-----------|----------------------------------|
| `info` (успешный RDP/SSH login) | нет | нет |
| `warning` (`*.login.failed`, sudo) | **да** | нет |
| `high` / `critical` (ban, problem) | **да** | **да** |
Problems (`notify_problem`) учитывают тот же порог `TELEGRAM_MIN_SEVERITY`.
UI **Настройки** (`/settings`) — просмотр маскированной конфигурации; запись в env — до задачи `notif-12` (БД) или правка `sac-api.env` + restart `sac-api`.
### 1.4. Версии и доставка обновлений
При **любом** изменении агента, влияющем на SAC или поведение на хосте, поднимайте версию и пушьте в **git.kalinamall.ru**:
@@ -53,7 +77,7 @@ $SacSpoolDir = "D:\Soft\Logs\sac-spool"
| Агент | Маркер версии | Как хост узнаёт о новой версии |
|-------|---------------|--------------------------------|
| **ssh-monitor** | `SSH_MONITOR_VERSION` в `ssh-monitor`; `# SAC client release:` в `sac-client.sh` | `update_ssh_monitor.sh`: `git pull` в клоне → сравнение sha256 `ssh-monitor` и `sac-client.sh` |
| **RDP-login-monitor** | `$ScriptVersion` в `Login_Monitor.ps1` и **та же** строка в `version.txt` на шаре NETLOGON | `Deploy-LoginMonitor.ps1`: `version.txt` на шаре > `deployed_version.txt` → копирует `Login_Monitor.ps1` и `Sac-Client.ps1` |
| **RDP-login-monitor** | `$ScriptVersion` в `Login_Monitor.ps1` и **та же** строка в `version.txt` на шаре NETLOGON | `Deploy-LoginMonitor.ps1`: сверка `version.txt` и SHA256 пакета (`Login_Monitor.ps1`, `Sac-Client.ps1`); при отсутствии SAC в settings — **`UseSAC=dual`** из example; подсказка `# $ServerDisplayName` |
**Кириллица в SAC (RDP):** до **1.2.8-SAC** `Invoke-WebRequest` мог слать JSON не в UTF-8 — в UI «Отчёты» summary вида `RDP 24?: ??????` вместо `RDP 24ч: сессий …`. Обновите `Sac-Client.ps1` на всех хостах; старые события в БД не пересчитываются, исправятся только новые ingest после деплоя.