From 1da1c178d038b91baa227288de3f329cc40cecde Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sat, 14 Feb 2026 16:08:11 +0100 Subject: [PATCH] Update security.tsx --- AppImage/components/security.tsx | 290 ++++++++++++++++++++++++++----- 1 file changed, 247 insertions(+), 43 deletions(-) diff --git a/AppImage/components/security.tsx b/AppImage/components/security.tsx index f9adb354..e0ae1310 100644 --- a/AppImage/components/security.tsx +++ b/AppImage/components/security.tsx @@ -9,7 +9,8 @@ import { Shield, Lock, User, AlertCircle, CheckCircle, Info, LogOut, Key, Copy, Eye, EyeOff, Trash2, RefreshCw, Clock, ShieldCheck, Globe, FileKey, AlertTriangle, Flame, Bug, Search, Download, Power, PowerOff, Plus, Minus, Activity, Settings, Ban, - FileText, Printer, Play, BarChart3, TriangleAlert, ChevronDown, + FileText, Printer, Play, BarChart3, TriangleAlert, ChevronDown, ArrowDownLeft, ArrowUpRight, + ChevronRight, Network, Zap, } from "lucide-react" import { getApiUrl, fetchApi } from "../lib/api-config" import { TwoFactorSetup } from "./two-factor-setup" @@ -88,6 +89,7 @@ export function Security() { }) const [addingRule, setAddingRule] = useState(false) const [deletingRuleIdx, setDeletingRuleIdx] = useState(null) + const [expandedRuleKey, setExpandedRuleKey] = useState(null) // Security Tools state const [toolsLoading, setToolsLoading] = useState(true) @@ -2341,6 +2343,83 @@ ${(report.sections && report.sections.length > 0) ? ` )} + {/* Rules Summary Dashboard */} + {firewallData.rules.length > 0 && (() => { + const acceptCount = firewallData.rules.filter(r => r.action === "ACCEPT").length + const dropCount = firewallData.rules.filter(r => r.action === "DROP").length + const rejectCount = firewallData.rules.filter(r => r.action === "REJECT").length + const blockCount = dropCount + rejectCount + const total = firewallData.rules.length + const clusterCount = firewallData.rules.filter(r => r.source_file === "cluster").length + const hostCount = firewallData.rules.filter(r => r.source_file === "host").length + const inCount = firewallData.rules.filter(r => (r.direction || "IN") === "IN").length + const outCount = firewallData.rules.filter(r => r.direction === "OUT").length + // Collect unique protected ports + const protectedPorts = new Set() + firewallData.rules.forEach(r => { + if (r.dport) r.dport.split(",").forEach(p => protectedPorts.add(p.trim())) + }) + + return ( +
+

Rules Overview

+
+
+

{total}

+

Total Rules

+
+
+

{acceptCount}

+

Accept

+
+
+

{blockCount}

+

Block / Reject

+
+
+

{protectedPorts.size}

+

Ports Covered

+
+
+ {/* Visual bar */} +
+
+ {acceptCount > 0 && ( +
+ )} + {dropCount > 0 && ( +
+ )} + {rejectCount > 0 && ( +
+ )} +
+
+ Accept + Drop + Reject +
+
+ {/* Scope breakdown */} +
+ + Cluster: {clusterCount} + + + Host: {hostCount} + + | + + IN: {inCount} + + + OUT: {outCount} + +
+
+ ) + })()} + {/* Firewall Rules */}
@@ -2366,6 +2445,42 @@ ${(report.sections && report.sections.length > 0) ? `

New Firewall Rule

+ {/* Service Presets */} +
+

Quick Presets

+
+ {[ + { label: "HTTP", port: "80", proto: "tcp", comment: "HTTP Web" }, + { label: "HTTPS", port: "443", proto: "tcp", comment: "HTTPS Web" }, + { label: "SSH", port: "22", proto: "tcp", comment: "SSH Remote Access" }, + { label: "DNS", port: "53", proto: "udp", comment: "DNS" }, + { label: "SMTP", port: "25", proto: "tcp", comment: "SMTP Mail" }, + { label: "NFS", port: "2049", proto: "tcp", comment: "NFS" }, + { label: "SMB", port: "445", proto: "tcp", comment: "SMB/CIFS" }, + { label: "Ping", port: "", proto: "icmp", comment: "ICMP Ping" }, + ].map((preset) => ( + + ))} +
+
+
@@ -2490,51 +2605,140 @@ ${(report.sections && report.sections.length > 0) ? ` {firewallData.rules.length > 0 ? (
{/* Table header */} -
- Action - Direction - Proto - Port - Source - Level - +
+ + Action + + Proto + Port + Source + Level +
-
- {firewallData.rules.map((rule, idx) => ( -
- - {rule.action || "?"} - - {rule.direction || "IN"} - {rule.p || "-"} - {rule.dport || "-"} - {rule.source || "any"} - - {rule.source_file} - - +
+
)} - -
- ))} +
+ ) + })}
) : (