import { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { Lock, ArrowLeft, CheckCircle2, XCircle, AlertTriangle, Shield, Key, Eye, EyeOff, TrendingUp, Clock } from 'lucide-react'; interface SecretViolation { id: string; type: string; timestamp: string; severity: 'low' | 'medium' | 'high' | 'critical'; original: string; redacted: string; } export function SecretsGuard() { const navigate = useNavigate(); const [status] = useState<'active' | 'inactive'>('active'); const [violations, setViolations] = useState([]); const [loading, setLoading] = useState(true); const [stats, setStats] = useState({ total: 0, critical: 0, high: 0, medium: 0, low: 0 }); useEffect(() => { const mock: SecretViolation[] = [ { id: '1', type: 'api_key', timestamp: new Date().toISOString(), severity: 'high', original: 'api_key=sk_live_***', redacted: 'api_key=***REDACTED***' }, { id: '2', type: 'aws_key', timestamp: new Date(Date.now() - 3600000).toISOString(), severity: 'critical', original: 'AWS_ACCESS_KEY_ID=AKIA***', redacted: 'AWS_ACCESS_KEY_ID=***REDACTED***' }, { id: '3', type: 'password', timestamp: new Date(Date.now() - 7200000).toISOString(), severity: 'high', original: 'password=***', redacted: 'password=***REDACTED***' }, ]; const t = setTimeout(() => { setViolations(mock); setStats({ total: mock.length, critical: mock.filter((v) => v.severity === 'critical').length, high: mock.filter((v) => v.severity === 'high').length, medium: mock.filter((v) => v.severity === 'medium').length, low: mock.filter((v) => v.severity === 'low').length, }); setLoading(false); }, 500); return () => clearTimeout(t); }, []); const getSeverityConfig = (severity: string) => { const map: Record = { critical: { label: 'Критично', bg: 'bg-red-50 dark:bg-red-900/20', text: 'text-red-700 dark:text-red-400', border: 'border-red-200', icon: AlertTriangle }, high: { label: 'Высокий', bg: 'bg-orange-50 dark:bg-orange-900/20', text: 'text-orange-700 dark:text-orange-400', border: 'border-orange-200', icon: AlertTriangle }, medium: { label: 'Средний', bg: 'bg-yellow-50 dark:bg-yellow-900/20', text: 'text-yellow-700 dark:text-yellow-400', border: 'border-yellow-200', icon: Shield }, low: { label: 'Низкий', bg: 'bg-blue-50 dark:bg-blue-900/20', text: 'text-blue-700 dark:text-blue-400', border: 'border-blue-200', icon: Shield }, }; return map[severity] || map.low; }; const statCards = [ { label: 'Всего обнаружено', value: stats.total, icon: TrendingUp, color: 'from-emerald-500/10 to-emerald-600/5 text-emerald-700' }, { label: 'Критичных', value: stats.critical, icon: AlertTriangle, color: 'from-red-500/10 to-red-600/5 text-red-700' }, { label: 'Высокий уровень', value: stats.high, icon: AlertTriangle, color: 'from-orange-500/10 to-orange-600/5 text-orange-700' }, { label: 'Средний уровень', value: stats.medium, icon: Shield, color: 'from-yellow-500/10 to-yellow-600/5 text-yellow-700' }, { label: 'Низкий уровень', value: stats.low, icon: Shield, color: 'from-blue-500/10 to-blue-600/5 text-blue-700' }, ]; if (loading) { return (
{[1, 2, 3, 4, 5].map((i) =>
)}
); } return (

Защита секретов

Мониторинг и защита от утечек конфиденциальных данных

{status === 'active' ? : }

Статус мониторинга

{status === 'active' ? 'Мониторинг активен' : 'Мониторинг неактивен'}

{status === 'active' ? <>Активен : <>Неактивен}
{statCards.map((stat, i) => { const Icon = stat.icon; return (
{stat.value}
{stat.label}
); })}

Примеры редактирования

{violations.map((v) => { const cfg = getSeverityConfig(v.severity); const SeverityIcon = cfg.icon; return (
{v.type.replace('_', ' ')}
{cfg.label}
{new Date(v.timestamp).toLocaleString('ru-RU')}
Оригинал
{v.original}
После редактирования
{v.redacted}
); })}
); }