import React, { useEffect, useState } from "react"; import { Shield, RefreshCw } from "lucide-react"; import { Card, CardHeader, CardTitle, CardContent, Badge, Separator, } from "@/components/ui"; import { getAuditLogCmd, type AuditEntry } from "@/lib/tauriCommands"; const piiPatterns = [ { id: "email", label: "Email Addresses", description: "Detect email addresses in logs" }, { id: "ip_address", label: "IP Addresses", description: "Detect IPv4 and IPv6 addresses" }, { id: "phone", label: "Phone Numbers", description: "Detect phone numbers in various formats" }, { id: "ssn", label: "Social Security Numbers", description: "Detect US SSN patterns" }, { id: "credit_card", label: "Credit Card Numbers", description: "Detect credit card number patterns" }, { id: "hostname", label: "Hostnames", description: "Detect internal hostnames and FQDNs" }, { id: "password", label: "Passwords in Logs", description: "Detect password= and secret= patterns" }, { id: "api_key", label: "API Keys", description: "Detect common API key patterns" }, ]; export default function Security() { const [enabledPatterns, setEnabledPatterns] = useState>(() => Object.fromEntries(piiPatterns.map((p) => [p.id, true])) ); const [auditEntries, setAuditEntries] = useState([]); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { loadAuditLog(); }, []); const loadAuditLog = async () => { setIsLoading(true); try { const entries = await getAuditLogCmd({ limit: 50 }); setAuditEntries(entries); } catch (err) { setError(String(err)); } finally { setIsLoading(false); } }; const togglePattern = (id: string) => { setEnabledPatterns((prev) => ({ ...prev, [id]: !prev[id] })); }; return (

Security

Configure PII detection patterns and review the audit log.

{/* PII Patterns */} PII Detection Patterns {piiPatterns.map((pattern) => (

{pattern.label}

{pattern.description}

))}
{/* Audit Log */}
Audit Log
{error && (
{error}
)} {auditEntries.length === 0 ? (

No audit entries yet.

) : (
{auditEntries.map((entry) => ( ))}
Event Type Destination Status Date
{entry.action} {entry.entity_id} {entry.action} {new Date(entry.timestamp).toLocaleString()}
)}
); }