a2129bb9bd
Pagination contract is not standardized across endpoints
2026-04-28 21:40:22 +02:00
ad21590f60
No canonical snake_case/camelCase serialization policy
2026-04-28 21:27:26 +02:00
4ab767e3d4
TASK-009: Mitigate SSRF vulnerability in blocklist URL validation
...
- Change BlocklistSourceCreate.url from str to AnyHttpUrl (Pydantic type)
- Rejects non-http schemes (file://, ftp://, etc.) at model boundary
- Add is_private_ip() utility to detect RFC 1918 private ranges:
- 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 (RFC 1918)
- 127.0.0.0/8, ::1/128 (loopback)
- 169.254.0.0/16, fe80::/10 (link-local)
- IPv6 site-local, multicast, and reserved ranges
- Add async validate_blocklist_url() function:
- Resolves hostname via DNS using loop.run_in_executor()
- Rejects if hostname resolves to private/reserved IP
- Raises ValueError on validation failure
- Integrate validation into service layer:
- create_source() calls validate_blocklist_url() before persist
- update_source() conditionally validates if url provided
- Both raise ValueError on failure
- Update router endpoints with error handling:
- create_blocklist() and update_blocklist() catch ValueError
- Return HTTP 400 Bad Request with descriptive error message
- Add comprehensive test coverage (9 new SSRF tests):
- file://, ftp://, localhost, 127.0.0.1, 192.168.x.x
- 10.x.x.x, 172.16.x.x, 169.254.x.x (link-local)
- Valid public URLs (passes validation)
- All 36 service tests passing
- Update documentation:
- Features.md: Document URL validation constraints
- Backend-Development.md: Add SSRF prevention pattern section
Fixes SSRF vulnerability where authenticated users could supply
file://, ftp://, or private IP URLs and the backend would fetch them.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com >
2026-04-26 12:57:23 +02:00
207be94c42
Show blocklist import error badge in navigation
...
When the most recent scheduled import completed with errors, surface the
failure in the persistent app shell:
- A warning MessageBar appears at top of main content area
- An amber badge is rendered on the Blocklists sidebar nav item
Backend: add last_run_errors: bool | None to ScheduleInfo model and
populate it in get_schedule_info() from the latest import_log row.
Frontend: extend ScheduleInfo type, add useBlocklistStatus polling hook,
wire both indicators into MainLayout.
Tests: 3 new service tests + 1 new router test (433 total, all pass).
2026-03-07 21:00:00 +01:00
1efa0e973b
Stage 10: external blocklist importer — backend + frontend
...
- blocklist_repo.py: CRUD for blocklist_sources table
- import_log_repo.py: add/list/get-last log entries
- blocklist_service.py: source CRUD, preview, import (download/validate/ban),
import_all, schedule get/set/info
- blocklist_import.py: APScheduler task (hourly/daily/weekly schedule triggers)
- blocklist.py router: 9 endpoints (list/create/update/delete/preview/import/
schedule-get+put/log)
- blocklist.py models: ScheduleFrequency (StrEnum), ScheduleConfig, ScheduleInfo,
ImportSourceResult, ImportRunResult, PreviewResponse
- 59 new tests (18 repo + 19 service + 22 router); 374 total pass
- ruff clean, mypy clean for Stage 10 files
- types/blocklist.ts, api/blocklist.ts, hooks/useBlocklist.ts
- BlocklistsPage.tsx: source management, schedule picker, import log table
- Frontend tsc + ESLint clean
2026-03-01 15:33:24 +01:00
7392c930d6
feat: Stage 1 — backend and frontend scaffolding
...
Backend (tasks 1.1, 1.5–1.8):
- pyproject.toml with FastAPI, Pydantic v2, aiosqlite, APScheduler 3.x,
structlog, bcrypt; ruff + mypy strict configured
- Pydantic Settings (BANGUI_ prefix env vars, fail-fast validation)
- SQLite schema: settings, sessions, blocklist_sources, import_log;
WAL mode + foreign keys; idempotent init_db()
- FastAPI app factory with lifespan (DB, aiohttp session, scheduler),
CORS, unhandled-exception handler, GET /api/health
- Fail2BanClient: async Unix-socket wrapper using run_in_executor,
custom error types, async context manager
- Utility modules: ip_utils, time_utils, constants
- 47 tests; ruff 0 errors; mypy --strict 0 errors
Frontend (tasks 1.2–1.4):
- Vite + React 18 + TypeScript strict; Fluent UI v9; ESLint + Prettier
- Custom brand theme (#0F6CBD, WCAG AA contrast) with light/dark variants
- Typed fetch API client (ApiError, get/post/put/del) + endpoints constants
- tsc --noEmit 0 errors
2026-02-28 21:15:01 +01:00