Commit Graph

5 Commits

Author SHA1 Message Date
980e0076c4 fix(eye-remote): Use Pydantic v1 dict() instead of model_dump() for serialization
- Pydantic v1.10.14 is the installed version which doesn't have model_dump()
- Changed device.model_dump(mode='json') to device.dict()
- All 36 tests now passing successfully
2026-04-23 11:51:38 +02:00
740c20cc29 feat(secubox-eye-remote): Implement boot media core logic with 4R pattern
Adds BootMediaManager for USB Mass Storage LUN image management:

Core Features:
- Thread-safe with RLock for reentrant operations
- 4R double-buffer pattern (active/shadow slots)
- Image validation (FAT32/ext magic, size constraints 16MiB-4GiB)
- SHA256 integrity verification
- Atomic symlink swaps for zero-downtime updates
- TFTP boot file extraction (optional, disabled in test mode)

Functions Implemented:
- validate_image(): Check FAT32/ext magic and size limits
- upload_to_shadow(): Stream upload with hash computation
- swap(): Atomic active↔shadow exchange with LUN detach/reattach
- rollback(): Convenience wrapper for swap operation
- get_state(): Read current state from symlinks and state.json

Technical Details:
- Uses RLock instead of Lock to prevent deadlock (get_state called from swap)
- Subprocess calls for gadget-setup.sh LUN management
- Test mode flag (SECUBOX_TEST_MODE) to skip TFTP extraction
- State persistence in /var/lib/secubox/eye-remote/boot-media/state.json

Tests:
- 18 integration tests covering all operations
- Mock subprocess.run for gadget script calls
- Validates atomic operations and state persistence

Next: Task 5 - FastAPI router endpoints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-23 11:16:30 +02:00
0cbef4f45d feat(secubox-eye-remote): Add device registry with JSON persistence
Implements DeviceRegistry class for managing paired Eye Remote devices:
- CRUD operations (add, get, remove, list)
- Thread-safe access via Lock
- JSON file persistence at /var/lib/secubox/eye-remote/devices.json
- Token validation and last_seen timestamp updates
- Singleton pattern for global access

Includes test suite with 8 passing tests covering all operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 10:56:22 +02:00
85cf748098 feat(secubox-eye-remote): Add token manager with SHA256 hashing
- Generate secure device tokens using secrets.token_hex
- Hash tokens with SHA256 (never store plain tokens)
- Verify tokens with constant-time comparison
- Generate 6-char pairing codes
- Create QR code URLs for pairing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 10:56:09 +02:00
4452f75874 feat(eye-remote): Add SecuBox module skeleton with Pydantic models
Create the SecuBox-side secubox-eye-remote module structure:
- api/main.py: FastAPI application with health check
- models/device.py: Pydantic models for device management
- Directory structure for routers, core, tests, debian, nginx, www

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-21 10:52:46 +02:00