Skip to content

feat: device security score 0-100 (#88) - #97

Merged
reloadfast merged 3 commits into
mainfrom
feat/risk-scoring-88
Mar 1, 2026
Merged

reloadfast merged 3 commits into
mainfrom
feat/risk-scoring-88

Conversation

@reloadfast

Copy link
Copy Markdown
Owner

Closes #88

What

Adds a computed 0–100 security score to every device, derived from its active risks.

Formula

score = max(0, 100 − (critical×30 + high×15 + medium×7 + low×3))

Trusted devices always score 100. Score is computed on read — no DB column.

Changes

  • Backend: _device_security_score() helper; security_score field in DeviceOut; all four device query endpoints now eager-load Device.risks
  • Frontend: new ScoreBadge component (green ≥70, amber 40–69, red <40)
  • DevicesPage: new sortable Score column
  • DeviceDetailPage: Security Score row in metadata section
  • Dashboard: 5th stat card shows average network score

reloadfast and others added 3 commits March 1, 2026 19:04
- Add _device_security_score() helper in api/__init__.py
  (weighted penalty: critical×30, high×15, medium×7, low×3; min 0)
- Trusted devices always score 100
- Add security_score field to DeviceOut schema
- Load Device.risks via selectinload in all four device endpoints
- Add ScoreBadge component (colour-coded: green ≥70, amber 40-69, red <40)
- Export ScoreBadge from components/index.ts
- DevicesPage: new sortable Score column with ScoreBadge
- DeviceDetailPage: Security Score row in metadata grid
- DashboardPage: Avg Score stat card (5th card, replaces 4-grid with 5-grid)
- Frontend type: add security_score: number to Device interface

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@reloadfast
reloadfast merged commit a19c5e3 into main Mar 1, 2026
7 checks passed
@reloadfast
reloadfast deleted the feat/risk-scoring-88 branch March 1, 2026 18:11
@reloadfast
reloadfast restored the feat/risk-scoring-88 branch March 26, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Risk scoring per device (0-100 security score)

1 participant