Commit Graph
6 Commits
Author SHA1 Message Date
maziggy 839be41133 Fix support bundle leaking personal data (#473)
The log sanitizer only used regex patterns, missing arbitrary user-chosen
strings (printer names, usernames). Tasmota smart plug credentials were
logged verbatim in URLs by httpx.

- Make _sanitize_log_content() database-aware: query Printer names/serials,
  User usernames, and Bambu Cloud email for exact-string replacement
  (longest-first, skip <3 chars to prevent over-redaction)
- Fix serial regex leaking first 3 chars (remove capture group partial
  redaction), add case-insensitive flag
- Move Tasmota credentials from URL-embedded (http://user:pass@host) to
  httpx auth= parameter so they never appear in logs
- Add URL credentials regex as defense-in-depth for user:pass@ in logs
- Add 'username' and 'path' to settings sensitive_keys filter (catches
  smtp_username, slicer_binary_path in support-info.json)
2026-02-21 08:17:59 +01:00
maziggy 24f509d604 Add frontend pre-commit hooks for TypeScript and ESLint (#458)
Add frontend-typecheck (tsc --noEmit) and frontend-lint (eslint .)
hooks to .pre-commit-config.yaml. Both hooks only trigger when
frontend/src/**/*.{ts,tsx} files are staged.
2026-02-20 09:34:55 +01:00
maziggy 5672d7965a Add recalculate costs button and reprint cost tracking
- Add "Recalculate Costs" button to Dashboard that updates all archive
  costs using current filament prices (Issue #120)
- Track reprints and add cost to existing archive total on completion,
  so statistics accurately reflect total filament expenditure

Closes #120
2026-01-24 07:05:15 +01:00
maziggyandClaude Opus 4.5 db0fc0f19b Fix backend code formatting for CI
- Update ruff pre-commit hook to v0.14.11
- Apply ruff format to pass CI checks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:29:26 +01:00
maziggy 929c4c8cd6 - Fix total print hours calculation in set_total_hours to include all
prints (not just completed), matching get_printer_total_hours behavior
  - Add option to keep or delete archives when deleting a printer
  - Custom maintenance types no longer auto-assign to all printers
  - Add UI to manually assign/remove custom maintenance types per printer
  - Add backend endpoints for assigning types to printers and removing items
  - Exclude static/assets from large file pre-commit check
2025-12-23 09:00:36 +01:00
maziggy c317ff1085 1. Pre-commit Hook Configuration (.pre-commit-config.yaml)
- Ruff linter and formatter - Fast Python linter with auto-fix
  - Standard hooks - trailing whitespace, end-of-file, YAML/JSON checks, large file detection, merge conflict detection, debug statements, private key detection
  - Custom hook - Runs import shadowing tests before commit

  2. Ruff Configuration (pyproject.toml)

  - Python 3.11+ target
  - 120 character line length
  - Checks: pycodestyle, Pyflakes, isort, flake8-bugbear, comprehensions, pyupgrade, unused arguments, simplify
  - Sensible ignores for FastAPI patterns (Depends, unused route args)

  3. New Test Files

  backend/tests/unit/test_code_quality.py (5 tests)
  - Import shadowing detection using AST analysis
  - Catches the exact bug that broke archive creation
  - Tests all Python files in main, services, and routes

  backend/tests/unit/test_log_error_detection.py (13 tests)
  - MQTT message processing (status, xcam, AMS, HMS)
  - Print lifecycle (start to complete, failure handling)
  - Service imports verification
  - Edge cases (empty messages, unknown fields, null values)

  backend/tests/integration/test_print_lifecycle.py (6 tests)
  - Print start callback logic
  - Print complete callback logic
  - Timelapse tracking (same-message detection, completion callback)
  - Callback error handling
  - Import shadowing verification
2025-12-13 09:57:04 +01:00