/** * SIEM Dashboard - JavaScript * نظام مراقبة وتحليل السجلات الأمنية */ // ═══════════════════════════════════════════════════════════════ // بيانات تجريبية (في الإنتاج تأتي من API) // ═══════════════════════════════════════════════════════════════ const sampleData = { statistics: { total_lines: 1250, threats_detected: 15, sources_analyzed: 3 }, summary: { total_alerts: 15, critical: 5, high: 6, medium: 4, suspicious_ips_count: 4 }, alerts: [ { id: "a1b2c3d4", timestamp: "2026-07-26T14:05:01", threat_type: "brute_force", description: "محاولات تسجيل دخول فاشلة متكررة", severity: "critical", source_ip: "192.168.1.100", details: { path: "/api/login", attempts: 15 } }, { id: "e5f6g7h8", timestamp: "2026-07-26T14:10:02", threat_type: "sql_injection", description: "محاولة SQL Injection", severity: "critical", source_ip: "10.0.0.50", details: { path: "/api/users?id=1' OR '1'='1" } }, { id: "i9j0k1l2", timestamp: "2026-07-26T14:15:01", threat_type: "xss_attempt", description: "محاولة XSS", severity: "high", source_ip: "172.16.0.25", details: { path: "/page?q=" } }, { id: "m3n4o5p6", timestamp: "2026-07-26T14:15:02", threat_type: "path_traversal", description: "محاولة Path Traversal", severity: "high", source_ip: "172.16.0.25", details: { path: "/../../etc/passwd" } }, { id: "q7r8s9t0", timestamp: "2026-07-26T14:00:05", threat_type: "ssh_brute_force", description: "محاولات SSH فاشلة", severity: "critical", source_ip: "192.168.1.200", details: { attempts: 5, usernames: ["admin", "root", "test"] } }, { id: "u1v2w3x4", timestamp: "2026-07-26T14:10:01", threat_type: "suspicious_user_agent", description: "User-Agent مشبوه", severity: "medium", source_ip: "10.0.0.50", details: { user_agent: "sqlmap/1.5" } } ], suspicious_ips: [ { ip: "192.168.1.100", threat_count: 15, request_count: 120, threats: ["brute_force", "auth_failure"], last_seen: "2026-07-26T14:05:06" }, { ip: "10.0.0.50", threat_count: 8, request_count: 45, threats: ["sql_injection", "suspicious_user_agent"], last_seen: "2026-07-26T14:10:02" }, { ip: "172.16.0.25", threat_count: 5, request_count: 30, threats: ["xss_attempt", "path_traversal"], last_seen: "2026-07-26T14:15:02" }, { ip: "192.168.1.200", threat_count: 5, request_count: 25, threats: ["ssh_brute_force"], last_seen: "2026-07-26T14:00:05" } ], threat_counts: { "SQL Injection": 3, "Brute Force": 5, "XSS": 2, "Path Traversal": 2, "SSH Attacks": 3 }, source_lines: { nginx: 850, auth: 200, app: 200 } }; // ═══════════════════════════════════════════════════════════════ // تحديث الإحصائيات // ═══════════════════════════════════════════════════════════════ function updateStats(data) { document.getElementById('criticalCount').textContent = data.summary.critical; document.getElementById('highCount').textContent = data.summary.high; document.getElementById('mediumCount').textContent = data.summary.medium; document.getElementById('suspiciousIPs').textContent = data.summary.suspicious_ips_count; // تحديث عدد الأسطر لكل مصدر document.getElementById('nginxLines').textContent = data.source_lines.nginx.toLocaleString(); document.getElementById('authLines').textContent = data.source_lines.auth.toLocaleString(); document.getElementById('appLines').textContent = data.source_lines.app.toLocaleString(); } // ═══════════════════════════════════════════════════════════════ // عرض التنبيهات // ═══════════════════════════════════════════════════════════════ function renderAlerts(alerts, filter = 'all') { const container = document.getElementById('alertsList'); container.innerHTML = ''; const filteredAlerts = filter === 'all' ? alerts : alerts.filter(a => a.severity === filter); if (filteredAlerts.length === 0) { container.innerHTML = '
لا توجد تنبيهات
'; return; } filteredAlerts.forEach(alert => { const icon = getAlertIcon(alert.severity); const time = formatTime(alert.timestamp); const alertHtml = `