feat: device security score 0-100 (#88) - #97
Merged
Merged
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
_device_security_score()helper;security_scorefield inDeviceOut; all four device query endpoints now eager-loadDevice.risksScoreBadgecomponent (green ≥70, amber 40–69, red <40)