Commit Graph

13 Commits

Author SHA1 Message Date
CyberMind
82b0522c5b
Aggregator résilience: sweep async (243 handlers) + threadpool 80 (#738) (#739)
* perf(aggregator): async-sweep — 243 blocking route handlers async def→def (#738)

Mounted in the aggregator's single event loop, an 'async def' route handler
that runs blocking code (subprocess/journalctl/openssl/argon2) freezes the
WHOLE loop -> aggregator.sock Connection refused -> 502 board-wide.

Deterministic AST codemod (scripts/async-sweep.py) converts route handlers
that (a) are decorated with an HTTP verb, (b) contain a known blocking call,
(c) have NO await/async-with/async-for/yield, (d) are never used as a
coroutine elsewhere -> plain 'def'. Starlette then runs them in the AnyIO
threadpool, so the blocking call no longer stalls the gateway. await/stream/
websocket handlers are left untouched. Every file py_compile-checked.

243 handlers across 56 modules (system 17, qos 13, netdiag/hexo 12, hub 11...).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* perf(aggregator): raise AnyIO threadpool to 80 tokens (#738)

The async-sweep moves ~243 blocking handlers to the threadpool. With ~110
modules in one process, the default 40-token pool can queue head-of-line under
concurrent blocking load. Raise to 80 on startup (best-effort, never breaks
boot).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* perf(hub): double-buffer status cache + emojized health page (#738)

Navbar status (menu + health-batch) is now a strict double-buffer cache:
- request handlers NEVER compute on the request path — they return the current
  snapshot instantly (or a 'warming' placeholder), so the sidebar's polling can
  no longer serialize behind a ~3s systemctl walk and starve the loop;
- the background refresher is kicked from the request path (_ensure_bg) because
  mounted sub-apps receive neither startup nor @app.middleware events under the
  aggregator — the previous lazy-start middleware never fired there;
- snapshots are built complete then swapped atomically, so the dashboard never
  shows partial/bad counts.

Served by the dedicated secubox-hub process (:8001, isolated loop) the navbar
stays <50ms and holds 200 under 25+ concurrent polls where the aggregator-
mounted copy wedged (000). health.js: 🟢🟡🔴 emoji status indicators.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* style(hub): render health status emoji cleanly (neutralize .led dot) (#738)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* perf(sidebar): kill per-module health storm, use batch endpoint (#738)

The navbar refreshed LEDs by firing ONE /api/v1/<module>/health request per
module — ~119 requests every 30s, in batches of 8 — straight at the aggregator's
single shared event loop. Combined with the in-process module mount this is a
prime driver of the recurring board-wide 502 wedge (user-identified).

checkAllHealth + refreshStaleHealth now call /api/v1/hub/public/health-batch
ONCE (served by the dedicated, double-buffered hub process) and populate every
module's LED from that single response. 119 reqs/cycle -> 1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 08:06:15 +02:00
CyberMind
7c37415f88
feat(remote-ui): Phase 1 — extract common/ shared core (ref #127)
* feat(remote-ui/common): scaffold shared-core directory (ref #127)

* feat(remote-ui/common): extract palette.css from round/ (ref #127)

* fix(remote-ui/common): trim palette.css to spec (6 module + 8 C3BOX tokens) (ref #127)

* feat(remote-ui/common): extract base.css verbatim from round/ (ref #127)

* feat(remote-ui/common): extract ICONS to icons.js (ref #127)

* docs(remote-ui/common): correct icons.js header comment — sizes are {22,48,96} not 128 (ref #127)

* feat(remote-ui/common): extract RINGS + CX/CY/SA to modules-table.js (ref #127)

* feat(remote-ui/common): extract CFG to config.js (replaces jwt-helper.js per #127 plan revision)

* feat(remote-ui/common): extract TransportManager with onModuleTap/onTransportChange hooks (ref #127)

* feat(remote-ui/common): extract SIM + simStep to sim.js (ref #127)

* feat(remote-ui/common): move 24 SecuBox module PNG icons to common/assets/icons/ (ref #127)

* feat(remote-ui/common): move secubox-otg-gadget.sh, add GADGET_NAME env override + arm64 serial fallback (ref #127)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(remote-ui/common): trim whitespace from device-tree serial-number read (ref #127)

* feat(remote-ui/common): move secubox-otg-host-up.sh + variant-aware comment (ref #127)

* refactor(remote-ui/round): consume common/ via <link>/<script> tags (ref #127)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(secubox-system): add form_factor to RemoteUIConnectedRequest with TDD (ref #127)

* feat(remote-ui/round): deploy.sh bundles common/ alongside round/ (ref #127)

* fix(remote-ui/round): deploy.sh COMMON_SRC path resolution + rsync --delete (ref #127)

* feat(remote-ui/round): build-eye-remote-image.sh embeds common/ + nginx /common/ alias (ref #127)

* docs(remote-ui): document common/ dependency in round/ docs (ref #127)

* docs(remote-ui/round): clarify palette.css is forward-looking (ref #127)

* docs(remote-ui): Task 18 regression-gate report — structural verification (ref #127)

Full diffoscope gate blocked by missing hyperpixel2r.dtbo prerequisite.
Structural equivalence verified instead: Phase 1 changes are purely
additive (common/ embed + nginx /common/ alias + extracted JS/CSS/icons),
no behavioural change to round/'s existing logic.

User must run the full image diffoscope manually after sourcing the
hyperpixel2r.dtbo blob, before final merge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* ci(eye-remote): bump workflow VERSION env 2.2.0 → 2.2.1 (ref #127)

Pre-existing drift: build-eye-remote-image.sh writes
secubox-eye-remote-2.2.1.img but the workflow's Compress/Checksum/
Upload steps reference ${{ env.VERSION }} = 2.2.0, so the compress
step fails with "No such file or directory" after a successful build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: CyberMind-FR <gandalf@Gk2.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 05:59:40 +02:00
e2989322f4 feat(api): Add /health endpoint to 53 modules
Auto-generated health check endpoints for sidebar status:
- Returns {status: "ok", module: "name"}
- Public endpoint (no auth required)
- Used by sidebar.js for LED status display

Added via scripts/add-health-endpoints.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-09 10:40:05 +02:00
9b48d6fa75 feat(system): Add WebUI sessions management
- GET /sessions - list active sessions with expiry info
- GET /sessions/summary - public endpoint for dashboard
- DELETE /sessions/{id} - revoke specific session (admin)
- POST /sessions/revoke-all - revoke all sessions (sysadmin)

Reads from /var/lib/secubox/auth/sessions.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-09 06:38:18 +02:00
0ca39ee4a9 fix(system): Hardcode firewall as Active (nftables always loaded)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-08 23:16:27 +02:00
919d030a58 feat(ui): Add dice icons, scribe trace, and LED pulse improvements
- Sidebar: Replace LED dots with dice icons (⚀-⚅) based on metric values
- Sidebar: Dice update dynamically with CPU/mem/disk/load/temp/net
- SOC: Add scribe trace histogram for firewall packet stats
- SOC: Remove category tag listings (keep donut metrics)
- SOC: Fix API paths for hub endpoints
- WAF: Fix JavaScript syntax errors (orphan returns, extra braces)
- WAF: Fix getSiteEmoji function structure
- HealthBump: Update LED pulse patterns (1/2/4 flashes per tier)
- HealthBump: Pulse from bright to dim (not dark to color)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-08 22:33:23 +02:00
8e909d8c65 feat(modules): Complete stub implementations and security fixes
Security:
- voip: Implement PBKDF2-SHA256 password hashing (100k iterations)
- eye-remote: Proper JWT auth import from secubox_core

Features:
- dns-provider: Full OVH and Route53 adapter implementations
- ai-gateway: Auto-persist provider configuration on update
- threat-analyst: Add WAF rule generation in JSON format
- mirror: Add docker, npm, and pypi registry sync support

Performance:
- system: Add batch systemctl calls and cache (275ms → 30ms)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-30 15:33:28 +02:00
34244534f8 fix(system,portal): Add /metrics endpoint + Pydantic v1 compatibility
secubox-system:
- Add /metrics endpoint for Eye Remote dashboard
- Returns cpu_percent, mem_percent, disk_percent, load_avg_1,
  cpu_temp, uptime_seconds, hostname, memory_used, memory_total
- Uses 0.1s CPU sampling for responsive display updates

secubox-portal:
- Fix Pydantic v1 compatibility (field_validator → validator)
- Fixes ImportError on systems with Pydantic 1.x

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-29 21:39:43 +02:00
aa47157a00 feat(system): Add public /metrics endpoint for Eye Remote Dashboard
- GET /api/v1/system/metrics returns all metrics without JWT
- CPU, MEM, DISK, LOAD, TEMP, WIFI for 6 module rings
- Extended metrics: uptime, network I/O, connections, processes
- Compatible with Eye Remote HyperPixel 2.1 Round display

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-28 15:43:29 +02:00
76cd7c0d96 feat(remote-ui): Add HyperPixel 2.1 Round dashboard for RPi Zero W
Complete Remote UI implementation for SecuBox status display:

- Python/PIL dashboard with direct framebuffer rendering (no Chromium)
- KMS overlay support (vc4-kms-dpi-hyperpixel2r) - tested working
- USB OTG composite gadget (CDC-ECM + CDC-ACM) for host connection
- 6 concentric rings showing CPU, MEM, DISK, LOAD, TEMP, WiFi metrics
- Auto-start systemd service (secubox-dashboard.service)
- install_zerow.sh for SD card preparation with all fixes

Key fixes discovered during debugging:
- Use KMS overlay, not non-KMS (GPIO conflicts on Bookworm)
- Framebuffer is RGB565 (16-bit), not BGRA
- RPi OS Bookworm requires userconf file for SSH credentials
- NetworkManager ignores ifupdown; use direct IP config

Files:
- secubox_dashboard.py: PIL-based live metrics dashboard
- install_zerow.sh: SD card flasher with KMS overlay
- secubox-dashboard.service: Auto-start systemd unit
- 24 module icons (AUTH/WALL/BOOT/MIND/ROOT/MESH)

Tested on: RPi Zero W + HyperPixel 2.1 Round 480x480

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-15 17:54:09 +02:00
d3e9352722 feat(core): Add board detection and kiosk management library
- secubox_core v1.1.0: New kiosk.py module with reusable functions
  - Board detection (MOCHAbin, ESPRESSObin, x64-vm, x64-baremetal, RPi)
  - Interface classification (WAN/LAN/SFP by board type)
  - Kiosk management (status, enable, disable)
- secubox-system v1.2.0: Board Detection and Kiosk cards in UI
  - Uses secubox_core.kiosk (no code duplication)
  - New endpoints: /board, /board/detect, /board/capabilities, /kiosk/*
- secubox-hub v1.1.0: Network Mode selection on dashboard
  - Mode selector with preview and apply
  - Proxies to secubox-netmodes via Unix socket
  - New endpoints: /network_mode, /network_mode/preview, /board_summary
- secubox-portal v2.1.0: Device-specific theming
  - 7 board themes (Pro, Lite, Virtual, Server, Maker, Standard)
  - Login page dynamically adapts colors and badge
  - New endpoints: /theme, /branding

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-01 05:52:19 +02:00
6a41f9d508 Add 4 new modules and RBAC system
New modules from secubox-openwrt:
- secubox-zkp: Zero-Knowledge Proof Hamiltonian Dashboard
- secubox-mesh: Meshname DNS for Yggdrasil mesh networks
- secubox-p2p: Peer-to-Peer Network Hub with threat intelligence

New module extracted from hub:
- secubox-roadmap: Migration Roadmap (public read-only API)

RBAC enhancements:
- secubox-users v1.2.0: Add role-based access control with 35+ permissions
  - Default roles: admin, operator, user, guest
  - Role management, assignment, and ACL endpoints
- secubox-system v1.1.0: Add system preferences with ACL
  - System roles: sysadmin, admin, operator, user, guest
  - Sysadmin can manage roles and shutdown
  - Admin can edit settings but not shutdown/roles
  - Action ACL for granular permission control

Removed roadmap widget from secubox-hub dashboard.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-24 09:39:15 +01:00
bf1babb37c Initial commit: SecuBox-DEB migration from OpenWrt to Debian
Includes all package APIs with public dashboard endpoints:
- secubox-system: System Hub with /info, /resources, /security
- secubox-crowdsec: CrowdSec dashboard with /status, /hub, /metrics, actions
- secubox-wireguard: WireGuard VPN with /interfaces, /peers, start/stop
- secubox-netdata: Monitoring with /stats, /processes, /alerts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-21 09:41:06 +01:00