ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
redesign(security): overview posture gauge + dense integrity table
Juan Denisb08c7970e3d3
diff --git a/frontend/src/components/security/IntegrityTab.jsx b/frontend/src/components/security/IntegrityTab.jsxindex eff156cd..7ce20fc4 100644--- a/frontend/src/components/security/IntegrityTab.jsx+++ b/frontend/src/components/security/IntegrityTab.jsx@@ -76,74 +76,54 @@ const IntegrityTab = () => {</div></div>- {results && results.total_changes > 0 && (- <div className="card">- <div className="card-header">- <h3>Changes Detected</h3>- <span className="sec-state sec-state--amber">{results.total_changes} changes</span>- </div>- <div className="card-body">- {results.changes.modified?.length > 0 && (- <div className="change-section">- <div className="sec-change-head">- <span className="sec-state sec-state--amber">modified</span>- <span className="sec-change-count">{results.changes.modified.length} files</span>- </div>- <ul className="file-list">- {results.changes.modified.map((file, i) => (- <li key={i}>{file.path}</li>- ))}- </ul>- </div>- )}-- {results.changes.deleted?.length > 0 && (- <div className="change-section">- <div className="sec-change-head">- <span className="sec-state sec-state--red">deleted</span>- <span className="sec-change-count">{results.changes.deleted.length} files</span>- </div>- <ul className="file-list">- {results.changes.deleted.map((file, i) => (- <li key={i}>{file}</li>- ))}- </ul>- </div>- )}-- {results.changes.new?.length > 0 && (- <div className="change-section">- <div className="sec-change-head">- <span className="sec-state sec-state--cyan">added</span>- <span className="sec-change-count">{results.changes.new.length} files</span>- </div>- <ul className="file-list">- {results.changes.new.slice(0, 50).map((file, i) => (- <li key={i}>{file}</li>- ))}- {results.changes.new.length > 50 && (- <li className="text-muted">... and {results.changes.new.length - 50} more</li>- )}- </ul>- </div>- )}+ {results && results.total_changes > 0 && (() => {+ const changes = results.changes || {};+ const NEW_LIMIT = 50;+ const newFiles = changes.new || [];+ const extraNew = Math.max(0, newFiles.length - NEW_LIMIT);+ // Flatten every change kind into dense-table rows (kind chip + mono path).+ const rows = [+ ...(changes.modified || []).map((f) => ({ kind: 'modified', tone: 'amber', path: f.path })),+ ...(changes.deleted || []).map((f) => ({ kind: 'deleted', tone: 'red', path: f })),+ ...newFiles.slice(0, NEW_LIMIT).map((f) => ({ kind: 'new', tone: 'green', path: f })),+ ...(changes.permission_changed || []).map((f) => ({+ kind: 'permission',+ tone: 'cyan',+ path: `${f.path} (${f.old_mode} → ${f.new_mode})`,+ })),+ ];- {results.changes.permission_changed?.length > 0 && (- <div className="change-section">- <div className="sec-change-head">- <span className="sec-state sec-state--violet">permissions</span>- <span className="sec-change-count">{results.changes.permission_changed.length} files</span>- </div>- <ul className="file-list">- {results.changes.permission_changed.map((file, i) => (- <li key={i}>{file.path} ({file.old_mode} → {file.new_mode})</li>- ))}- </ul>- </div>- )}+ return (+ <div className="card sec-flush">+ <div className="card-header">+ <h3>Changes Detected</h3>+ <span className="sec-state sec-state--amber">{results.total_changes} changes</span>+ </div>+ <table className="sk-dtable">+ <thead>+ <tr>+ <th>Change</th>+ <th>Path</th>+ </tr>+ </thead>+ <tbody>+ {rows.map((row, i) => (+ <tr key={i}>+ <td><span className={`sec-state sec-state--${row.tone}`}>{row.kind}</span></td>+ <td className="sk-cell-mono sec-path">{row.path}</td>+ </tr>+ ))}+ {extraNew > 0 && (+ <tr>+ <td><span className="sec-state sec-state--green">new</span></td>+ <td className="sk-cell-mono sec-faint">… and {extraNew} more added</td>+ </tr>+ )}+ </tbody>+ </table></div>- </div>- )}+ );+ })()}</div>);};diff --git a/frontend/src/components/security/OverviewTab.jsx b/frontend/src/components/security/OverviewTab.jsxindex 469413b2..9bc5d5e7 100644--- a/frontend/src/components/security/OverviewTab.jsx+++ b/frontend/src/components/security/OverviewTab.jsx@@ -1,7 +1,7 @@import React, { useState } from 'react';import api from '../../services/api';import { Button } from '@/components/ui/button';-import { Pill } from '@/components/ds';+import { Pill, ScoreGauge } from '@/components/ds';const InstallClamAVButton = ({ onInstalled }) => {const [installing, setInstalling] = useState(false);@@ -34,9 +34,74 @@ const OverviewTab = ({ status, clamavStatus, clamavLoading, onRefreshClamav }) =const alerts = status?.recent_alerts || {};const loading = clamavLoading;const integrityChanges = alerts.integrity_changes || 0;+ const integrity = status?.file_integrity || {};++ // Posture checks — real boolean signals already on this tab's props/state.+ // Checks that can't be evaluated yet (ClamAV still loading) stay 'unknown'+ // and are excluded from the score (client-side, mirrors WordPressDetail).+ const checks = [+ {+ label: 'ClamAV antivirus installed',+ state: clamavLoading ? 'unknown' : (clamavStatus?.installed ? 'pass' : 'warn'),+ detail: clamavLoading ? 'checking…' : (clamavStatus?.installed ? 'installed' : 'not installed'),+ },+ {+ label: 'ClamAV service running',+ state: clamavLoading || !clamavStatus?.installed ? 'unknown' : (clamavStatus?.service_running ? 'pass' : 'warn'),+ detail: clamavLoading ? 'checking…' : (!clamavStatus?.installed ? 'n/a' : (clamavStatus?.service_running ? 'running' : 'stopped')),+ },+ {+ label: 'File integrity monitoring enabled',+ state: integrity.enabled ? 'pass' : 'warn',+ detail: integrity.enabled ? 'enabled' : 'disabled',+ },+ {+ label: 'Integrity baseline initialized',+ state: integrity.database_exists ? 'pass' : 'warn',+ detail: integrity.database_exists ? 'initialized' : 'not initialized',+ },+ {+ label: 'No integrity changes (24h)',+ state: integrityChanges > 0 ? 'warn' : 'pass',+ detail: integrityChanges > 0 ? `${integrityChanges} detected` : 'clean',+ },+ {+ label: 'Security alerts configured',+ state: status?.notifications_enabled ? 'pass' : 'warn',+ detail: status?.notifications_enabled ? 'enabled' : 'disabled',+ },+ ];+ const scored = checks.filter((c) => c.state !== 'unknown');+ const score = scored.length+ ? Math.round((scored.filter((c) => c.state === 'pass').length / scored.length) * 100)+ : null;+ const scoreColor = score >= 80 ? 'var(--green)' : score >= 50 ? 'var(--amber)' : 'var(--red)';+ const CHECK_PILL = { pass: 'green', warn: 'amber', unknown: 'gray' };return (<div className="security-overview">+ <div className="card">+ <div className="card-header">+ <h3>Security Posture</h3>+ </div>+ <div className="card-body sec-posture">+ {score !== null ? (+ <ScoreGauge value={score} size={110} stroke={9} color={scoreColor} label="posture" />+ ) : (+ <p className="sec-hint sec-hint--lead">Refresh the checks below to compute a posture score.</p>+ )}+ <div className="sec-posture__checks">+ {checks.map((c) => (+ <div key={c.label} className="sec-posture__check">+ <span className="sec-posture__label">{c.label}</span>+ <span className="sec-posture__detail">{c.detail}</span>+ <Pill kind={CHECK_PILL[c.state]}>{c.state === 'unknown' ? 'pending' : c.state}</Pill>+ </div>+ ))}+ </div>+ </div>+ </div>+<div className="security-grid"><div className="card"><div className="card-header">diff --git a/frontend/src/styles/pages/_security.scss b/frontend/src/styles/pages/_security.scssindex b052eed3..e5b9b916 100644--- a/frontend/src/styles/pages/_security.scss+++ b/frontend/src/styles/pages/_security.scss@@ -282,11 +282,58 @@// ── Overview tab ─────────────────────────────────────────────.security-overview {+ display: flex;+ flex-direction: column;+ gap: $space-4;+.security-grid {display: grid;grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));gap: $space-4;}++ // Posture ring + hardening checklist (ScoreGauge beside check rows)+ .sec-posture {+ display: flex;+ align-items: center;+ gap: $space-6;++ &__checks {+ flex: 1;+ min-width: 0;+ }++ &__check {+ display: flex;+ align-items: center;+ gap: $space-3;+ padding: 10px 0;+ border-top: 1px solid var(--border-soft);+ font-size: 13px;++ &:first-child { border-top: none; }+ }++ &__label {+ flex: 1;+ min-width: 0;+ color: var(--text);+ }++ &__detail {+ font-family: var(--mono);+ font-size: 11.5px;+ color: var(--text-faint);+ white-space: nowrap;+ }++ @media (max-width: $breakpoint-md) {+ flex-direction: column;+ align-items: flex-start;++ &__checks { width: 100%; }+ }+ }}// ── Scanner tab ──────────────────────────────────────────────@@ -418,47 +465,8 @@gap: $space-3;}- .change-section {- margin-bottom: $space-5;-- &:last-child { margin-bottom: 0; }- }-- .sec-change-head {- display: flex;- align-items: center;- gap: 10px;- margin-bottom: $space-2;- }-- .sec-change-count {- font-family: var(--mono);- font-size: 11px;- color: var(--text-faint);- }-- .file-list {- list-style: none;- padding: 0;- margin: 0;- max-height: 300px;- overflow-y: auto;- background: var(--bg-code);- border: 1px solid var(--border-soft);- border-radius: var(--radius-sm);-- li {- padding: 7px 12px;- font-family: var(--mono);- font-size: 11.5px;- color: var(--text-dim);- border-bottom: 1px solid var(--border-soft);-- &:last-child {- border-bottom: none;- }- }- }+ // Change-kind chip column reads as a tag, not a full state wash+ .sk-dtable .sec-state { text-transform: lowercase; }}// ── Events tab ───────────────────────────────────────────────