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"; import { useSettingsStore } from "@/stores/settingsStore"; 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 { pii_enabled_patterns, setPiiPattern } = useSettingsStore(); const [auditEntries, setAuditEntries] = useState([]); const [expandedRows, setExpandedRows] = useState>(new Set()); 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 toggleRow = (entryId: string) => { setExpandedRows((prev) => { const newSet = new Set(prev); if (newSet.has(entryId)) { newSet.delete(entryId); } else { newSet.add(entryId); } return newSet; }); }; 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) => { const isExpanded = expandedRows.has(entry.id); return ( {isExpanded && ( )} ); })}
Event Type Destination Status Date Details
{entry.action} {entry.entity_id} {entry.action} {new Date(entry.timestamp).toLocaleString()}

Transmitted Data:

                                  {JSON.stringify(JSON.parse(entry.details), null, 2)}
                                
Entry ID: {entry.id} Type: {entry.entity_type}
)}
); }