Compare commits
242 Commits
main
..
d95b93992d
| Author | SHA1 | Date | |
|---|---|---|---|
| d95b93992d | |||
| d20517804d | |||
| 91bd6afd1f | |||
| dd2356cf04 | |||
| 3475c1811b | |||
| 91be282ec6 | |||
| 310e7f699d | |||
| e7d5b1c60b | |||
| 69fac2f26e | |||
| c222dd7d41 | |||
| 6565b7d679 | |||
| b148b558c3 | |||
| 1ad01534f1 | |||
| 253b80c500 | |||
| f569293d52 | |||
| d47131cd9f | |||
| 1639261cde | |||
| fa1bd41c92 | |||
| 3cabf12f68 | |||
| 9bfc5e23f7 | |||
| 9e43de6fc1 | |||
| 80320ae698 | |||
| 939fe122c5 | |||
| c72e510fb0 | |||
| 6c43b8637e | |||
| 3765d4d476 | |||
| 10ae670962 | |||
| daeb7e965d | |||
| 606bf53019 | |||
| fd1be5e7e4 | |||
| 5a7909bb55 | |||
| 86fd400f0b | |||
| dd2ae51b43 | |||
| 719d5c5719 | |||
| bda02f67eb | |||
| 9053ef0588 | |||
| 0601aafd2d | |||
| 8b3e43f30d | |||
| 6330f31162 | |||
| b47cbf03c5 | |||
| 407ef37004 | |||
| 64b942447b | |||
| 8b52c5fe3c | |||
| fbd213f323 | |||
| 1b96a3b2c7 | |||
| 24ca87a47a | |||
| 4eb41608ea | |||
| 6e3f0ede4d | |||
| fe818e9946 | |||
| 5e26834e16 | |||
| 54c1d96933 | |||
| a51a585b14 | |||
| fc66b57e78 | |||
| ad2425b0ff | |||
| d848d94604 | |||
| ca0255e13b | |||
| d96d9d6333 | |||
| 7397ec30cd | |||
| 75eec35365 | |||
| b3d28cd5d8 | |||
| 5bd1333928 | |||
| bf7c83c408 | |||
| 87ac1e09b0 | |||
| 8adaf3bfd3 | |||
| 8a451a0c49 | |||
| 5635be1322 | |||
| d7bbcc5337 | |||
| f3a8952947 | |||
| 4d9a9e7e2b | |||
| 9484160045 | |||
| 6acbfe22de | |||
| ca90f5c296 | |||
| 191fb4e2cf | |||
| 8c1a8fddb1 | |||
| 05408e17c3 | |||
| d3517a5706 | |||
| 2c2f78eba9 | |||
| ec5ec62240 | |||
| 115289ef35 | |||
| fc9d630263 | |||
| 01d72d0f68 | |||
| a35e50ccd1 | |||
| 34a1670ea9 | |||
| c21043d845 | |||
| 07b97bd111 | |||
| f411d8f070 | |||
| d820d941c1 | |||
| cd2f27792d | |||
| 75f4c475df | |||
| 2eb06acb5b | |||
| 6fea8262fb | |||
| 2e839e0b16 | |||
| cc8f50de89 | |||
| 279ea925a8 | |||
| c8e3eef9d7 | |||
| 2fe492b06b | |||
| 154ba3efc2 | |||
| df4c93d243 | |||
| db95be39f3 | |||
| 2aec488226 | |||
| b328d32f97 | |||
| 308e075f35 | |||
| 63cc2954af | |||
| 45f45145f0 | |||
| 55f047cd35 | |||
| 8a97bbfb43 | |||
| 2069e57f14 | |||
| 6b288bfa49 | |||
| 6bff073108 | |||
| 06c6748274 | |||
| eac1e0b59e | |||
| 36ccfc9471 | |||
| 5b2aeb0183 | |||
| 3d36faa49d | |||
| e022f2f213 | |||
| f0bd31c544 | |||
| 87549731c8 | |||
| 7df718eed3 | |||
| befaf86bf4 | |||
| fed21c536b | |||
| 3f671b9899 | |||
| 3f7095ed03 | |||
| 37bffe0e3f | |||
| 0a414a0904 | |||
| e38bd8a52a | |||
| f9baf96d88 | |||
| 5e9f0f8110 | |||
| e2b5fb7604 | |||
| 563b836acc | |||
| 86c602cf07 | |||
| 77e167b6e3 | |||
| f9d56621f6 | |||
| e65daa8c3b | |||
| aafb80fa31 | |||
| 2a0eb6e90c | |||
| 459b2babd1 | |||
| 95c5b9f25a | |||
| 02200f1a80 | |||
| 502971367e | |||
| d9893497ce | |||
| adfc69c656 | |||
| 7699d8690a | |||
| 54337a5917 | |||
| 5d3cda2ab6 | |||
| 57793d24ba | |||
| d324e41eba | |||
| 1580982d88 | |||
| d8ba864e48 | |||
| 7ab497b300 | |||
| 2d39943020 | |||
| 79185d9186 | |||
| 47d08b54d2 | |||
| b565a259ea | |||
| 0d4a50cd35 | |||
| 3053058cdf | |||
| cf5a6f995c | |||
| 141fc44099 | |||
| d3a337992c | |||
| 06a8ed8614 | |||
| de29270a25 | |||
| 8de5d14cfb | |||
| 56c469ddbd | |||
| bc77f82307 | |||
| 7e13be3c38 | |||
| fbef1e2f4b | |||
| 4baa2b426f | |||
| 9dacbd7944 | |||
| 366a9c83f7 | |||
| 3d4d1f3c76 | |||
| a45b641b8c | |||
| 799f8668e6 | |||
| 2501ecc4fe | |||
| eba2f0d15c | |||
| 7ebbb9a9d1 | |||
| 11195ae64f | |||
| 2670c8cb46 | |||
| 0baeacf808 | |||
| 42f31b3bb5 | |||
| 415d863b3b | |||
| 4167687dec | |||
| 1a70980920 | |||
| ebb450be92 | |||
| 9b177c145b | |||
| 20fa7e2c27 | |||
| f7b5fff04e | |||
| 79a78dc7c9 | |||
| e0ba384705 | |||
| 117390cbca | |||
| a42a63b8fa | |||
| daec333dbe | |||
| ac3c20b7db | |||
| dce5b88b2f | |||
| 81cf9c46b3 | |||
| d4bf6e536c | |||
| 108e1756c4 | |||
| 9ed0670863 | |||
| fcf3da223c | |||
| f322a46f98 | |||
| a218ff2581 | |||
| 98055dfdf8 | |||
| c8f357007f | |||
| 249894d8e1 | |||
| 64b5ef297a | |||
| 83f48dce97 | |||
| a4a224b284 | |||
| 8eb40cf75d | |||
| 4d603637e5 | |||
| e0b066f5e5 | |||
| 25a485fabb | |||
| 2b76ae8497 | |||
| 5cf76f492c | |||
| d1b89c75dd | |||
| 721de21d5c | |||
| 8995a34037 | |||
| 61c9f9b673 | |||
| 04301ab359 | |||
| 9ba3c4b63b | |||
| b404747f8d | |||
| c657a65970 | |||
| ea221db3c7 | |||
| eeba3a704d | |||
| 5fce00faae | |||
| b19cdf2b47 | |||
| 947fc4ab98 | |||
| 4265d58c4b | |||
| a4bbc14448 | |||
| bdfc7016e6 | |||
| d8a8329397 | |||
| a9bea3d276 | |||
| 0c5d2537db | |||
| 21578b27c9 | |||
| 2c12f161a1 | |||
| 934a5a0c9c | |||
| 539126b75e | |||
| 38c137cbd3 | |||
| 6d33669ac2 | |||
| 69547d83bc | |||
| 9203af90d5 | |||
| 69a232d08a | |||
| bf1c1c9fe9 | |||
| 2f82c7c658 | |||
| 4f3adc9429 |
@@ -1,4 +1,4 @@
|
|||||||
# Security Alert Center (SAC)
|
# Security Alert Center (SAC)
|
||||||
|
|
||||||
Центральная платформа: приём событий от агентов, корреляция, UI, оповещения, управление хостами.
|
Центральная платформа: приём событий от агентов, корреляция, UI, оповещения, управление хостами.
|
||||||
|
|
||||||
@@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
| Репозиторий | Назначение |
|
| Репозиторий | Назначение |
|
||||||
|-------------|------------|
|
|-------------|------------|
|
||||||
| [ssh-monitor](https://git.papatramp.ru/PapaTramp/ssh-monitor) | Linux-агент |
|
| [ssh-monitor](https://git.kalinamall.ru/PapaTramp/ssh-monitor) | Linux-агент |
|
||||||
| [RDP-login-monitor](https://git.papatramp.ru/PapaTramp/RDP-login-monitor) | Windows-агент |
|
| [RDP-login-monitor](https://git.kalinamall.ru/PapaTramp/RDP-login-monitor) | Windows-агент |
|
||||||
| **security-alert-center** | Сервер SAC (Ubuntu 24.04) |
|
| **security-alert-center** | Сервер SAC (Ubuntu 24.04) |
|
||||||
| [seaca](https://git.papatramp.ru/PapaTramp/seaca) | Android-клиент |
|
| [seaca](https://git.kalinamall.ru/PapaTramp/seaca) | Android-клиент |
|
||||||
|
|
||||||
**Версия:** `0.5.16` · **Деплой:** `sudo /opt/sac-deploy.sh`
|
**Версия:** `0.5.14` · **Деплой:** `sudo /opt/sac-deploy.sh`
|
||||||
|
|
||||||
## Возможности
|
## Возможности
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
## Быстрый старт
|
## Быстрый старт
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.papatramp.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
git clone https://git.kalinamall.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
||||||
# deploy/env.native.example → config/sac-api.env (JWT_SECRET, CORS_ORIGINS, SAC_SECURITY_ENFORCE)
|
# deploy/env.native.example → config/sac-api.env (JWT_SECRET, CORS_ORIGINS, SAC_SECURITY_ENFORCE)
|
||||||
cd /opt/security-alert-center/backend && python3 -m venv .venv
|
cd /opt/security-alert-center/backend && python3 -m venv .venv
|
||||||
.venv/bin/pip install -r requirements.txt && .venv/bin/alembic upgrade head
|
.venv/bin/pip install -r requirements.txt && .venv/bin/alembic upgrade head
|
||||||
|
|||||||
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
# Security Alert Center (SAC)
|
# Security Alert Center (SAC)
|
||||||
|
|
||||||
Self-hosted hub for security events from Linux and Windows agents: ingest, correlation, UI, notifications, host management.
|
Self-hosted hub for security events from Linux and Windows agents: ingest, correlation, UI, notifications, host management.
|
||||||
|
|
||||||
@@ -8,12 +8,12 @@ Self-hosted hub for security events from Linux and Windows agents: ingest, corre
|
|||||||
|
|
||||||
| Repository | Role |
|
| Repository | Role |
|
||||||
|------------|------|
|
|------------|------|
|
||||||
| [ssh-monitor](https://git.papatramp.ru/PapaTramp/ssh-monitor) | Linux agent |
|
| [ssh-monitor](https://git.kalinamall.ru/PapaTramp/ssh-monitor) | Linux agent |
|
||||||
| [RDP-login-monitor](https://git.papatramp.ru/PapaTramp/RDP-login-monitor) | Windows agent |
|
| [RDP-login-monitor](https://git.kalinamall.ru/PapaTramp/RDP-login-monitor) | Windows agent |
|
||||||
| **security-alert-center** | SAC server (Ubuntu 24.04) |
|
| **security-alert-center** | SAC server (Ubuntu 24.04) |
|
||||||
| [seaca](https://git.papatramp.ru/PapaTramp/seaca) | Android client |
|
| [seaca](https://git.kalinamall.ru/PapaTramp/seaca) | Android client |
|
||||||
|
|
||||||
**Version:** `0.5.16` · **Deploy:** `sudo /opt/sac-deploy.sh`
|
**Version:** `0.5.14` · **Deploy:** `sudo /opt/sac-deploy.sh`
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ Self-hosted hub for security events from Linux and Windows agents: ingest, corre
|
|||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.papatramp.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
git clone https://git.kalinamall.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
||||||
# deploy/env.native.example → config/sac-api.env
|
# deploy/env.native.example → config/sac-api.env
|
||||||
cd /opt/security-alert-center/backend && python3 -m venv .venv
|
cd /opt/security-alert-center/backend && python3 -m venv .venv
|
||||||
.venv/bin/pip install -r requirements.txt && .venv/bin/alembic upgrade head
|
.venv/bin/pip install -r requirements.txt && .venv/bin/alembic upgrade head
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
"""per-host management credentials (SSH / WinRM override)
|
|
||||||
|
|
||||||
Revision ID: 027_host_mgmt_credentials
|
|
||||||
Revises: 026_host_silence_dedupe
|
|
||||||
Create Date: 2026-07-14
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
revision = "027_host_mgmt_credentials"
|
|
||||||
down_revision = "026_host_silence_dedupe"
|
|
||||||
branch_labels = None
|
|
||||||
depends_on = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
|
||||||
op.add_column("hosts", sa.Column("mgmt_user", sa.String(length=256), nullable=True))
|
|
||||||
op.add_column("hosts", sa.Column("mgmt_password", sa.Text(), nullable=True))
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
|
||||||
op.drop_column("hosts", "mgmt_password")
|
|
||||||
op.drop_column("hosts", "mgmt_user")
|
|
||||||
@@ -28,12 +28,12 @@ from app.services.host_sessions import (
|
|||||||
mark_event_session_terminated,
|
mark_event_session_terminated,
|
||||||
terminate_session_for_event,
|
terminate_session_for_event,
|
||||||
)
|
)
|
||||||
from app.services.linux_admin_settings import get_effective_linux_admin_for_host
|
from app.services.linux_admin_settings import get_effective_linux_admin_config
|
||||||
from app.services.ssh_connect import (
|
from app.services.ssh_connect import (
|
||||||
HostNotLinuxError as SshHostNotLinuxError,
|
HostNotLinuxError as SshHostNotLinuxError,
|
||||||
HostTargetMissingError as SshHostTargetMissingError,
|
HostTargetMissingError as SshHostTargetMissingError,
|
||||||
)
|
)
|
||||||
from app.services.win_admin_settings import get_effective_win_admin_for_host
|
from app.services.win_admin_settings import get_effective_win_admin_config
|
||||||
from app.services.winrm_connect import HostNotWindowsError, HostTargetMissingError
|
from app.services.winrm_connect import HostNotWindowsError, HostTargetMissingError
|
||||||
from app.services.ingest import ingest_event
|
from app.services.ingest import ingest_event
|
||||||
from app.services.event_summary import event_to_summary
|
from app.services.event_summary import event_to_summary
|
||||||
@@ -284,10 +284,8 @@ def post_event_terminate_session(
|
|||||||
if event_session_terminated(event, db=db):
|
if event_session_terminated(event, db=db):
|
||||||
raise HTTPException(status_code=409, detail="Session already terminated for this event")
|
raise HTTPException(status_code=409, detail="Session already terminated for this event")
|
||||||
|
|
||||||
if event.host is None:
|
linux_cfg = get_effective_linux_admin_config(db)
|
||||||
raise HTTPException(status_code=400, detail="Event has no host")
|
win_cfg = get_effective_win_admin_config(db)
|
||||||
linux_cfg = get_effective_linux_admin_for_host(db, event.host)
|
|
||||||
win_cfg = get_effective_win_admin_for_host(db, event.host)
|
|
||||||
sid = (body.session_id if body else None) or event_session_id(event)
|
sid = (body.session_id if body else None) or event_session_id(event)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
+16
-109
@@ -46,12 +46,8 @@ from app.services.host_sessions import (
|
|||||||
terminate_windows_session,
|
terminate_windows_session,
|
||||||
)
|
)
|
||||||
from app.services.host_delete import delete_host_and_related
|
from app.services.host_delete import delete_host_and_related
|
||||||
from app.services.host_mgmt_credentials import (
|
from app.services.linux_admin_settings import get_effective_linux_admin_config
|
||||||
get_host_mgmt_access_view,
|
from app.services.win_admin_settings import get_effective_win_admin_config
|
||||||
upsert_host_mgmt_credentials,
|
|
||||||
)
|
|
||||||
from app.services.linux_admin_settings import get_effective_linux_admin_for_host
|
|
||||||
from app.services.win_admin_settings import get_effective_win_admin_for_host
|
|
||||||
from app.services.winrm_connect import (
|
from app.services.winrm_connect import (
|
||||||
HostNotWindowsError,
|
HostNotWindowsError,
|
||||||
HostTargetMissingError,
|
HostTargetMissingError,
|
||||||
@@ -303,23 +299,6 @@ class HostAgentConfigResponse(BaseModel):
|
|||||||
settings: dict[str, object]
|
settings: dict[str, object]
|
||||||
|
|
||||||
|
|
||||||
class HostMgmtAccessResponse(BaseModel):
|
|
||||||
host_id: int
|
|
||||||
has_override: bool
|
|
||||||
user: str | None = None
|
|
||||||
password_set: bool = False
|
|
||||||
password_hint: str | None = None
|
|
||||||
effective_source: str
|
|
||||||
effective_configured: bool
|
|
||||||
effective_user: str | None = None
|
|
||||||
|
|
||||||
|
|
||||||
class HostMgmtAccessUpdate(BaseModel):
|
|
||||||
user: str | None = None
|
|
||||||
password: str | None = None
|
|
||||||
clear: bool = False
|
|
||||||
|
|
||||||
|
|
||||||
class HostRemoteActionStartResponse(BaseModel):
|
class HostRemoteActionStartResponse(BaseModel):
|
||||||
status: str
|
status: str
|
||||||
host_id: int
|
host_id: int
|
||||||
@@ -490,12 +469,9 @@ def test_host_winrm(
|
|||||||
if host is None:
|
if host is None:
|
||||||
raise HTTPException(status_code=404, detail="Host not found")
|
raise HTTPException(status_code=404, detail="Host not found")
|
||||||
|
|
||||||
cfg = get_effective_win_admin_for_host(db, host)
|
cfg = get_effective_win_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=400, detail="Windows domain admin is not configured")
|
||||||
status_code=400,
|
|
||||||
detail="Windows admin is not configured (host override or Settings → Windows)",
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
targets = iter_winrm_targets(host)
|
targets = iter_winrm_targets(host)
|
||||||
@@ -556,12 +532,9 @@ def test_host_ssh(
|
|||||||
if host is None:
|
if host is None:
|
||||||
raise HTTPException(status_code=404, detail="Host not found")
|
raise HTTPException(status_code=404, detail="Host not found")
|
||||||
|
|
||||||
cfg = get_effective_linux_admin_for_host(db, host)
|
cfg = get_effective_linux_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=400, detail="Linux SSH admin is not configured")
|
||||||
status_code=400,
|
|
||||||
detail="Linux SSH admin is not configured (host override or Settings → Linux)",
|
|
||||||
)
|
|
||||||
|
|
||||||
response = _run_ssh_action_on_host(host, cfg, action=test_ssh_connection)
|
response = _run_ssh_action_on_host(host, cfg, action=test_ssh_connection)
|
||||||
_set_ssh_admin_status(host, response.ok)
|
_set_ssh_admin_status(host, response.ok)
|
||||||
@@ -583,12 +556,9 @@ def update_host_agent_via_ssh(
|
|||||||
if host is None:
|
if host is None:
|
||||||
raise HTTPException(status_code=404, detail="Host not found")
|
raise HTTPException(status_code=404, detail="Host not found")
|
||||||
|
|
||||||
cfg = get_effective_linux_admin_for_host(db, host)
|
cfg = get_effective_linux_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=400, detail="Linux SSH admin is not configured")
|
||||||
status_code=400,
|
|
||||||
detail="Linux SSH admin is not configured (host override or Settings → Linux)",
|
|
||||||
)
|
|
||||||
|
|
||||||
title = "Обновление ssh-monitor (SSH)"
|
title = "Обновление ssh-monitor (SSH)"
|
||||||
try:
|
try:
|
||||||
@@ -716,12 +686,9 @@ def list_host_sessions(
|
|||||||
from app.services.winrm_connect import is_windows_host
|
from app.services.winrm_connect import is_windows_host
|
||||||
|
|
||||||
if is_linux_host(host):
|
if is_linux_host(host):
|
||||||
cfg = get_effective_linux_admin_for_host(db, host)
|
cfg = get_effective_linux_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=400, detail="Linux SSH admin is not configured")
|
||||||
status_code=400,
|
|
||||||
detail="Linux SSH admin is not configured (host override or Settings → Linux)",
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
sessions, result = list_linux_sessions(host, cfg)
|
sessions, result = list_linux_sessions(host, cfg)
|
||||||
except SshHostNotLinuxError as exc:
|
except SshHostNotLinuxError as exc:
|
||||||
@@ -736,12 +703,9 @@ def list_host_sessions(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if is_windows_host(host):
|
if is_windows_host(host):
|
||||||
cfg = get_effective_win_admin_for_host(db, host)
|
cfg = get_effective_win_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=400, detail="Windows domain admin is not configured")
|
||||||
status_code=400,
|
|
||||||
detail="Windows admin is not configured (host override or Settings → Windows)",
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
sessions, result = list_windows_sessions(host, cfg)
|
sessions, result = list_windows_sessions(host, cfg)
|
||||||
except HostNotWindowsError as exc:
|
except HostNotWindowsError as exc:
|
||||||
@@ -779,12 +743,9 @@ def terminate_host_session(
|
|||||||
raise HTTPException(status_code=422, detail="session_id is required")
|
raise HTTPException(status_code=422, detail="session_id is required")
|
||||||
|
|
||||||
if is_linux_host(host):
|
if is_linux_host(host):
|
||||||
cfg = get_effective_linux_admin_for_host(db, host)
|
cfg = get_effective_linux_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=400, detail="Linux SSH admin is not configured")
|
||||||
status_code=400,
|
|
||||||
detail="Linux SSH admin is not configured (host override or Settings → Linux)",
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
result = terminate_linux_session(host, cfg, sid)
|
result = terminate_linux_session(host, cfg, sid)
|
||||||
except SshHostNotLinuxError as exc:
|
except SshHostNotLinuxError as exc:
|
||||||
@@ -800,12 +761,9 @@ def terminate_host_session(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if is_windows_host(host):
|
if is_windows_host(host):
|
||||||
cfg = get_effective_win_admin_for_host(db, host)
|
cfg = get_effective_win_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=400, detail="Windows domain admin is not configured")
|
||||||
status_code=400,
|
|
||||||
detail="Windows admin is not configured (host override or Settings → Windows)",
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
result = terminate_windows_session(host, cfg, sid)
|
result = terminate_windows_session(host, cfg, sid)
|
||||||
except HostNotWindowsError as exc:
|
except HostNotWindowsError as exc:
|
||||||
@@ -845,57 +803,6 @@ def patch_host_agent_config(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{host_id}/access", response_model=HostMgmtAccessResponse)
|
|
||||||
def get_host_access(
|
|
||||||
host_id: int,
|
|
||||||
db: Session = Depends(get_db),
|
|
||||||
_user=Depends(require_admin),
|
|
||||||
) -> HostMgmtAccessResponse:
|
|
||||||
host = db.get(Host, host_id)
|
|
||||||
if host is None:
|
|
||||||
raise HTTPException(status_code=404, detail="Host not found")
|
|
||||||
view = get_host_mgmt_access_view(db, host)
|
|
||||||
return HostMgmtAccessResponse(
|
|
||||||
host_id=view.host_id,
|
|
||||||
has_override=view.has_override,
|
|
||||||
user=view.user,
|
|
||||||
password_set=view.password_set,
|
|
||||||
password_hint=view.password_hint,
|
|
||||||
effective_source=view.effective_source,
|
|
||||||
effective_configured=view.effective_configured,
|
|
||||||
effective_user=view.effective_user,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.put("/{host_id}/access", response_model=HostMgmtAccessResponse)
|
|
||||||
def put_host_access(
|
|
||||||
host_id: int,
|
|
||||||
body: HostMgmtAccessUpdate,
|
|
||||||
db: Session = Depends(get_db),
|
|
||||||
_user=Depends(require_admin),
|
|
||||||
) -> HostMgmtAccessResponse:
|
|
||||||
host = db.get(Host, host_id)
|
|
||||||
if host is None:
|
|
||||||
raise HTTPException(status_code=404, detail="Host not found")
|
|
||||||
view = upsert_host_mgmt_credentials(
|
|
||||||
db,
|
|
||||||
host,
|
|
||||||
user=body.user,
|
|
||||||
password=body.password,
|
|
||||||
clear=body.clear,
|
|
||||||
)
|
|
||||||
return HostMgmtAccessResponse(
|
|
||||||
host_id=view.host_id,
|
|
||||||
has_override=view.has_override,
|
|
||||||
user=view.user,
|
|
||||||
password_set=view.password_set,
|
|
||||||
password_hint=view.password_hint,
|
|
||||||
effective_source=view.effective_source,
|
|
||||||
effective_configured=view.effective_configured,
|
|
||||||
effective_user=view.effective_user,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{host_id}/agent-config", response_model=HostAgentConfigResponse)
|
@router.get("/{host_id}/agent-config", response_model=HostAgentConfigResponse)
|
||||||
def get_host_agent_config(
|
def get_host_agent_config(
|
||||||
host_id: int,
|
host_id: int,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -138,8 +138,8 @@ class Settings(BaseSettings):
|
|||||||
sac_agent_min_rdp_version: str = ""
|
sac_agent_min_rdp_version: str = ""
|
||||||
sac_agent_min_ssh_version: str = ""
|
sac_agent_min_ssh_version: str = ""
|
||||||
sac_win_agent_update_script: str = ""
|
sac_win_agent_update_script: str = ""
|
||||||
sac_agent_rdp_git_repo_url: str = "https://git.papatramp.ru/PapaTramp/RDP-login-monitor.git"
|
sac_agent_rdp_git_repo_url: str = "https://git.kalinamall.ru/PapaTramp/RDP-login-monitor.git"
|
||||||
sac_agent_ssh_git_repo_url: str = "https://git.papatramp.ru/PapaTramp/ssh-monitor.git"
|
sac_agent_ssh_git_repo_url: str = "https://git.kalinamall.ru/PapaTramp/ssh-monitor.git"
|
||||||
sac_agent_git_branch: str = "main"
|
sac_agent_git_branch: str = "main"
|
||||||
sac_agent_git_cache_dir: str = "/opt/security-alert-center/cache/agent-repos"
|
sac_agent_git_cache_dir: str = "/opt/security-alert-center/cache/agent-repos"
|
||||||
sac_agent_git_cache_ttl_minutes: int = 30
|
sac_agent_git_cache_ttl_minutes: int = 30
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ class Host(Base):
|
|||||||
use_sac_mode: Mapped[str | None] = mapped_column(String(32))
|
use_sac_mode: Mapped[str | None] = mapped_column(String(32))
|
||||||
ssh_admin_ok: Mapped[bool | None] = mapped_column(nullable=True)
|
ssh_admin_ok: Mapped[bool | None] = mapped_column(nullable=True)
|
||||||
ssh_admin_checked_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
ssh_admin_checked_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
||||||
# Optional override for SSH/WinRM (home PCs, unique local admin). Empty → global Settings.
|
|
||||||
mgmt_user: Mapped[str | None] = mapped_column(String(256))
|
|
||||||
mgmt_password: Mapped[str | None] = mapped_column(Text)
|
|
||||||
pending_agent_update: Mapped[bool] = mapped_column(default=False, server_default="false")
|
pending_agent_update: Mapped[bool] = mapped_column(default=False, server_default="false")
|
||||||
pending_update_requested_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
pending_update_requested_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
||||||
pending_update_target_version: Mapped[str | None] = mapped_column(String(64))
|
pending_update_target_version: Mapped[str | None] = mapped_column(String(64))
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ class EventSummary(BaseModel):
|
|||||||
title: str
|
title: str
|
||||||
summary: str
|
summary: str
|
||||||
actor_user: str | None = None
|
actor_user: str | None = None
|
||||||
session_duration_sec: int | None = None
|
|
||||||
rdg_flap: bool = False
|
rdg_flap: bool = False
|
||||||
rdg_flap_pair_event_id: int | None = None
|
rdg_flap_pair_event_id: int | None = None
|
||||||
rdg_flap_qwinsta_event_id: int | None = None
|
rdg_flap_qwinsta_event_id: int | None = None
|
||||||
|
|||||||
@@ -7,22 +7,17 @@ from datetime import datetime, timezone
|
|||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from app.config import get_settings
|
||||||
from app.models import AgentCommand, Host
|
from app.models import AgentCommand, Host
|
||||||
from app.services.win_admin_settings import (
|
from app.services.win_admin_settings import get_effective_win_admin_config
|
||||||
get_effective_win_admin_config,
|
|
||||||
get_effective_win_admin_for_host,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _win_admin_configured() -> bool:
|
def _win_admin_configured() -> bool:
|
||||||
return get_effective_win_admin_config().configured
|
return get_effective_win_admin_config().configured
|
||||||
|
|
||||||
|
|
||||||
def win_admin_run_as(db: Session | None = None, host: Host | None = None) -> dict[str, str] | None:
|
def win_admin_run_as() -> dict[str, str] | None:
|
||||||
if host is not None and db is not None:
|
cfg = get_effective_win_admin_config()
|
||||||
cfg = get_effective_win_admin_for_host(db, host)
|
|
||||||
else:
|
|
||||||
cfg = get_effective_win_admin_config(db)
|
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
return None
|
return None
|
||||||
return {
|
return {
|
||||||
@@ -31,13 +26,7 @@ def win_admin_run_as(db: Session | None = None, host: Host | None = None) -> dic
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def command_to_dict(
|
def command_to_dict(cmd: AgentCommand, *, include_run_as: bool = False) -> dict:
|
||||||
cmd: AgentCommand,
|
|
||||||
*,
|
|
||||||
include_run_as: bool = False,
|
|
||||||
db: Session | None = None,
|
|
||||||
host: Host | None = None,
|
|
||||||
) -> dict:
|
|
||||||
out = {
|
out = {
|
||||||
"id": cmd.command_uuid,
|
"id": cmd.command_uuid,
|
||||||
"type": cmd.command_type,
|
"type": cmd.command_type,
|
||||||
@@ -49,7 +38,7 @@ def command_to_dict(
|
|||||||
"completed_at": cmd.completed_at.isoformat() if cmd.completed_at else None,
|
"completed_at": cmd.completed_at.isoformat() if cmd.completed_at else None,
|
||||||
}
|
}
|
||||||
if include_run_as and cmd.status == "pending":
|
if include_run_as and cmd.status == "pending":
|
||||||
run_as = win_admin_run_as(db, host)
|
run_as = win_admin_run_as()
|
||||||
if run_as:
|
if run_as:
|
||||||
out["run_as"] = run_as
|
out["run_as"] = run_as
|
||||||
return out
|
return out
|
||||||
|
|||||||
@@ -27,5 +27,5 @@ def build_agent_poll_payload(db: Session, host: Host) -> dict[str, Any]:
|
|||||||
"config_revision": int(host.agent_config_revision or 0),
|
"config_revision": int(host.agent_config_revision or 0),
|
||||||
"config": config_payload,
|
"config": config_payload,
|
||||||
"update": update_block,
|
"update": update_block,
|
||||||
"commands": [command_to_dict(c, include_run_as=True, db=db, host=host) for c in pending],
|
"commands": [command_to_dict(c, include_run_as=True) for c in pending],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from app.services.agent_version import (
|
|||||||
host_version_outdated,
|
host_version_outdated,
|
||||||
latest_agent_versions_by_product,
|
latest_agent_versions_by_product,
|
||||||
)
|
)
|
||||||
from app.services.linux_admin_settings import get_effective_linux_admin_for_host
|
from app.services.linux_admin_settings import get_effective_linux_admin_config
|
||||||
from app.services.ssh_connect import (
|
from app.services.ssh_connect import (
|
||||||
HostNotLinuxError,
|
HostNotLinuxError,
|
||||||
HostTargetMissingError,
|
HostTargetMissingError,
|
||||||
@@ -28,7 +28,7 @@ from app.services.ssh_connect import (
|
|||||||
iter_ssh_targets,
|
iter_ssh_targets,
|
||||||
run_ssh_monitor_update,
|
run_ssh_monitor_update,
|
||||||
)
|
)
|
||||||
from app.services.win_admin_settings import get_effective_win_admin_for_host
|
from app.services.win_admin_settings import get_effective_win_admin_config
|
||||||
from app.services.winrm_connect import (
|
from app.services.winrm_connect import (
|
||||||
HostNotWindowsError,
|
HostNotWindowsError,
|
||||||
HostTargetMissingError as WinRmHostTargetMissingError,
|
HostTargetMissingError as WinRmHostTargetMissingError,
|
||||||
@@ -249,7 +249,7 @@ def execute_agent_update_fallback(db: Session, host: Host) -> AgentUpdateFallbac
|
|||||||
product = (host.product or "").strip()
|
product = (host.product or "").strip()
|
||||||
|
|
||||||
if product == PRODUCT_SSH or is_linux_host(host):
|
if product == PRODUCT_SSH or is_linux_host(host):
|
||||||
linux_cfg = get_effective_linux_admin_for_host(db, host)
|
linux_cfg = get_effective_linux_admin_config(db)
|
||||||
agent_cfg = get_effective_agent_update_config(db)
|
agent_cfg = get_effective_agent_update_config(db)
|
||||||
repo_url = (agent_cfg.ssh_git_repo_url or "").strip() or None
|
repo_url = (agent_cfg.ssh_git_repo_url or "").strip() or None
|
||||||
branch = (agent_cfg.git_branch or "main").strip() or "main"
|
branch = (agent_cfg.git_branch or "main").strip() or "main"
|
||||||
@@ -260,7 +260,7 @@ def execute_agent_update_fallback(db: Session, host: Host) -> AgentUpdateFallbac
|
|||||||
git_branch=branch,
|
git_branch=branch,
|
||||||
)
|
)
|
||||||
elif product == PRODUCT_RDP or is_windows_host(host):
|
elif product == PRODUCT_RDP or is_windows_host(host):
|
||||||
win_cfg = get_effective_win_admin_for_host(db, host)
|
win_cfg = get_effective_win_admin_config(db)
|
||||||
result = run_windows_agent_update_fallback(
|
result = run_windows_agent_update_fallback(
|
||||||
host,
|
host,
|
||||||
win_cfg,
|
win_cfg,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from app.services.event_actor_user import extract_event_actor_user
|
|||||||
from app.services.host_sessions import event_session_terminated
|
from app.services.host_sessions import event_session_terminated
|
||||||
from app.services.rdg_display import build_rdg_display
|
from app.services.rdg_display import build_rdg_display
|
||||||
from app.services.rdg_session_flap import resolve_rdg_flap_summary
|
from app.services.rdg_session_flap import resolve_rdg_flap_summary
|
||||||
from app.services.session_duration import extract_session_duration_sec
|
|
||||||
|
|
||||||
|
|
||||||
def event_to_summary(event: Event, db: Session | None = None) -> EventSummary:
|
def event_to_summary(event: Event, db: Session | None = None) -> EventSummary:
|
||||||
@@ -45,9 +44,6 @@ def event_to_summary(event: Event, db: Session | None = None) -> EventSummary:
|
|||||||
title=title,
|
title=title,
|
||||||
summary=summary,
|
summary=summary,
|
||||||
actor_user=extract_event_actor_user(event.type, event.details),
|
actor_user=extract_event_actor_user(event.type, event.details),
|
||||||
session_duration_sec=extract_session_duration_sec(
|
|
||||||
event.details if isinstance(event.details, dict) else None
|
|
||||||
),
|
|
||||||
rdg_flap=rdg_flap,
|
rdg_flap=rdg_flap,
|
||||||
rdg_flap_pair_event_id=rdg_flap_pair_event_id,
|
rdg_flap_pair_event_id=rdg_flap_pair_event_id,
|
||||||
rdg_flap_qwinsta_event_id=rdg_flap_qwinsta_event_id,
|
rdg_flap_qwinsta_event_id=rdg_flap_qwinsta_event_id,
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
"""Per-host management credentials (override global Win/Linux admin)."""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
from sqlalchemy.orm import Session
|
|
||||||
|
|
||||||
from app.models.host import Host
|
|
||||||
from app.services.linux_admin_settings import (
|
|
||||||
LinuxAdminConfig,
|
|
||||||
get_effective_linux_admin_for_host,
|
|
||||||
)
|
|
||||||
from app.services.win_admin_settings import (
|
|
||||||
WinAdminConfig,
|
|
||||||
get_effective_win_admin_for_host,
|
|
||||||
normalize_win_admin_user,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def mask_secret(value: str | None) -> str | None:
|
|
||||||
if not value:
|
|
||||||
return None
|
|
||||||
text = value.strip()
|
|
||||||
if not text:
|
|
||||||
return None
|
|
||||||
if len(text) <= 4:
|
|
||||||
return "****"
|
|
||||||
return f"{text[:2]}…{text[-2:]}"
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class HostMgmtAccessView:
|
|
||||||
host_id: int
|
|
||||||
has_override: bool
|
|
||||||
user: str | None
|
|
||||||
password_set: bool
|
|
||||||
password_hint: str | None
|
|
||||||
effective_source: str
|
|
||||||
effective_configured: bool
|
|
||||||
effective_user: str | None
|
|
||||||
|
|
||||||
|
|
||||||
def _effective_for_host(db: Session, host: Host) -> WinAdminConfig | LinuxAdminConfig:
|
|
||||||
os_family = (host.os_family or "").strip().lower()
|
|
||||||
if os_family == "windows" or (host.product or "").strip().lower() in {"rdp-login-monitor", "rdp"}:
|
|
||||||
return get_effective_win_admin_for_host(db, host)
|
|
||||||
if os_family == "linux" or (host.product or "").strip().lower() in {"ssh-monitor", "ssh"}:
|
|
||||||
return get_effective_linux_admin_for_host(db, host)
|
|
||||||
# Fallback: try host override first via win helper (same columns), then global win, then linux.
|
|
||||||
win_cfg = get_effective_win_admin_for_host(db, host)
|
|
||||||
if win_cfg.configured:
|
|
||||||
return win_cfg
|
|
||||||
return get_effective_linux_admin_for_host(db, host)
|
|
||||||
|
|
||||||
|
|
||||||
def get_host_mgmt_access_view(db: Session, host: Host) -> HostMgmtAccessView:
|
|
||||||
host_user = (host.mgmt_user or "").strip() or None
|
|
||||||
host_password = (host.mgmt_password or "").strip() or None
|
|
||||||
has_override = bool(host_user or host_password)
|
|
||||||
effective = _effective_for_host(db, host)
|
|
||||||
return HostMgmtAccessView(
|
|
||||||
host_id=host.id,
|
|
||||||
has_override=has_override,
|
|
||||||
user=host_user,
|
|
||||||
password_set=bool(host_password),
|
|
||||||
password_hint=mask_secret(host_password),
|
|
||||||
effective_source=effective.source,
|
|
||||||
effective_configured=effective.configured,
|
|
||||||
effective_user=effective.user or None,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def upsert_host_mgmt_credentials(
|
|
||||||
db: Session,
|
|
||||||
host: Host,
|
|
||||||
*,
|
|
||||||
user: str | None = None,
|
|
||||||
password: str | None = None,
|
|
||||||
clear: bool = False,
|
|
||||||
) -> HostMgmtAccessView:
|
|
||||||
"""Update per-host credentials.
|
|
||||||
|
|
||||||
- clear=True → wipe host override (use global Settings).
|
|
||||||
- user="" → clear username.
|
|
||||||
- password omitted (None) → keep existing password.
|
|
||||||
- password="" → clear password.
|
|
||||||
"""
|
|
||||||
if clear:
|
|
||||||
host.mgmt_user = None
|
|
||||||
host.mgmt_password = None
|
|
||||||
db.commit()
|
|
||||||
db.refresh(host)
|
|
||||||
return get_host_mgmt_access_view(db, host)
|
|
||||||
|
|
||||||
if user is not None:
|
|
||||||
cleaned = user.strip()
|
|
||||||
if not cleaned:
|
|
||||||
host.mgmt_user = None
|
|
||||||
else:
|
|
||||||
# Preserve DOMAIN\\user form for Windows; for Linux leave as-is after strip.
|
|
||||||
os_family = (host.os_family or "").strip().lower()
|
|
||||||
if os_family == "windows" or "\\" in cleaned or "@" in cleaned:
|
|
||||||
host.mgmt_user = normalize_win_admin_user(cleaned)
|
|
||||||
else:
|
|
||||||
host.mgmt_user = cleaned
|
|
||||||
|
|
||||||
if password is not None:
|
|
||||||
if not password.strip():
|
|
||||||
host.mgmt_password = None
|
|
||||||
else:
|
|
||||||
host.mgmt_password = password
|
|
||||||
|
|
||||||
db.commit()
|
|
||||||
db.refresh(host)
|
|
||||||
return get_host_mgmt_access_view(db, host)
|
|
||||||
@@ -14,7 +14,7 @@ from app.database import SessionLocal
|
|||||||
from app.models import Host
|
from app.models import Host
|
||||||
from app.services.agent_update import execute_agent_update_fallback
|
from app.services.agent_update import execute_agent_update_fallback
|
||||||
from app.services.agent_update_types import AgentUpdateFallbackResult
|
from app.services.agent_update_types import AgentUpdateFallbackResult
|
||||||
from app.services.linux_admin_settings import get_effective_linux_admin_for_host
|
from app.services.linux_admin_settings import get_effective_linux_admin_config
|
||||||
from app.services.agent_update_settings import get_effective_agent_update_config
|
from app.services.agent_update_settings import get_effective_agent_update_config
|
||||||
from app.services.ssh_connect import (
|
from app.services.ssh_connect import (
|
||||||
iter_ssh_targets,
|
iter_ssh_targets,
|
||||||
@@ -97,7 +97,7 @@ def _completion_message(result: SshCommandResult) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def _fetch_ssh_update_log_tail(db: Session, host: Host, *, lines: int = 200) -> str:
|
def _fetch_ssh_update_log_tail(db: Session, host: Host, *, lines: int = 200) -> str:
|
||||||
cfg = get_effective_linux_admin_for_host(db, host)
|
cfg = get_effective_linux_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
return ""
|
return ""
|
||||||
try:
|
try:
|
||||||
@@ -191,7 +191,7 @@ def _poll_ssh_update_log_loop(
|
|||||||
payload = dict(row.remote_action or {})
|
payload = dict(row.remote_action or {})
|
||||||
if (payload.get("status") or "").strip().lower() != "running":
|
if (payload.get("status") or "").strip().lower() != "running":
|
||||||
continue
|
continue
|
||||||
cfg = get_effective_linux_admin_for_host(session, row)
|
cfg = get_effective_linux_admin_config(session)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
@@ -322,7 +322,7 @@ def start_host_remote_action(
|
|||||||
|
|
||||||
|
|
||||||
def run_ssh_monitor_update_action(db: Session, host: Host) -> SshCommandResult:
|
def run_ssh_monitor_update_action(db: Session, host: Host) -> SshCommandResult:
|
||||||
cfg = get_effective_linux_admin_for_host(db, host)
|
cfg = get_effective_linux_admin_config(db)
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
return SshCommandResult(
|
return SshCommandResult(
|
||||||
ok=False,
|
ok=False,
|
||||||
|
|||||||
@@ -128,15 +128,6 @@ def ingest_event(db: Session, payload: dict) -> tuple[Event, bool]:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
process_agent_update_ingest(db, host, payload.get("type", ""), details)
|
process_agent_update_ingest(db, host, payload.get("type", ""), details)
|
||||||
from app.services.rdg_workstation_session import (
|
|
||||||
enrich_empty_login_from_rdg_success,
|
|
||||||
enrich_workstation_login_user_from_rdg,
|
|
||||||
)
|
|
||||||
|
|
||||||
if event.host is None:
|
|
||||||
event.host = host
|
|
||||||
enrich_workstation_login_user_from_rdg(db, event)
|
|
||||||
enrich_empty_login_from_rdg_success(db, event)
|
|
||||||
close_workstation_session_for_rdg_end(db, event)
|
close_workstation_session_for_rdg_end(db, event)
|
||||||
close_workstation_session_for_rdp_logoff(db, event)
|
close_workstation_session_for_rdp_logoff(db, event)
|
||||||
return event, True
|
return event, True
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""Effective Linux SSH admin credentials (host → DB → env)."""
|
"""Effective Linux SSH admin credentials (DB overrides env)."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@@ -7,7 +7,6 @@ from dataclasses import dataclass
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
from app.models.host import Host
|
|
||||||
from app.models.ui_settings import UI_SETTINGS_ROW_ID, UiSettings
|
from app.models.ui_settings import UI_SETTINGS_ROW_ID, UiSettings
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ from app.models.ui_settings import UI_SETTINGS_ROW_ID, UiSettings
|
|||||||
class LinuxAdminConfig:
|
class LinuxAdminConfig:
|
||||||
user: str
|
user: str
|
||||||
password: str
|
password: str
|
||||||
source: str # host | env | db
|
source: str # env | db
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configured(self) -> bool:
|
def configured(self) -> bool:
|
||||||
@@ -81,16 +80,3 @@ def upsert_linux_admin_settings(
|
|||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(row)
|
db.refresh(row)
|
||||||
return get_effective_linux_admin_config(db)
|
return get_effective_linux_admin_config(db)
|
||||||
|
|
||||||
|
|
||||||
def get_effective_linux_admin_for_host(db: Session, host: Host) -> LinuxAdminConfig:
|
|
||||||
"""Prefer per-host mgmt_* when both user and password are set; else global Settings/env."""
|
|
||||||
host_user = (host.mgmt_user or "").strip()
|
|
||||||
host_password = (host.mgmt_password or "").strip()
|
|
||||||
if host_user and host_password:
|
|
||||||
return LinuxAdminConfig(user=host_user, password=host_password, source="host")
|
|
||||||
|
|
||||||
global_cfg = get_effective_linux_admin_config(db)
|
|
||||||
if host_user and global_cfg.password.strip():
|
|
||||||
return LinuxAdminConfig(user=host_user, password=global_cfg.password, source="host")
|
|
||||||
return global_cfg
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from app.models import AgentCommand, Event, Host
|
|||||||
from app.services.rdg_client_host import ClientWorkstationNotFoundError, resolve_client_workstation
|
from app.services.rdg_client_host import ClientWorkstationNotFoundError, resolve_client_workstation
|
||||||
from app.services.rdg_display import event_supports_rdg_client_qwinsta
|
from app.services.rdg_display import event_supports_rdg_client_qwinsta
|
||||||
from app.services.rdg_session_flap import event_internal_ip
|
from app.services.rdg_session_flap import event_internal_ip
|
||||||
from app.services.win_admin_settings import get_effective_win_admin_for_host
|
from app.services.win_admin_settings import get_effective_win_admin_config
|
||||||
from app.services.winrm_connect import (
|
from app.services.winrm_connect import (
|
||||||
WinRmCmdResult,
|
WinRmCmdResult,
|
||||||
run_winrm_logoff,
|
run_winrm_logoff,
|
||||||
@@ -21,17 +21,12 @@ from app.services.winrm_connect import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _require_win_admin(db: Session, host: Host | None = None):
|
def _require_win_admin(db: Session):
|
||||||
if host is not None:
|
cfg = get_effective_win_admin_config(db)
|
||||||
cfg = get_effective_win_admin_for_host(db, host)
|
|
||||||
else:
|
|
||||||
from app.services.win_admin_settings import get_effective_win_admin_config
|
|
||||||
|
|
||||||
cfg = get_effective_win_admin_config(db)
|
|
||||||
if not cfg.configured:
|
if not cfg.configured:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=503,
|
status_code=503,
|
||||||
detail="Windows admin is not configured (host override or Settings → Windows)",
|
detail="Windows domain admin is not configured (Settings or SAC_WIN_ADMIN_*)",
|
||||||
)
|
)
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
@@ -98,8 +93,8 @@ def _persist_command(
|
|||||||
|
|
||||||
def execute_qwinsta_via_winrm(db: Session, event: Event, *, requested_by: str) -> AgentCommand:
|
def execute_qwinsta_via_winrm(db: Session, event: Event, *, requested_by: str) -> AgentCommand:
|
||||||
_require_rdg_client_qwinsta(db, event)
|
_require_rdg_client_qwinsta(db, event)
|
||||||
|
cfg = _require_win_admin(db)
|
||||||
client_host = _resolve_client(db, event)
|
client_host = _resolve_client(db, event)
|
||||||
cfg = _require_win_admin(db, client_host)
|
|
||||||
|
|
||||||
details = event.details if isinstance(event.details, dict) else {}
|
details = event.details if isinstance(event.details, dict) else {}
|
||||||
user = details.get("user")
|
user = details.get("user")
|
||||||
@@ -141,8 +136,8 @@ def execute_logoff_via_winrm(
|
|||||||
requested_by: str,
|
requested_by: str,
|
||||||
) -> AgentCommand:
|
) -> AgentCommand:
|
||||||
_require_rdg_client_qwinsta(db, event)
|
_require_rdg_client_qwinsta(db, event)
|
||||||
|
cfg = _require_win_admin(db)
|
||||||
client_host = _resolve_client(db, event)
|
client_host = _resolve_client(db, event)
|
||||||
cfg = _require_win_admin(db, client_host)
|
|
||||||
|
|
||||||
details = event.details if isinstance(event.details, dict) else {}
|
details = event.details if isinstance(event.details, dict) else {}
|
||||||
user = details.get("user")
|
user = details.get("user")
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta, timezone
|
|
||||||
|
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from sqlalchemy.orm.attributes import flag_modified
|
from sqlalchemy.orm.attributes import flag_modified
|
||||||
@@ -17,7 +15,6 @@ from app.services.host_sessions import (
|
|||||||
from app.services.rdg_client_host import find_windows_host_by_ipv4
|
from app.services.rdg_client_host import find_windows_host_by_ipv4
|
||||||
from app.services.rdg_session_flap import (
|
from app.services.rdg_session_flap import (
|
||||||
RDG_END_TYPES,
|
RDG_END_TYPES,
|
||||||
RDG_SUCCESS_TYPE,
|
|
||||||
_event_user,
|
_event_user,
|
||||||
event_internal_ip,
|
event_internal_ip,
|
||||||
find_rdg_success_before_end,
|
find_rdg_success_before_end,
|
||||||
@@ -25,22 +22,10 @@ from app.services.rdg_session_flap import (
|
|||||||
|
|
||||||
SESSION_CLOSED_BY_RDG_AT_KEY = "session_closed_by_rdg_at"
|
SESSION_CLOSED_BY_RDG_AT_KEY = "session_closed_by_rdg_at"
|
||||||
SESSION_CLOSED_BY_RDG_EVENT_ID_KEY = "session_closed_by_rdg_event_id"
|
SESSION_CLOSED_BY_RDG_EVENT_ID_KEY = "session_closed_by_rdg_event_id"
|
||||||
USER_ENRICHED_FROM_RDG_EVENT_ID_KEY = "user_enriched_from_rdg_event_id"
|
|
||||||
|
|
||||||
# RCM 1149 via RD Gateway often has empty Param1/Param2; RDG 302 has the account.
|
|
||||||
RDG_LOGIN_USER_ENRICH_WINDOW = timedelta(minutes=5)
|
|
||||||
|
|
||||||
WORKSTATION_LOGIN_TYPE = "rdp.login.success"
|
WORKSTATION_LOGIN_TYPE = "rdp.login.success"
|
||||||
|
|
||||||
|
|
||||||
def _as_utc(dt):
|
|
||||||
if dt is None:
|
|
||||||
return None
|
|
||||||
if dt.tzinfo is None:
|
|
||||||
return dt.replace(tzinfo=timezone.utc)
|
|
||||||
return dt.astimezone(timezone.utc)
|
|
||||||
|
|
||||||
|
|
||||||
def normalize_sam_account(user: str) -> str:
|
def normalize_sam_account(user: str) -> str:
|
||||||
text = (user or "").strip()
|
text = (user or "").strip()
|
||||||
if "\\" in text:
|
if "\\" in text:
|
||||||
@@ -56,115 +41,6 @@ def users_match_rdg(login_user: str, rdg_user: str) -> bool:
|
|||||||
return bool(left and right and left == right)
|
return bool(left and right and left == right)
|
||||||
|
|
||||||
|
|
||||||
def _login_user_missing(event: Event) -> bool:
|
|
||||||
details = _details_dict(event)
|
|
||||||
for key in ("user", "username"):
|
|
||||||
val = details.get(key)
|
|
||||||
if val is not None and str(val).strip() not in ("", "-"):
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def _apply_rdg_user_to_login(login_event: Event, *, rdg_event: Event, rdg_user: str) -> None:
|
|
||||||
details = dict(_details_dict(login_event))
|
|
||||||
details["user"] = rdg_user
|
|
||||||
details[USER_ENRICHED_FROM_RDG_EVENT_ID_KEY] = rdg_event.id
|
|
||||||
login_event.details = details
|
|
||||||
flag_modified(login_event, "details")
|
|
||||||
summary = (login_event.summary or "").strip()
|
|
||||||
if summary.startswith("RCM 1149") and rdg_user not in summary:
|
|
||||||
rest = summary[len("RCM 1149") :].strip()
|
|
||||||
login_event.summary = f"RCM 1149 {rdg_user} {rest}".strip()
|
|
||||||
|
|
||||||
|
|
||||||
def find_rdg_success_for_workstation_login(db: Session, login_event: Event) -> Event | None:
|
|
||||||
"""Nearest RDG 302 for this workstation IP within the enrich window."""
|
|
||||||
if login_event.type != WORKSTATION_LOGIN_TYPE:
|
|
||||||
return None
|
|
||||||
host = login_event.host
|
|
||||||
if host is None or not (host.ipv4 or "").strip():
|
|
||||||
return None
|
|
||||||
workstation_ip = host.ipv4.strip()
|
|
||||||
login_at = _as_utc(login_event.occurred_at)
|
|
||||||
window_start = login_at - RDG_LOGIN_USER_ENRICH_WINDOW
|
|
||||||
window_end = login_at + RDG_LOGIN_USER_ENRICH_WINDOW
|
|
||||||
|
|
||||||
candidates = db.scalars(
|
|
||||||
select(Event)
|
|
||||||
.where(
|
|
||||||
Event.type == RDG_SUCCESS_TYPE,
|
|
||||||
Event.occurred_at >= window_start,
|
|
||||||
Event.occurred_at <= window_end,
|
|
||||||
Event.id != login_event.id,
|
|
||||||
)
|
|
||||||
.order_by(Event.occurred_at.desc())
|
|
||||||
).all()
|
|
||||||
|
|
||||||
best: Event | None = None
|
|
||||||
best_delta: timedelta | None = None
|
|
||||||
for rdg in candidates:
|
|
||||||
if event_internal_ip(rdg) != workstation_ip:
|
|
||||||
continue
|
|
||||||
if not _event_user(rdg):
|
|
||||||
continue
|
|
||||||
delta = abs(_as_utc(rdg.occurred_at) - login_at)
|
|
||||||
if best is None or best_delta is None or delta < best_delta:
|
|
||||||
best = rdg
|
|
||||||
best_delta = delta
|
|
||||||
return best
|
|
||||||
|
|
||||||
|
|
||||||
def enrich_workstation_login_user_from_rdg(db: Session, login_event: Event) -> Event | None:
|
|
||||||
"""Fill details.user when RCM 1149 EventLog left Param1/Param2 empty (seen on some Win10 Pro)."""
|
|
||||||
if login_event.type != WORKSTATION_LOGIN_TYPE:
|
|
||||||
return None
|
|
||||||
if not _login_user_missing(login_event):
|
|
||||||
return None
|
|
||||||
rdg = find_rdg_success_for_workstation_login(db, login_event)
|
|
||||||
if rdg is None:
|
|
||||||
return None
|
|
||||||
rdg_user = _event_user(rdg)
|
|
||||||
if not rdg_user:
|
|
||||||
return None
|
|
||||||
_apply_rdg_user_to_login(login_event, rdg_event=rdg, rdg_user=rdg_user)
|
|
||||||
return login_event
|
|
||||||
|
|
||||||
|
|
||||||
def enrich_empty_login_from_rdg_success(db: Session, rdg_success_event: Event) -> Event | None:
|
|
||||||
"""Backfill empty workstation 1149 when RDG 302 is ingested after it."""
|
|
||||||
if rdg_success_event.type != RDG_SUCCESS_TYPE:
|
|
||||||
return None
|
|
||||||
internal_ip = event_internal_ip(rdg_success_event)
|
|
||||||
rdg_user = _event_user(rdg_success_event)
|
|
||||||
if not internal_ip or not rdg_user:
|
|
||||||
return None
|
|
||||||
client_host = find_windows_host_by_ipv4(db, internal_ip)
|
|
||||||
if client_host is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
rdg_at = _as_utc(rdg_success_event.occurred_at)
|
|
||||||
window_start = rdg_at - RDG_LOGIN_USER_ENRICH_WINDOW
|
|
||||||
window_end = rdg_at + RDG_LOGIN_USER_ENRICH_WINDOW
|
|
||||||
candidates = db.scalars(
|
|
||||||
select(Event)
|
|
||||||
.where(
|
|
||||||
Event.host_id == client_host.id,
|
|
||||||
Event.type == WORKSTATION_LOGIN_TYPE,
|
|
||||||
Event.occurred_at >= window_start,
|
|
||||||
Event.occurred_at <= window_end,
|
|
||||||
Event.id != rdg_success_event.id,
|
|
||||||
)
|
|
||||||
.order_by(Event.occurred_at.desc())
|
|
||||||
).all()
|
|
||||||
|
|
||||||
for login in candidates:
|
|
||||||
if not _login_user_missing(login):
|
|
||||||
continue
|
|
||||||
_apply_rdg_user_to_login(login, rdg_event=rdg_success_event, rdg_user=rdg_user)
|
|
||||||
return login
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def event_closed_by_rdg(event: Event) -> bool:
|
def event_closed_by_rdg(event: Event) -> bool:
|
||||||
details = _details_dict(event)
|
details = _details_dict(event)
|
||||||
at = details.get(SESSION_CLOSED_BY_RDG_AT_KEY)
|
at = details.get(SESSION_CLOSED_BY_RDG_AT_KEY)
|
||||||
@@ -222,11 +98,8 @@ def find_workstation_login_for_rdg_end(db: Session, rdg_end_event: Event) -> Eve
|
|||||||
for login in candidates:
|
for login in candidates:
|
||||||
if _login_already_closed(login):
|
if _login_already_closed(login):
|
||||||
continue
|
continue
|
||||||
login_user = (_event_login_user(login) or "").strip()
|
login_user = _event_login_user(login)
|
||||||
if login_user in ("", "-"):
|
if not users_match_rdg(login_user, rdg_user):
|
||||||
login_user = ""
|
|
||||||
# RCM 1149 may lack user (empty Param1); still close by workstation IP + open session.
|
|
||||||
if login_user and not users_match_rdg(login_user, rdg_user):
|
|
||||||
continue
|
continue
|
||||||
return login
|
return login
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ from app.services.rdg_workstation_session import (
|
|||||||
users_match_rdg,
|
users_match_rdg,
|
||||||
)
|
)
|
||||||
from app.services.rdp_flap_settings import get_effective_rdp_flap_settings
|
from app.services.rdp_flap_settings import get_effective_rdp_flap_settings
|
||||||
from app.services.win_admin_settings import get_effective_win_admin_for_host
|
from app.services.win_admin_settings import get_effective_win_admin_config
|
||||||
|
|
||||||
logger = logging.getLogger("sac.rdp_flap_auto_disconnect")
|
logger = logging.getLogger("sac.rdp_flap_auto_disconnect")
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ def _disconnect_on_workstation(
|
|||||||
user: str,
|
user: str,
|
||||||
login_event: Event | None,
|
login_event: Event | None,
|
||||||
) -> AutoDisconnectResult:
|
) -> AutoDisconnectResult:
|
||||||
win_cfg = get_effective_win_admin_for_host(db, workstation)
|
win_cfg = get_effective_win_admin_config(db)
|
||||||
sessions, qwinsta = list_windows_sessions(workstation, win_cfg)
|
sessions, qwinsta = list_windows_sessions(workstation, win_cfg)
|
||||||
if qwinsta is None or not qwinsta.ok:
|
if qwinsta is None or not qwinsta.ok:
|
||||||
message = qwinsta.message if qwinsta else "qwinsta failed"
|
message = qwinsta.message if qwinsta else "qwinsta failed"
|
||||||
@@ -291,6 +291,14 @@ def maybe_auto_disconnect_stuck_rdp_session(db: Session, event: Event) -> AutoDi
|
|||||||
if not get_effective_rdp_flap_settings(db).auto_disconnect:
|
if not get_effective_rdp_flap_settings(db).auto_disconnect:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
win_cfg = get_effective_win_admin_config(db)
|
||||||
|
if not win_cfg.configured:
|
||||||
|
logger.warning(
|
||||||
|
"auto rdp flap disconnect skipped: win admin not configured (event_id=%s)",
|
||||||
|
event.event_id,
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
result = _auto_disconnect_rdg_flap(db, event)
|
result = _auto_disconnect_rdg_flap(db, event)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
if result.ok:
|
if result.ok:
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
"""Format and extract RDP/RDG session_duration_sec for UI."""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
def extract_session_duration_sec(details: dict[str, Any] | None) -> int | None:
|
|
||||||
if not isinstance(details, dict):
|
|
||||||
return None
|
|
||||||
raw = details.get("session_duration_sec")
|
|
||||||
if raw is None or raw == "":
|
|
||||||
return None
|
|
||||||
try:
|
|
||||||
value = int(raw)
|
|
||||||
except (TypeError, ValueError):
|
|
||||||
return None
|
|
||||||
if value < 0:
|
|
||||||
return None
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def format_session_duration(seconds: int) -> str:
|
|
||||||
"""
|
|
||||||
Human-readable session length for lists:
|
|
||||||
- under 24h → HH:MM:SS (05:05:24)
|
|
||||||
- 24h+ → Nд HH:MM:SS (1д 00:01:25)
|
|
||||||
"""
|
|
||||||
if seconds < 0:
|
|
||||||
return "—"
|
|
||||||
days, rem = divmod(int(seconds), 86_400)
|
|
||||||
hours, rem = divmod(rem, 3600)
|
|
||||||
minutes, secs = divmod(rem, 60)
|
|
||||||
clock = f"{hours:02d}:{minutes:02d}:{secs:02d}"
|
|
||||||
if days:
|
|
||||||
return f"{days}д {clock}"
|
|
||||||
return clock
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
"""SSH connectivity and remote commands for Linux hosts."""
|
"""SSH connectivity and remote commands for Linux hosts."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ SSH_MONITOR_UPDATE_LOG_PATH = "/var/log/update_script.log"
|
|||||||
SSH_MONITOR_UPDATE_SCRIPT = "/opt/scripts/update_ssh_monitor.sh"
|
SSH_MONITOR_UPDATE_SCRIPT = "/opt/scripts/update_ssh_monitor.sh"
|
||||||
SSH_MONITOR_UPDATE_DIR = "/opt/scripts/update"
|
SSH_MONITOR_UPDATE_DIR = "/opt/scripts/update"
|
||||||
SSH_MONITOR_REPO_NAME = "ssh-monitor"
|
SSH_MONITOR_REPO_NAME = "ssh-monitor"
|
||||||
SSH_MONITOR_UPDATE_REPO_URL = "https://git.papatramp.ru/PapaTramp/ssh-monitor.git"
|
SSH_MONITOR_UPDATE_REPO_URL = "https://git.kalinamall.ru/PapaTramp/ssh-monitor.git"
|
||||||
SSH_MONITOR_BINARY = "/usr/local/bin/ssh-monitor"
|
SSH_MONITOR_BINARY = "/usr/local/bin/ssh-monitor"
|
||||||
SSH_MONITOR_VERSION_CMD = (
|
SSH_MONITOR_VERSION_CMD = (
|
||||||
f"grep -m1 '^SSH_MONITOR_VERSION=' {SSH_MONITOR_BINARY} 2>/dev/null "
|
f"grep -m1 '^SSH_MONITOR_VERSION=' {SSH_MONITOR_BINARY} 2>/dev/null "
|
||||||
|
|||||||
@@ -564,11 +564,9 @@ def _format_rdg_html(event: Event) -> str:
|
|||||||
err = _detail(details, "gateway_error_code", "error_code", default="")
|
err = _detail(details, "gateway_error_code", "error_code", default="")
|
||||||
if err != "-":
|
if err != "-":
|
||||||
msg += _line("⚠️", "Код ошибки", html_escape(err))
|
msg += _line("⚠️", "Код ошибки", html_escape(err))
|
||||||
from app.services.session_duration import extract_session_duration_sec, format_session_duration
|
dur = _detail(details, "session_duration_sec", default="")
|
||||||
|
if dur not in ("-", "0", ""):
|
||||||
dur_sec = extract_session_duration_sec(details if isinstance(details, dict) else None)
|
msg += _line("⏱️", "Длительность", f"{html_escape(dur)} с")
|
||||||
if dur_sec is not None and dur_sec > 0:
|
|
||||||
msg += _line("⏱️", "Длительность", html_escape(format_session_duration(dur_sec)))
|
|
||||||
msg += _line("🕐", "Время", format_time(event.occurred_at))
|
msg += _line("🕐", "Время", format_time(event.occurred_at))
|
||||||
win_id = _detail(details, "event_id_windows", default="")
|
win_id = _detail(details, "event_id_windows", default="")
|
||||||
if win_id != "-":
|
if win_id != "-":
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""Effective Windows domain admin credentials (host → DB → env)."""
|
"""Effective Windows domain admin credentials (DB overrides env)."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@@ -7,7 +7,6 @@ from dataclasses import dataclass
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
from app.models.host import Host
|
|
||||||
from app.models.ui_settings import UI_SETTINGS_ROW_ID, UiSettings
|
from app.models.ui_settings import UI_SETTINGS_ROW_ID, UiSettings
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ from app.models.ui_settings import UI_SETTINGS_ROW_ID, UiSettings
|
|||||||
class WinAdminConfig:
|
class WinAdminConfig:
|
||||||
user: str
|
user: str
|
||||||
password: str
|
password: str
|
||||||
source: str # host | env | db
|
source: str # env | db
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configured(self) -> bool:
|
def configured(self) -> bool:
|
||||||
@@ -93,17 +92,3 @@ def upsert_win_admin_settings(
|
|||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(row)
|
db.refresh(row)
|
||||||
return get_effective_win_admin_config(db)
|
return get_effective_win_admin_config(db)
|
||||||
|
|
||||||
|
|
||||||
def get_effective_win_admin_for_host(db: Session, host: Host) -> WinAdminConfig:
|
|
||||||
"""Prefer per-host mgmt_* when both user and password are set; else global Settings/env."""
|
|
||||||
host_user = normalize_win_admin_user((host.mgmt_user or "").strip())
|
|
||||||
host_password = (host.mgmt_password or "").strip()
|
|
||||||
if host_user and host_password:
|
|
||||||
return WinAdminConfig(user=host_user, password=host_password, source="host")
|
|
||||||
|
|
||||||
global_cfg = get_effective_win_admin_config(db)
|
|
||||||
# Allow host to override only the username, still using global password (rare).
|
|
||||||
if host_user and global_cfg.password.strip():
|
|
||||||
return WinAdminConfig(user=host_user, password=global_cfg.password, source="host")
|
|
||||||
return global_cfg
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""WinRM connectivity test for Windows hosts using domain admin credentials."""
|
"""WinRM connectivity test for Windows hosts using domain admin credentials."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ def run_winrm_rdp_monitor_update(
|
|||||||
)
|
)
|
||||||
|
|
||||||
effective_repo = (
|
effective_repo = (
|
||||||
repo_url or "https://git.papatramp.ru/PapaTramp/RDP-login-monitor.git"
|
repo_url or "https://git.kalinamall.ru/PapaTramp/RDP-login-monitor.git"
|
||||||
).strip()
|
).strip()
|
||||||
effective_branch = (git_branch or "main").strip() or "main"
|
effective_branch = (git_branch or "main").strip() or "main"
|
||||||
if not effective_repo:
|
if not effective_repo:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""Единый источник версии SAC (API, health, логи, OpenAPI)."""
|
"""Единый источник версии SAC (API, health, логи, OpenAPI)."""
|
||||||
|
|
||||||
APP_NAME = "Security Alert Center"
|
APP_NAME = "Security Alert Center"
|
||||||
APP_VERSION = "0.5.17"
|
APP_VERSION = "0.5.14"
|
||||||
APP_VERSION_LABEL = f"{APP_NAME} v.{APP_VERSION}"
|
APP_VERSION_LABEL = f"{APP_NAME} v.{APP_VERSION}"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from app.services.agent_version import reference_agent_versions_by_product
|
|||||||
|
|
||||||
|
|
||||||
def test_normalize_git_repo_url():
|
def test_normalize_git_repo_url():
|
||||||
assert normalize_git_repo_url("git.papatramp.ru/PapaTramp/ssh-monitor").endswith(
|
assert normalize_git_repo_url("git.kalinamall.ru/PapaTramp/ssh-monitor").endswith(
|
||||||
"ssh-monitor.git"
|
"ssh-monitor.git"
|
||||||
)
|
)
|
||||||
assert normalize_git_repo_url("https://example.com/repo.git") == "https://example.com/repo.git"
|
assert normalize_git_repo_url("https://example.com/repo.git") == "https://example.com/repo.git"
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
"""Per-host management credential override."""
|
|
||||||
|
|
||||||
from app.models.host import Host
|
|
||||||
from app.services.linux_admin_settings import get_effective_linux_admin_for_host
|
|
||||||
from app.services.win_admin_settings import get_effective_win_admin_for_host
|
|
||||||
from app.services.host_mgmt_credentials import get_host_mgmt_access_view, upsert_host_mgmt_credentials
|
|
||||||
|
|
||||||
|
|
||||||
def test_win_admin_for_host_prefers_override(db_session):
|
|
||||||
host = Host(
|
|
||||||
hostname="HOME-PC",
|
|
||||||
os_family="windows",
|
|
||||||
product="rdp-login-monitor",
|
|
||||||
mgmt_user=".\\Admin",
|
|
||||||
mgmt_password="local-secret",
|
|
||||||
)
|
|
||||||
db_session.add(host)
|
|
||||||
db_session.commit()
|
|
||||||
db_session.refresh(host)
|
|
||||||
|
|
||||||
cfg = get_effective_win_admin_for_host(db_session, host)
|
|
||||||
assert cfg.configured is True
|
|
||||||
assert cfg.source == "host"
|
|
||||||
assert cfg.user == ".\\Admin"
|
|
||||||
assert cfg.password == "local-secret"
|
|
||||||
|
|
||||||
|
|
||||||
def test_linux_admin_for_host_prefers_override(db_session):
|
|
||||||
host = Host(
|
|
||||||
hostname="homeserver",
|
|
||||||
os_family="linux",
|
|
||||||
product="ssh-monitor",
|
|
||||||
mgmt_user="deploy",
|
|
||||||
mgmt_password="ssh-pass",
|
|
||||||
)
|
|
||||||
db_session.add(host)
|
|
||||||
db_session.commit()
|
|
||||||
db_session.refresh(host)
|
|
||||||
|
|
||||||
cfg = get_effective_linux_admin_for_host(db_session, host)
|
|
||||||
assert cfg.source == "host"
|
|
||||||
assert cfg.user == "deploy"
|
|
||||||
|
|
||||||
|
|
||||||
def test_upsert_and_clear_host_access(db_session):
|
|
||||||
host = Host(hostname="box", os_family="windows", product="rdp-login-monitor")
|
|
||||||
db_session.add(host)
|
|
||||||
db_session.commit()
|
|
||||||
db_session.refresh(host)
|
|
||||||
|
|
||||||
view = upsert_host_mgmt_credentials(
|
|
||||||
db_session,
|
|
||||||
host,
|
|
||||||
user="HOME\\user",
|
|
||||||
password="secret123",
|
|
||||||
)
|
|
||||||
assert view.has_override is True
|
|
||||||
assert view.password_set is True
|
|
||||||
assert view.user == "HOME\\user"
|
|
||||||
|
|
||||||
cleared = upsert_host_mgmt_credentials(db_session, host, clear=True)
|
|
||||||
assert cleared.has_override is False
|
|
||||||
assert cleared.password_set is False
|
|
||||||
assert get_host_mgmt_access_view(db_session, host).user is None
|
|
||||||
@@ -266,113 +266,3 @@ def test_ip_mismatch_does_not_close_login(db_session, rdg_settings, rdg_hosts):
|
|||||||
|
|
||||||
assert close_workstation_session_for_rdg_end(db_session, end) is None
|
assert close_workstation_session_for_rdg_end(db_session, end) is None
|
||||||
assert event_session_terminated(login, db=db_session) is False
|
assert event_session_terminated(login, db=db_session) is False
|
||||||
|
|
||||||
|
|
||||||
def test_empty_rcm1149_user_enriched_from_prior_rdg302(db_session, rdg_settings, rdg_hosts):
|
|
||||||
"""COMM-PC class: EventLog 1149 has empty Param1; RDG 302 already has the account."""
|
|
||||||
ws, _gw = rdg_hosts
|
|
||||||
t0 = datetime.now(timezone.utc)
|
|
||||||
user = r"B26\s.shelkovaya"
|
|
||||||
internal_ip = ws.ipv4
|
|
||||||
|
|
||||||
_ingest(
|
|
||||||
db_session,
|
|
||||||
t0,
|
|
||||||
host={"hostname": "K6A-DC3", "os_family": "windows"},
|
|
||||||
source={"product": "rdp-login-monitor", "product_version": "2.1.13-SAC"},
|
|
||||||
type="rdg.connection.success",
|
|
||||||
category="auth",
|
|
||||||
severity="warning",
|
|
||||||
title="RDG 302",
|
|
||||||
summary="302",
|
|
||||||
details={"user": user, "internal_ip": internal_ip},
|
|
||||||
)
|
|
||||||
login = _ingest(
|
|
||||||
db_session,
|
|
||||||
t0 + timedelta(seconds=3),
|
|
||||||
host={"hostname": ws.hostname, "os_family": "windows", "ipv4": internal_ip},
|
|
||||||
source={"product": "rdp-login-monitor", "product_version": "2.1.13-SAC"},
|
|
||||||
type="rdp.login.success",
|
|
||||||
category="auth",
|
|
||||||
severity="warning",
|
|
||||||
title="RDP connection (RCM 1149)",
|
|
||||||
summary="RCM 1149 - 192.168.160.40",
|
|
||||||
details={"user": "-", "ip_address": "192.168.160.40", "event_id_windows": 1149},
|
|
||||||
)
|
|
||||||
db_session.refresh(login)
|
|
||||||
|
|
||||||
assert login.details["user"] == user
|
|
||||||
assert login.details.get("user_enriched_from_rdg_event_id")
|
|
||||||
summary = event_to_summary(login, db_session)
|
|
||||||
assert summary.actor_user == user
|
|
||||||
|
|
||||||
|
|
||||||
def test_empty_rcm1149_backfilled_when_rdg302_arrives_later(db_session, rdg_settings, rdg_hosts):
|
|
||||||
ws, _gw = rdg_hosts
|
|
||||||
t0 = datetime.now(timezone.utc)
|
|
||||||
user = r"B26\s.shelkovaya"
|
|
||||||
internal_ip = ws.ipv4
|
|
||||||
|
|
||||||
login = _ingest(
|
|
||||||
db_session,
|
|
||||||
t0 + timedelta(seconds=1),
|
|
||||||
host={"hostname": ws.hostname, "os_family": "windows", "ipv4": internal_ip},
|
|
||||||
source={"product": "rdp-login-monitor", "product_version": "2.1.13-SAC"},
|
|
||||||
type="rdp.login.success",
|
|
||||||
category="auth",
|
|
||||||
severity="info",
|
|
||||||
title="RDP connection (RCM 1149)",
|
|
||||||
summary="RCM 1149 - 1.2.3.4",
|
|
||||||
details={"user": "-", "event_id_windows": 1149},
|
|
||||||
)
|
|
||||||
assert login.details["user"] == "-"
|
|
||||||
|
|
||||||
_ingest(
|
|
||||||
db_session,
|
|
||||||
t0,
|
|
||||||
host={"hostname": "K6A-DC3", "os_family": "windows"},
|
|
||||||
source={"product": "rdp-login-monitor", "product_version": "2.1.13-SAC"},
|
|
||||||
type="rdg.connection.success",
|
|
||||||
category="auth",
|
|
||||||
severity="info",
|
|
||||||
title="RDG 302",
|
|
||||||
summary="302",
|
|
||||||
details={"user": user, "internal_ip": internal_ip},
|
|
||||||
)
|
|
||||||
db_session.refresh(login)
|
|
||||||
assert login.details["user"] == user
|
|
||||||
|
|
||||||
|
|
||||||
def test_empty_user_login_still_closed_by_rdg303(db_session, rdg_settings, rdg_hosts):
|
|
||||||
ws, _gw = rdg_hosts
|
|
||||||
t0 = datetime.now(timezone.utc)
|
|
||||||
user = r"B26\s.shelkovaya"
|
|
||||||
internal_ip = ws.ipv4
|
|
||||||
|
|
||||||
login = _ingest(
|
|
||||||
db_session,
|
|
||||||
t0,
|
|
||||||
host={"hostname": ws.hostname, "os_family": "windows", "ipv4": internal_ip},
|
|
||||||
source={"product": "rdp-login-monitor", "product_version": "2.1.13-SAC"},
|
|
||||||
type="rdp.login.success",
|
|
||||||
category="auth",
|
|
||||||
severity="info",
|
|
||||||
title="RDP connection (RCM 1149)",
|
|
||||||
summary="RCM 1149",
|
|
||||||
details={"user": "-", "event_id_windows": 1149},
|
|
||||||
)
|
|
||||||
end = _ingest(
|
|
||||||
db_session,
|
|
||||||
t0 + timedelta(minutes=5),
|
|
||||||
host={"hostname": "K6A-DC3", "os_family": "windows"},
|
|
||||||
source={"product": "rdp-login-monitor", "product_version": "2.1.13-SAC"},
|
|
||||||
type="rdg.connection.disconnected",
|
|
||||||
category="auth",
|
|
||||||
severity="info",
|
|
||||||
title="303",
|
|
||||||
summary="303",
|
|
||||||
details={"user": user, "internal_ip": internal_ip},
|
|
||||||
)
|
|
||||||
db_session.refresh(login)
|
|
||||||
assert login.details.get(SESSION_CLOSED_BY_RDG_AT_KEY) == end.occurred_at.isoformat()
|
|
||||||
assert event_session_terminated(login, db=db_session) is True
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
"""Tests for session_duration_sec extract/format."""
|
|
||||||
|
|
||||||
from app.services.session_duration import extract_session_duration_sec, format_session_duration
|
|
||||||
|
|
||||||
|
|
||||||
def test_extract_session_duration_sec():
|
|
||||||
assert extract_session_duration_sec({"session_duration_sec": 18324}) == 18324
|
|
||||||
assert extract_session_duration_sec({"session_duration_sec": "42"}) == 42
|
|
||||||
assert extract_session_duration_sec({"session_duration_sec": ""}) is None
|
|
||||||
assert extract_session_duration_sec({}) is None
|
|
||||||
assert extract_session_duration_sec(None) is None
|
|
||||||
assert extract_session_duration_sec({"session_duration_sec": -1}) is None
|
|
||||||
|
|
||||||
|
|
||||||
def test_format_session_duration():
|
|
||||||
assert format_session_duration(0) == "00:00:00"
|
|
||||||
assert format_session_duration(18324) == "05:05:24"
|
|
||||||
assert format_session_duration(2428) == "00:40:28"
|
|
||||||
assert format_session_duration(86400 + 85) == "1д 00:01:25"
|
|
||||||
assert format_session_duration(2 * 86400 + 3661) == "2д 01:01:01"
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
"""SSH connect service tests (paramiko mocked via sys.modules)."""
|
"""SSH connect service tests (paramiko mocked via sys.modules)."""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
@@ -323,7 +323,7 @@ def test_run_ssh_monitor_update_runs_script(monkeypatch):
|
|||||||
target="ubabuba",
|
target="ubabuba",
|
||||||
user="root",
|
user="root",
|
||||||
password="pw",
|
password="pw",
|
||||||
repo_url="https://git.papatramp.ru/PapaTramp/ssh-monitor.git",
|
repo_url="https://git.kalinamall.ru/PapaTramp/ssh-monitor.git",
|
||||||
)
|
)
|
||||||
assert result.ok is True
|
assert result.ok is True
|
||||||
assert result.agent_version == "2.1.0-SAC"
|
assert result.agent_version == "2.1.0-SAC"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Security Alert Center API (FastAPI)
|
Description=Security Alert Center API (FastAPI)
|
||||||
Documentation=https://git.papatramp.ru/PapaTramp/security-alert-center
|
Documentation=https://git.kalinamall.ru/PapaTramp/security-alert-center
|
||||||
After=network-online.target postgresql.service
|
After=network-online.target postgresql.service
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
Requires=postgresql.service
|
Requires=postgresql.service
|
||||||
|
|||||||
@@ -183,13 +183,11 @@ sequenceDiagram
|
|||||||
|
|
||||||
## 5. П.2C — Доступ SAC к хостам
|
## 5. П.2C — Доступ SAC к хостам
|
||||||
|
|
||||||
### 5.1. Windows — WinRM / учётки
|
### 5.1. Windows — WinRM
|
||||||
|
|
||||||
- **Глобальный доменный admin** в **Настройки → Windows**: `DOMAIN\user` + password (encrypted). Аналогично **Linux admin** для SSH.
|
- **Один доменный admin** в **Настройки → Управление хостами → Windows**: `DOMAIN\user` + password (encrypted).
|
||||||
- **Override на карточке хоста** (**Хосты → WinRM/SSH / доступ к хосту**): `COMPUTER\user` / `.\Administrator` + password (encrypted в `hosts.mgmt_*`). Если пусто — берутся глобальные.
|
- Override на карточке хоста — опционально позже.
|
||||||
- Effective creds: `get_effective_win_admin_for_host` / `get_effective_linux_admin_for_host` (source: `host` | `db` | `env`).
|
- Используется для fallback-обновления и (при необходимости) remote ops; для qwinsta/logoff MVP — **через агента** с теми же creds, переданными в command poll (TLS + API key, не пишутся на диск агента).
|
||||||
- API: `GET` / `PUT /api/v1/hosts/{id}/access` (`user`, `password`, `clear`).
|
|
||||||
- Используются для WinRM/SSH-test, fallback-update, qwinsta/logoff, remote ops; для run_as через агента — те же creds в command poll (TLS + API key, не пишутся на диск агента).
|
|
||||||
|
|
||||||
### 5.2. Linux — bootstrap password → SSH key → удалить password
|
### 5.2. Linux — bootstrap password → SSH key → удалить password
|
||||||
|
|
||||||
@@ -268,7 +266,7 @@ Authorization: Bearer sac_xxx
|
|||||||
| POST | `/api/v1/events/{id}/actions/logoff` | logoff `{ "session_id": 5 }` |
|
| POST | `/api/v1/events/{id}/actions/logoff` | logoff `{ "session_id": 5 }` |
|
||||||
| GET | `/api/v1/events/{id}/actions/{cmd_id}` | Статус / результат |
|
| GET | `/api/v1/events/{id}/actions/{cmd_id}` | Статус / результат |
|
||||||
| PATCH | `/api/v1/hosts/{id}/config` | Desired config |
|
| PATCH | `/api/v1/hosts/{id}/config` | Desired config |
|
||||||
| GET/PUT | `/api/v1/hosts/{id}/access` | Per-host WinRM/SSH override (mgmt_user/password) |
|
| PATCH | `/api/v1/hosts/{id}/access` | Bootstrap / WinRM creds |
|
||||||
| GET/PATCH | `/api/v1/settings/agent-updates` | Режим A/B, версии, источники |
|
| GET/PATCH | `/api/v1/settings/agent-updates` | Режим A/B, версии, источники |
|
||||||
| GET/PATCH | `/api/v1/settings/host-management` | Доменный admin Windows |
|
| GET/PATCH | `/api/v1/settings/host-management` | Доменный admin Windows |
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
"$id": "https://git.papatramp.ru/PapaTramp/security-alert-center/schemas/event-v1.json",
|
"$id": "https://git.kalinamall.ru/PapaTramp/security-alert-center/schemas/event-v1.json",
|
||||||
"title": "Security Alert Center Event v1",
|
"title": "Security Alert Center Event v1",
|
||||||
"description": "Каноническое событие от ssh-monitor или RDP-login-monitor",
|
"description": "Каноническое событие от ssh-monitor или RDP-login-monitor",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
**Статус:** ToDo (не в текущем релизе).
|
**Статус:** ToDo (не в текущем релизе).
|
||||||
**Контекст:** массовый SSH-update через SAC (10+ хостов) + `sac-deploy` в одно окно → часть POST в ingest «теряется» с точки зрения агента (`SAC POST HTTP :`), flood в Telegram (fallback + watchdog).
|
**Контекст:** массовый SSH-update через SAC (10+ хостов) + `sac-deploy` в одно окно → часть POST в ingest «теряется» с точки зрения агента (`SAC POST HTTP :`), flood в Telegram (fallback + watchdog).
|
||||||
**Связано:** [runbook-ops.md](runbook-ops.md), [agent-integration.md](agent-integration.md), ssh-monitor [security-roadmap.ru.md](https://git.papatramp.ru/PapaTramp/ssh-monitor/src/branch/main/docs/security-roadmap.ru.md).
|
**Связано:** [runbook-ops.md](runbook-ops.md), [agent-integration.md](agent-integration.md), ssh-monitor [security-roadmap.ru.md](https://git.kalinamall.ru/PapaTramp/ssh-monitor/src/branch/main/docs/security-roadmap.ru.md).
|
||||||
|
|
||||||
Увеличение `SAC_DB_POOL_SIZE` / defer daily в **0.5.0** лечит штурм суточных отчётов и пул БД; **не** снимает узкие места ниже при одновременном restart многих агентов.
|
Увеличение `SAC_DB_POOL_SIZE` / defer daily в **0.5.0** лечит штурм суточных отчётов и пул БД; **не** снимает узкие места ниже при одновременном restart многих агентов.
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Docker удобен для локальной отладки или изолир
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install -y git
|
sudo apt install -y git
|
||||||
sudo git clone https://git.papatramp.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
sudo git clone https://git.kalinamall.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
||||||
sudo chown -R "$USER:$USER" /opt/security-alert-center
|
sudo chown -R "$USER:$USER" /opt/security-alert-center
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ nginx -v
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo mkdir -p /opt
|
sudo mkdir -p /opt
|
||||||
sudo git clone https://git.papatramp.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
sudo git clone https://git.kalinamall.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
```bash
|
```bash
|
||||||
# см. полный чеклист в native-руководстве
|
# см. полный чеклист в native-руководстве
|
||||||
sudo apt update && sudo apt install -y git postgresql nginx python3.12 python3.12-venv
|
sudo apt update && sudo apt install -y git postgresql nginx python3.12 python3.12-venv
|
||||||
sudo git clone https://git.papatramp.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
sudo git clone https://git.kalinamall.ru/PapaTramp/security-alert-center.git /opt/security-alert-center
|
||||||
# … PostgreSQL, venv, config/sac-api.env, systemd, nginx
|
# … PostgreSQL, venv, config/sac-api.env, systemd, nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ sudo /opt/sac-deploy.sh
|
|||||||
| Параметр | Значение |
|
| Параметр | Значение |
|
||||||
|----------|----------|
|
|----------|----------|
|
||||||
| Хост | `ubabuba` / `10.10.36.9` |
|
| Хост | `ubabuba` / `10.10.36.9` |
|
||||||
| Репозиторий | `git.papatramp.ru/PapaTramp/ssh-monitor` (`main`, есть `sac-client.sh`) |
|
| Репозиторий | `git.kalinamall.ru/PapaTramp/ssh-monitor` (`main`, есть `sac-client.sh`) |
|
||||||
| `UseSAC` | пилот **exclusive** — см. [pilot-2.1-exclusive.md](pilot-2.1-exclusive.md) |
|
| `UseSAC` | пилот **exclusive** — см. [pilot-2.1-exclusive.md](pilot-2.1-exclusive.md) |
|
||||||
| Сервис | `ssh-monitor.service` — **active** |
|
| Сервис | `ssh-monitor.service` — **active** |
|
||||||
| `--check-sac` | OK (health + ingest `agent.test` 202) |
|
| `--check-sac` | OK (health + ingest `agent.test` 202) |
|
||||||
|
|||||||
+3
-3
@@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
**Цель:** нативный Android-клиент и push по тем же правилам оповещений, что Telegram/email/webhook.
|
**Цель:** нативный Android-клиент и push по тем же правилам оповещений, что Telegram/email/webhook.
|
||||||
|
|
||||||
Репозиторий клиента: [seaca](https://git.papatramp.ru/PapaTramp/seaca) (Kotlin, Jetpack Compose, FCM).
|
Репозиторий клиента: [seaca](https://git.kalinamall.ru/PapaTramp/seaca) (Kotlin, Jetpack Compose, FCM).
|
||||||
|
|
||||||
**Сервер SAC:**
|
**Сервер SAC:**
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
**Не в мобильном клиенте:** пользователи SAC, каналы Telegram/SMTP/webhook, админ-настройки.
|
**Не в мобильном клиенте:** пользователи SAC, каналы Telegram/SMTP/webhook, админ-настройки.
|
||||||
|
|
||||||
Подробный план клиента — [seaca/docs/ROADMAP.md](https://git.papatramp.ru/PapaTramp/seaca/src/branch/main/docs/ROADMAP.md).
|
Подробный план клиента — [seaca/docs/ROADMAP.md](https://git.kalinamall.ru/PapaTramp/seaca/src/branch/main/docs/ROADMAP.md).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
| v0.1 | — (не требуется) | — |
|
| v0.1 | — (не требуется) | — |
|
||||||
| v0.2 | TBD (тег с UseSAC) | TBD |
|
| v0.2 | TBD (тег с UseSAC) | TBD |
|
||||||
| v0.3+ | совместимость schema 1.0 | совместимость schema 1.0 |
|
| v0.3+ | совместимость schema 1.0 | совместимость schema 1.0 |
|
||||||
| v0.6 | — | — (мобильный клиент [seaca](https://git.papatramp.ru/PapaTramp/seaca), не агент) |
|
| v0.6 | — | — (мобильный клиент [seaca](https://git.kalinamall.ru/PapaTramp/seaca), не агент) |
|
||||||
|
|
||||||
При breaking change схемы — `schema_version: 1.1` с поддержкой 1.0 на ingest.
|
При breaking change схемы — `schema_version: 1.1` с поддержкой 1.0 на ingest.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Seaca — мобильный клиент SAC
|
# Seaca — мобильный клиент SAC
|
||||||
|
|
||||||
Репозиторий приложения: [seaca](https://git.papatramp.ru/PapaTramp/seaca).
|
Репозиторий приложения: [seaca](https://git.kalinamall.ru/PapaTramp/seaca).
|
||||||
Требуется SAC **≥ 0.9.0** с применённой миграцией `014`.
|
Требуется SAC **≥ 0.9.0** с применённой миграцией `014`.
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -84,7 +84,7 @@ SAC_FCM_SERVICE_ACCOUNT_JSON=/etc/security-alert-center/fcm-service-account.json
|
|||||||
| `sac.kalinamall.ru` | Web UI | yes (`git-sac-allowed`) |
|
| `sac.kalinamall.ru` | Web UI | yes (`git-sac-allowed`) |
|
||||||
| `sac-api.kalinamall.ru` | Seaca, `/api/v1/mobile/*` | no (enroll + JWT) |
|
| `sac-api.kalinamall.ru` | Seaca, `/api/v1/mobile/*` | no (enroll + JWT) |
|
||||||
|
|
||||||
Both resolve to the same SAC server (**192.168.160.145**). nginx must accept both names in `server_name`. See [reverse-proxy/docs/sac-access.md](https://git.papatramp.ru/PapaTramp/reverse-proxy/src/branch/main/docs/sac-access.md).
|
Both resolve to the same SAC server (**192.168.160.145**). nginx must accept both names in `server_name`. See [reverse-proxy/docs/sac-access.md](https://git.kalinamall.ru/PapaTramp/reverse-proxy/src/branch/main/docs/sac-access.md).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
| Имя в workspace | Путь (пример Windows) | Remote |
|
| Имя в workspace | Путь (пример Windows) | Remote |
|
||||||
|-----------------|----------------------|--------|
|
|-----------------|----------------------|--------|
|
||||||
| `ssh-monitor` | `D:\Soft\Git\ssh-monitor` | git.papatramp.ru/PapaTramp/ssh-monitor |
|
| `ssh-monitor` | `D:\Soft\Git\ssh-monitor` | git.kalinamall.ru/PapaTramp/ssh-monitor |
|
||||||
| `rdp-monitor` | `D:\Soft\Git\RDP-login-monitor` | git.papatramp.ru/PapaTramp/RDP-login-monitor |
|
| `rdp-monitor` | `D:\Soft\Git\RDP-login-monitor` | git.kalinamall.ru/PapaTramp/RDP-login-monitor |
|
||||||
| `security-alert-center` | `D:\Soft\Git\security-alert-center` | git.papatramp.ru/PapaTramp/security-alert-center |
|
| `security-alert-center` | `D:\Soft\Git\security-alert-center` | git.kalinamall.ru/PapaTramp/security-alert-center |
|
||||||
|
|
||||||
Пути подставьте свои.
|
Пути подставьте свои.
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ git push kalinamall main
|
|||||||
|
|
||||||
| Проект | URL |
|
| Проект | URL |
|
||||||
|--------|-----|
|
|--------|-----|
|
||||||
| security-alert-center | `https://git.papatramp.ru/PapaTramp/security-alert-center.git` |
|
| security-alert-center | `https://git.kalinamall.ru/PapaTramp/security-alert-center.git` |
|
||||||
| ssh-monitor | `https://git.papatramp.ru/PapaTramp/ssh-monitor.git` |
|
| ssh-monitor | `https://git.kalinamall.ru/PapaTramp/ssh-monitor.git` |
|
||||||
| RDP-login-monitor | `https://git.papatramp.ru/PapaTramp/RDP-login-monitor.git` |
|
| RDP-login-monitor | `https://git.kalinamall.ru/PapaTramp/RDP-login-monitor.git` |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,6 @@ export interface EventSummary {
|
|||||||
title: string;
|
title: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
actor_user?: string | null;
|
actor_user?: string | null;
|
||||||
session_duration_sec?: number | null;
|
|
||||||
rdg_flap?: boolean;
|
rdg_flap?: boolean;
|
||||||
rdg_flap_pair_event_id?: number | null;
|
rdg_flap_pair_event_id?: number | null;
|
||||||
rdg_flap_qwinsta_event_id?: number | null;
|
rdg_flap_qwinsta_event_id?: number | null;
|
||||||
@@ -532,31 +531,6 @@ export function updateLinuxAdminSettings(payload: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HostMgmtAccess {
|
|
||||||
host_id: number;
|
|
||||||
has_override: boolean;
|
|
||||||
user: string | null;
|
|
||||||
password_set: boolean;
|
|
||||||
password_hint: string | null;
|
|
||||||
effective_source: string;
|
|
||||||
effective_configured: boolean;
|
|
||||||
effective_user: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchHostAccess(hostId: number): Promise<HostMgmtAccess> {
|
|
||||||
return apiFetch<HostMgmtAccess>(`/api/v1/hosts/${hostId}/access`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateHostAccess(
|
|
||||||
hostId: number,
|
|
||||||
payload: { user?: string | null; password?: string | null; clear?: boolean },
|
|
||||||
): Promise<HostMgmtAccess> {
|
|
||||||
return apiFetch<HostMgmtAccess>(`/api/v1/hosts/${hostId}/access`, {
|
|
||||||
method: "PUT",
|
|
||||||
body: JSON.stringify(payload),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface HostSshActionResult {
|
export interface HostSshActionResult {
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
message: string;
|
message: string;
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
/** Human-readable session_duration_sec for event tables. */
|
|
||||||
|
|
||||||
export function formatSessionDuration(seconds: number | null | undefined): string {
|
|
||||||
if (seconds == null || !Number.isFinite(seconds) || seconds < 0) {
|
|
||||||
return "—";
|
|
||||||
}
|
|
||||||
const total = Math.floor(seconds);
|
|
||||||
const days = Math.floor(total / 86_400);
|
|
||||||
const hours = Math.floor((total % 86_400) / 3600);
|
|
||||||
const minutes = Math.floor((total % 3600) / 60);
|
|
||||||
const secs = total % 60;
|
|
||||||
const clock = `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
|
||||||
if (days > 0) {
|
|
||||||
return `${days}д ${clock}`;
|
|
||||||
}
|
|
||||||
return clock;
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/** Fallback до загрузки /health; при релизе держите в sync с backend/app/version.py */
|
/** Fallback до загрузки /health; при релизе держите в sync с backend/app/version.py */
|
||||||
export const APP_NAME = "Security Alert Center";
|
export const APP_NAME = "Security Alert Center";
|
||||||
export const APP_VERSION = "0.5.17";
|
export const APP_VERSION = "0.5.14";
|
||||||
export const APP_VERSION_LABEL = `${APP_NAME} v.${APP_VERSION}`;
|
export const APP_VERSION_LABEL = `${APP_NAME} v.${APP_VERSION}`;
|
||||||
|
|||||||
@@ -238,8 +238,6 @@
|
|||||||
|
|
||||||
<th>Пользователь</th>
|
<th>Пользователь</th>
|
||||||
|
|
||||||
<th title="Длительность сессии (из session_duration_sec)">Длительность</th>
|
|
||||||
|
|
||||||
<th>Версия агента</th>
|
<th>Версия агента</th>
|
||||||
|
|
||||||
<th>Severity</th>
|
<th>Severity</th>
|
||||||
@@ -278,8 +276,6 @@
|
|||||||
|
|
||||||
<td>{{ e.actor_user || "—" }}</td>
|
<td>{{ e.actor_user || "—" }}</td>
|
||||||
|
|
||||||
<td>{{ formatSessionDuration(e.session_duration_sec) }}</td>
|
|
||||||
|
|
||||||
<td>{{ e.product_version || "—" }}</td>
|
<td>{{ e.product_version || "—" }}</td>
|
||||||
|
|
||||||
<td :class="'sev-' + e.severity">{{ e.severity }}</td>
|
<td :class="'sev-' + e.severity">{{ e.severity }}</td>
|
||||||
@@ -358,7 +354,6 @@ import RdgQwinstaModal from "../components/RdgQwinstaModal.vue";
|
|||||||
import { useRdgQwinsta } from "../composables/useRdgQwinsta";
|
import { useRdgQwinsta } from "../composables/useRdgQwinsta";
|
||||||
import { formatServerName } from "../utils/hostDisplay";
|
import { formatServerName } from "../utils/hostDisplay";
|
||||||
import { hasRdgFlapUi, rdgQwinstaEventId } from "../utils/rdgFlap";
|
import { hasRdgFlapUi, rdgQwinstaEventId } from "../utils/rdgFlap";
|
||||||
import { formatSessionDuration } from "../utils/sessionDuration";
|
|
||||||
import { markEventSessionTerminatedInList, showEventSessionTerminateButton } from "../utils/sessionActions";
|
import { markEventSessionTerminatedInList, showEventSessionTerminateButton } from "../utils/sessionActions";
|
||||||
|
|
||||||
const { qwinstaLoadingId, qwinstaModal, closeQwinstaModal, runQwinsta, runLogoff } = useRdgQwinsta();
|
const { qwinstaLoadingId, qwinstaModal, closeQwinstaModal, runQwinsta, runLogoff } = useRdgQwinsta();
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
<th>Хост</th>
|
<th>Хост</th>
|
||||||
<th>Имя сервера</th>
|
<th>Имя сервера</th>
|
||||||
<th>Пользователь</th>
|
<th>Пользователь</th>
|
||||||
<th title="Длительность сессии (из session_duration_sec)">Длительность</th>
|
|
||||||
<th>Версия агента</th>
|
<th>Версия агента</th>
|
||||||
<th>Severity</th>
|
<th>Severity</th>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
@@ -51,7 +50,6 @@
|
|||||||
<td>{{ e.hostname }}</td>
|
<td>{{ e.hostname }}</td>
|
||||||
<td>{{ formatServerName(e.display_name) }}</td>
|
<td>{{ formatServerName(e.display_name) }}</td>
|
||||||
<td>{{ e.actor_user || "—" }}</td>
|
<td>{{ e.actor_user || "—" }}</td>
|
||||||
<td>{{ formatSessionDuration(e.session_duration_sec) }}</td>
|
|
||||||
<td>{{ e.product_version || "—" }}</td>
|
<td>{{ e.product_version || "—" }}</td>
|
||||||
<td :class="'sev-' + e.severity">{{ e.severity }}</td>
|
<td :class="'sev-' + e.severity">{{ e.severity }}</td>
|
||||||
<td><code>{{ e.type }}</code></td>
|
<td><code>{{ e.type }}</code></td>
|
||||||
@@ -122,7 +120,6 @@ import {
|
|||||||
type EventsListState,
|
type EventsListState,
|
||||||
} from "../utils/eventsListQuery";
|
} from "../utils/eventsListQuery";
|
||||||
import { formatServerName } from "../utils/hostDisplay";
|
import { formatServerName } from "../utils/hostDisplay";
|
||||||
import { formatSessionDuration } from "../utils/sessionDuration";
|
|
||||||
import { markEventSessionTerminatedInList, showEventSessionTerminateButton } from "../utils/sessionActions";
|
import { markEventSessionTerminatedInList, showEventSessionTerminateButton } from "../utils/sessionActions";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|||||||
@@ -69,52 +69,6 @@
|
|||||||
<dd>{{ host.event_count ?? 0 }}</dd>
|
<dd>{{ host.event_count ?? 0 }}</dd>
|
||||||
</div>
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<section v-if="showAgentConfig" class="host-mgmt-access">
|
|
||||||
<h3>{{ isWindowsHost ? "WinRM / доступ к хосту" : "SSH / доступ к хосту" }}</h3>
|
|
||||||
<p class="muted">
|
|
||||||
Переопределение для этого ПК. Если пусто — используются глобальные учётные данные из
|
|
||||||
<RouterLink to="/settings">Настройки</RouterLink>
|
|
||||||
({{ isWindowsHost ? "Windows admin" : "Linux admin" }}).
|
|
||||||
Сейчас effective:
|
|
||||||
<strong>{{ accessEffectiveLabel }}</strong>
|
|
||||||
</p>
|
|
||||||
<form class="agent-config-form" @submit.prevent="saveHostAccess">
|
|
||||||
<label class="config-field">
|
|
||||||
Логин
|
|
||||||
<input
|
|
||||||
v-model="accessForm.user"
|
|
||||||
type="text"
|
|
||||||
:placeholder="isWindowsHost ? 'COMPUTER\\user или .\\Administrator' : 'root'"
|
|
||||||
autocomplete="off"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<label class="config-field">
|
|
||||||
Пароль
|
|
||||||
<input
|
|
||||||
v-model="accessForm.password"
|
|
||||||
type="password"
|
|
||||||
:placeholder="accessForm.passwordSet ? '•••• (оставьте пустым, чтобы не менять)' : ''"
|
|
||||||
autocomplete="new-password"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<div class="host-actions-row">
|
|
||||||
<button type="submit" :disabled="savingAccess">
|
|
||||||
{{ savingAccess ? "Сохранение…" : "Сохранить доступ" }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="secondary"
|
|
||||||
:disabled="savingAccess || !accessForm.hasOverride"
|
|
||||||
@click="clearHostAccess"
|
|
||||||
>
|
|
||||||
Сбросить (глобальные)
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p v-if="accessMessage" :class="accessOk ? 'success' : 'error'">{{ accessMessage }}</p>
|
|
||||||
</form>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div v-if="isWindowsHost" class="host-actions">
|
<div v-if="isWindowsHost" class="host-actions">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -342,8 +296,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
apiFetch,
|
apiFetch,
|
||||||
fetchHost,
|
fetchHost,
|
||||||
fetchHostAccess,
|
|
||||||
updateHostAccess,
|
|
||||||
fetchRecentEvents,
|
fetchRecentEvents,
|
||||||
testHostWinRm,
|
testHostWinRm,
|
||||||
testHostSsh,
|
testHostSsh,
|
||||||
@@ -351,7 +303,6 @@ import {
|
|||||||
patchHostAgentConfig,
|
patchHostAgentConfig,
|
||||||
type EventListResponse,
|
type EventListResponse,
|
||||||
type HostDetail,
|
type HostDetail,
|
||||||
type HostMgmtAccess,
|
|
||||||
} from "../api";
|
} from "../api";
|
||||||
import { emitHostPatch } from "../utils/hostPatchBus";
|
import { emitHostPatch } from "../utils/hostPatchBus";
|
||||||
import HostSessionsPanel from "../components/HostSessionsPanel.vue";
|
import HostSessionsPanel from "../components/HostSessionsPanel.vue";
|
||||||
@@ -403,32 +354,6 @@ const configForm = reactive({
|
|||||||
serverDisplayName: "",
|
serverDisplayName: "",
|
||||||
getInventory: true,
|
getInventory: true,
|
||||||
});
|
});
|
||||||
const savingAccess = ref(false);
|
|
||||||
const accessMessage = ref("");
|
|
||||||
const accessOk = ref(false);
|
|
||||||
const accessForm = reactive({
|
|
||||||
user: "",
|
|
||||||
password: "",
|
|
||||||
passwordSet: false,
|
|
||||||
hasOverride: false,
|
|
||||||
effectiveSource: "",
|
|
||||||
effectiveUser: "",
|
|
||||||
effectiveConfigured: false,
|
|
||||||
});
|
|
||||||
const accessEffectiveLabel = computed(() => {
|
|
||||||
if (!accessForm.effectiveConfigured) {
|
|
||||||
return "не настроено";
|
|
||||||
}
|
|
||||||
const src =
|
|
||||||
accessForm.effectiveSource === "host"
|
|
||||||
? "override хоста"
|
|
||||||
: accessForm.effectiveSource === "db"
|
|
||||||
? "глобальные (Settings)"
|
|
||||||
: accessForm.effectiveSource === "env"
|
|
||||||
? "env"
|
|
||||||
: accessForm.effectiveSource;
|
|
||||||
return `${accessForm.effectiveUser || "—"} · ${src}`;
|
|
||||||
});
|
|
||||||
let sshTestHideTimer: ReturnType<typeof setTimeout> | null = null;
|
let sshTestHideTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
let winRmTestHideTimer: ReturnType<typeof setTimeout> | null = null;
|
let winRmTestHideTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
let sshProbeSeq = 0;
|
let sshProbeSeq = 0;
|
||||||
@@ -753,67 +678,6 @@ async function saveAgentConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyAccessView(view: HostMgmtAccess) {
|
|
||||||
accessForm.user = view.user || "";
|
|
||||||
accessForm.password = "";
|
|
||||||
accessForm.passwordSet = view.password_set;
|
|
||||||
accessForm.hasOverride = view.has_override;
|
|
||||||
accessForm.effectiveSource = view.effective_source;
|
|
||||||
accessForm.effectiveUser = view.effective_user || "";
|
|
||||||
accessForm.effectiveConfigured = view.effective_configured;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadHostAccess() {
|
|
||||||
accessMessage.value = "";
|
|
||||||
try {
|
|
||||||
const view = await fetchHostAccess(hostId.value);
|
|
||||||
applyAccessView(view);
|
|
||||||
} catch (e) {
|
|
||||||
accessOk.value = false;
|
|
||||||
accessMessage.value = e instanceof Error ? e.message : "Не удалось загрузить доступ хоста";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveHostAccess() {
|
|
||||||
savingAccess.value = true;
|
|
||||||
accessMessage.value = "";
|
|
||||||
try {
|
|
||||||
const payload: { user?: string | null; password?: string | null } = {
|
|
||||||
user: accessForm.user,
|
|
||||||
};
|
|
||||||
if (accessForm.password.trim()) {
|
|
||||||
payload.password = accessForm.password;
|
|
||||||
}
|
|
||||||
const view = await updateHostAccess(hostId.value, payload);
|
|
||||||
applyAccessView(view);
|
|
||||||
accessOk.value = true;
|
|
||||||
accessMessage.value = view.has_override
|
|
||||||
? "Сохранено (override хоста)"
|
|
||||||
: "Сохранено (логин очищен — глобальные настройки)";
|
|
||||||
} catch (e) {
|
|
||||||
accessOk.value = false;
|
|
||||||
accessMessage.value = e instanceof Error ? e.message : "Ошибка сохранения доступа";
|
|
||||||
} finally {
|
|
||||||
savingAccess.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function clearHostAccess() {
|
|
||||||
savingAccess.value = true;
|
|
||||||
accessMessage.value = "";
|
|
||||||
try {
|
|
||||||
const view = await updateHostAccess(hostId.value, { clear: true });
|
|
||||||
applyAccessView(view);
|
|
||||||
accessOk.value = true;
|
|
||||||
accessMessage.value = "Override сброшен — используются глобальные настройки";
|
|
||||||
} catch (e) {
|
|
||||||
accessOk.value = false;
|
|
||||||
accessMessage.value = e instanceof Error ? e.message : "Ошибка сброса доступа";
|
|
||||||
} finally {
|
|
||||||
savingAccess.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadHost() {
|
async function loadHost() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
error.value = "";
|
error.value = "";
|
||||||
@@ -828,7 +692,6 @@ async function loadHost() {
|
|||||||
try {
|
try {
|
||||||
const detail = await fetchHost(hostId.value);
|
const detail = await fetchHost(hostId.value);
|
||||||
applyHostDetail(detail);
|
applyHostDetail(detail);
|
||||||
void loadHostAccess();
|
|
||||||
if (isLinuxHostDetail(detail)) {
|
if (isLinuxHostDetail(detail)) {
|
||||||
void probeSshOnOpen();
|
void probeSshOnOpen();
|
||||||
}
|
}
|
||||||
@@ -985,49 +848,6 @@ watch(
|
|||||||
color: #9aa4b2;
|
color: #9aa4b2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.host-mgmt-access {
|
|
||||||
margin: 1rem 0 1.25rem;
|
|
||||||
padding: 0.85rem 1rem;
|
|
||||||
border: 1px solid #2a3340;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #141a22;
|
|
||||||
}
|
|
||||||
|
|
||||||
.host-mgmt-access h3 {
|
|
||||||
margin: 0 0 0.35rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.host-mgmt-form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.65rem;
|
|
||||||
margin-top: 0.75rem;
|
|
||||||
max-width: 28rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.host-mgmt-field {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.25rem;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.host-mgmt-field input {
|
|
||||||
padding: 0.4rem 0.55rem;
|
|
||||||
border-radius: 6px;
|
|
||||||
border: 1px solid #3a4554;
|
|
||||||
background: #0f1419;
|
|
||||||
color: #e8eef5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.host-mgmt-actions {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 0.5rem;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.host-actions {
|
.host-actions {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="settings-page">
|
<div class="settings-page">
|
||||||
<h1>Настройки</h1>
|
<h1>Настройки</h1>
|
||||||
<p class="settings-intro">
|
<p class="settings-intro">
|
||||||
@@ -126,9 +126,8 @@
|
|||||||
<section class="card settings-card settings-policy">
|
<section class="card settings-card settings-policy">
|
||||||
<h2>Windows (qwinsta / logoff)</h2>
|
<h2>Windows (qwinsta / logoff)</h2>
|
||||||
<p class="settings-hint settings-hint-top">
|
<p class="settings-hint settings-hint-top">
|
||||||
Глобальный (доменный) admin для удалённых команд на Windows-хостах (qwinsta, logoff, WinRM-update).
|
Доменный admin для удалённых команд на Windows-хостах (qwinsta, logoff через агент).
|
||||||
Формат логина: <code>ДОМЕН\пользователь</code> (например <code>B26\papatramp</code>).
|
Формат логина: <code>ДОМЕН\пользователь</code> (например <code>B26\papatramp</code>).
|
||||||
Для отдельного ПК (home/workgroup) задайте override в карточке <strong>Хосты → доступ к хосту</strong>.
|
|
||||||
Пока запись не создана в UI — используются <code>SAC_WIN_ADMIN_*</code> из <code>sac-api.env</code>.
|
Пока запись не создана в UI — используются <code>SAC_WIN_ADMIN_*</code> из <code>sac-api.env</code>.
|
||||||
</p>
|
</p>
|
||||||
<form class="settings-form" @submit.prevent="saveWinAdminSettings">
|
<form class="settings-form" @submit.prevent="saveWinAdminSettings">
|
||||||
@@ -187,9 +186,8 @@
|
|||||||
<section class="card settings-card settings-policy">
|
<section class="card settings-card settings-policy">
|
||||||
<h2>Linux (SSH / обновление ssh-monitor)</h2>
|
<h2>Linux (SSH / обновление ssh-monitor)</h2>
|
||||||
<p class="settings-hint settings-hint-top">
|
<p class="settings-hint settings-hint-top">
|
||||||
Глобальная SSH-учётка для удалённого запуска <code>/opt/scripts/update_ssh_monitor.sh</code> с карточки Linux-хоста.
|
SSH-учётка для удалённого запуска <code>/opt/scripts/update_ssh_monitor.sh</code> с карточки Linux-хоста.
|
||||||
Рекомендуется <code>root</code> или пользователь с <code>sudo NOPASSWD</code>.
|
Рекомендуется <code>root</code> или пользователь с <code>sudo NOPASSWD</code>.
|
||||||
Для отдельного сервера задайте override в карточке <strong>Хосты → доступ к хосту</strong>.
|
|
||||||
Пока запись не создана в UI — используются <code>SAC_LINUX_ADMIN_*</code> из <code>sac-api.env</code>.
|
Пока запись не создана в UI — используются <code>SAC_LINUX_ADMIN_*</code> из <code>sac-api.env</code>.
|
||||||
</p>
|
</p>
|
||||||
<form class="settings-form" @submit.prevent="saveLinuxAdminSettings">
|
<form class="settings-form" @submit.prevent="saveLinuxAdminSettings">
|
||||||
@@ -253,7 +251,7 @@
|
|||||||
<input
|
<input
|
||||||
v-model="agentUpdateForm.rdp_git_repo_url"
|
v-model="agentUpdateForm.rdp_git_repo_url"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="https://git.papatramp.ru/PapaTramp/RDP-login-monitor.git"
|
placeholder="https://git.kalinamall.ru/PapaTramp/RDP-login-monitor.git"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label class="settings-field">
|
<label class="settings-field">
|
||||||
@@ -261,7 +259,7 @@
|
|||||||
<input
|
<input
|
||||||
v-model="agentUpdateForm.ssh_git_repo_url"
|
v-model="agentUpdateForm.ssh_git_repo_url"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="https://git.papatramp.ru/PapaTramp/ssh-monitor.git"
|
placeholder="https://git.kalinamall.ru/PapaTramp/ssh-monitor.git"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label class="settings-field">
|
<label class="settings-field">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
"$id": "https://git.papatramp.ru/PapaTramp/security-alert-center/schemas/event-v1.json",
|
"$id": "https://git.kalinamall.ru/PapaTramp/security-alert-center/schemas/event-v1.json",
|
||||||
"title": "Security Alert Center Event v1",
|
"title": "Security Alert Center Event v1",
|
||||||
"description": "Каноническое событие от ssh-monitor или RDP-login-monitor",
|
"description": "Каноническое событие от ssh-monitor или RDP-login-monitor",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|||||||
Regular → Executable
@@ -7,8 +7,8 @@ REMOTE_CMD = (
|
|||||||
"set -e\n"
|
"set -e\n"
|
||||||
"TMP=$(mktemp -d)\n"
|
"TMP=$(mktemp -d)\n"
|
||||||
'trap "rm -rf \\"$TMP\\"" EXIT\n'
|
'trap "rm -rf \\"$TMP\\"" EXIT\n'
|
||||||
"git clone --depth 1 -q https://git.papatramp.ru/PapaTramp/RDP-login-monitor.git \"$TMP/rdp\"\n"
|
"git clone --depth 1 -q https://git.kalinamall.ru/PapaTramp/RDP-login-monitor.git \"$TMP/rdp\"\n"
|
||||||
"git clone --depth 1 -q https://git.papatramp.ru/PapaTramp/ssh-monitor.git \"$TMP/ssh\"\n"
|
"git clone --depth 1 -q https://git.kalinamall.ru/PapaTramp/ssh-monitor.git \"$TMP/ssh\"\n"
|
||||||
"echo RDP_version_txt:\n"
|
"echo RDP_version_txt:\n"
|
||||||
"cat \"$TMP/rdp/version.txt\" 2>/dev/null || echo missing\n"
|
"cat \"$TMP/rdp/version.txt\" 2>/dev/null || echo missing\n"
|
||||||
"echo RDP_script:\n"
|
"echo RDP_script:\n"
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
set -e
|
set -e
|
||||||
TMP=$(mktemp -d)
|
TMP=$(mktemp -d)
|
||||||
trap 'rm -rf "$TMP"' EXIT
|
trap 'rm -rf "$TMP"' EXIT
|
||||||
git clone --depth 1 -q https://git.papatramp.ru/PapaTramp/RDP-login-monitor.git "$TMP/rdp"
|
git clone --depth 1 -q https://git.kalinamall.ru/PapaTramp/RDP-login-monitor.git "$TMP/rdp"
|
||||||
git clone --depth 1 -q https://git.papatramp.ru/PapaTramp/ssh-monitor.git "$TMP/ssh"
|
git clone --depth 1 -q https://git.kalinamall.ru/PapaTramp/ssh-monitor.git "$TMP/ssh"
|
||||||
echo RDP_version_txt:
|
echo RDP_version_txt:
|
||||||
cat "$TMP/rdp/version.txt" 2>/dev/null || echo missing
|
cat "$TMP/rdp/version.txt" 2>/dev/null || echo missing
|
||||||
echo RDP_script:
|
echo RDP_script:
|
||||||
|
|||||||
Reference in New Issue
Block a user