Documentation - Three levels: DOCS/General (overview, configuration), DOCS/Deployment (choose a method, first steps), details per method in Containers/ and System_Services/; new root README and DOCS/README map. - Remove superseded pages (Deployment.md, Deployment_Docker/Native.md, Index.md); split the two scenario guides by section. - Isolate the Timeweb/Hysteria2 records in DEPLOYMENTS/timeweb-hysteria2/ (not linked from DOCS, listed in .graphifyignore). - Add DOCS/code_review/ with a time-stamped analysis of the code base. Gatherer (BUG-02, BUG-03) - Session key (CN, address, connected_since_ts), baseline from the active_sessions snapshot, grace period for sessions missing from the status. - Status file integrity (TITLE/TIME/END) and freshness; a torn read skips the tick. - Cache applied after commit; main loop survives exceptions, backs off, and stops cleanly on SIGTERM/SIGINT; new client rows start with the first frame's totals; five tests. JWT signing key (SEC-01) - No built-in default: Core and Profiler refuse to start with a missing, placeholder or short (< 32) key; shipped config.ini has an empty value. - Same rule in install.sh, update.sh (issues a new key when missing or weak), docker lib/entrypoint; five tests, conftest.py for the test key. Each change has a plan and a summary under DOCS/Changes/. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
51 lines
3.8 KiB
Markdown
51 lines
3.8 KiB
Markdown
# Артефакт внедрения: п.1 — валидация настроек Profiler
|
|
|
|
Дата: 2026-09-30. Узел: 213.226.125.13 (Alpine, OpenRC). Приложение: `/opt/OpenVPN-Monitoring-Simple`. План: `PLAN-validation-and-privilege-drop.md`.
|
|
Коммит в репозитории приложения на узле: `05f44b9` («Profiler: validate server/PKI settings before they reach OpenVPN config»), пуш не выполнялся.
|
|
|
|
## 1. Что внедрено
|
|
|
|
| Слой | Файл | Суть |
|
|
|---|---|---|
|
|
| A | `APP_PROFILER/schemas.py` | валидаторы `SystemSettingsUpdate`, `PKISettingUpdate` (422) |
|
|
| B | `APP_PROFILER/services/validation.py` (новый), `services/generator.py` | `check_script`: скрипт только из `/etc/openvpn/scripts/`, root-owned, без записи group/other |
|
|
| C | `APP_PROFILER/services/generator.py`, `routers/server.py` | отказ при `\n`, `\r`, NUL, управляющих символах, `"`, `\`; `ValueError` → HTTP 400 |
|
|
|
|
## 2. Порядок внедрения
|
|
|
|
1. Бэкап изменяемых файлов: `/root/app-bak/p1/` (`schemas.py`, `generator.py`, `server.py`).
|
|
2. Добавлен `services/validation.py`; правки `schemas.py`, `generator.py`, `routers/server.py` (Python-патч с проверкой якорей `assert`).
|
|
3. Проверка импорта: `venv/bin/python -c "import schemas"`.
|
|
4. `rc-service ovpmon-profiler restart`.
|
|
5. Тесты (скрипт запускался на узле с локально выпущенным токеном, т.к. на учётке включена 2FA).
|
|
6. Документация: `DOCS/Changes/2026-09-30_Settings_Validation.md`, ссылки в `README.md`, `DOCS/General/Index.md`; коммит.
|
|
|
|
## 3. Доказательства (результаты тестов)
|
|
|
|
| Проверка | Результат |
|
|
|---|---|
|
|
| Круговой `PUT` текущих настроек server / pki | 200 / 200 |
|
|
| 17 вредоносных или невалидных значений | все 422 |
|
|
| 4 валидных изменения | все 200 |
|
|
| Скрипты: root 755 / group-writable / симлинк / нет файла / вне каталога / traversal / пусто | принят / отклонён / отклонён / отклонён / отклонён / отклонён / принят |
|
|
| Слой C при обходе схемы (5 инъекций) | все заблокированы, ничего не записано |
|
|
| Рендер текущих настроек против рабочего `server.conf` | идентичен |
|
|
| После тестов | настройки восстановлены и совпадают с исходными; `rc-status`: все сервисы `started` |
|
|
|
|
## 4. Откат
|
|
|
|
```sh
|
|
cd /opt/OpenVPN-Monitoring-Simple/APP_PROFILER
|
|
cp /root/app-bak/p1/schemas.py schemas.py
|
|
cp /root/app-bak/p1/generator.py services/generator.py
|
|
cp /root/app-bak/p1/server.py routers/server.py
|
|
rm services/validation.py
|
|
rc-service ovpmon-profiler restart
|
|
```
|
|
Либо `git revert 05f44b9` в репозитории.
|
|
|
|
## 5. Оговорки
|
|
- Каталога `/etc/openvpn/scripts/` по умолчанию нет (для теста создавался временно и удалён): перед включением скриптов создать `root:root 755`, файлы `755` от root.
|
|
- Валидаторы действуют на обновления; ранее сохранённые значения проверяются при рендере (слой C).
|
|
- Слой B/C защищает конфиг, но сервис по-прежнему работает от root — это закрывает пункт 2 (см. `IMPLEMENTATION-02-…` после выполнения).
|