larxius commited on
Commit
454f74b
·
verified ·
1 Parent(s): d705002

Update frontend/src/pages/LogsAndThreats.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/pages/LogsAndThreats.jsx +182 -223
frontend/src/pages/LogsAndThreats.jsx CHANGED
@@ -1,7 +1,10 @@
1
  import React, { useState, useEffect } from 'react';
2
  import { Link } from 'react-router-dom';
3
  import { useAuth } from '../components/AuthContext';
4
- import { ShieldAlert, Search, Download, RefreshCw, List, ArrowLeft, Filter, Info, X, ExternalLink, Shield, AlertTriangle, CheckCircle } from 'lucide-react';
 
 
 
5
 
6
  const THREAT_KNOWLEDGE_BASE = {
7
  "Missing Security Header: Cross-Origin-Embedder-Policy": {
@@ -12,7 +15,7 @@ const THREAT_KNOWLEDGE_BASE = {
12
  cwe: ["CWE-693"],
13
  description: "The Cross-Origin-Embedder-Policy (COEP) HTTP response header prevents a document from loading any cross-origin resources that do not explicitly grant the document permission (using CORP or CORS).",
14
  impact: "Without COEP, cross-origin resources can be loaded without explicit consent, increasing susceptibility to Spectre-style side-channel attacks and unauthorized data leakage.",
15
- remediation: "Add the Cross-Origin-Embedder-Policy header to HTTP responses:\n\nCross-Origin-Embedder-Policy: require-corp;\n\nAlternatively, use 'credentialless' mode for legacy asset compatibility.",
16
  affected_targets: ["https://app.larshield.io", "https://api.larshield.io/v1", "https://portal.larshield.com"]
17
  },
18
  "Missing Security Header: Expect-CT": {
@@ -23,7 +26,7 @@ const THREAT_KNOWLEDGE_BASE = {
23
  cwe: ["CWE-295"],
24
  description: "The Expect-CT header allows sites to report and/or enforce Certificate Transparency requirements, preventing misissued SSL/TLS certificates.",
25
  impact: "Lack of CT enforcement leaves client browsers unable to verify whether an SSL certificate was legitimately logged in public CT logs.",
26
- remediation: "Configure HTTP response header:\n\nExpect-CT: max-age=86400, enforce, report-uri=\"https://your-domain.com/ct-report\"",
27
  affected_targets: ["https://auth.larshield.io", "https://admin.larshield.com"]
28
  },
29
  "Known TLS/Crypto CVEs: CVE-2023-44487": {
@@ -34,7 +37,7 @@ const THREAT_KNOWLEDGE_BASE = {
34
  cwe: ["CWE-400"],
35
  description: "CVE-2023-44487 refers to the HTTP/2 Rapid Reset Denial of Service attack. Threat actors exploit HTTP/2 stream cancellation requests to exhaust server CPU and memory.",
36
  impact: "Unpatched web servers accepting HTTP/2 connections can be easily overwhelmed by rapid stream creation and immediate resets, causing server outages and complete denial of service.",
37
- remediation: "1. Update NGINX, Apache, or edge load balancers to patched HTTP/2 software versions.\n2. Limit concurrent streams and set rate limits on RST_STREAM frames.\n3. Example NGINX fix:\n\nkeepalive_requests 1000;\nhttp2_max_concurrent_streams 128;",
38
  affected_targets: ["https://lb-primary.larshield.internal", "https://gateway.larshield.io"]
39
  },
40
  "DNSSEC Not Implemented": {
@@ -45,7 +48,7 @@ const THREAT_KNOWLEDGE_BASE = {
45
  cwe: ["CWE-350"],
46
  description: "Domain Name System Security Extensions (DNSSEC) adds cryptographic signatures to DNS records to verify domain data authenticity.",
47
  impact: "Without DNSSEC, clients are vulnerable to DNS spoofing and cache poisoning attacks, allowing threat actors to hijack domain traffic and impersonate application services.",
48
- remediation: "1. Enable DNSSEC signing at your domain registrar (e.g. Cloudflare, Route53, GoDaddy).\n2. Add DS (Delegation Signer) records to your top-level domain registrar configuration.",
49
  affected_targets: ["larshield.io", "larshield.com"]
50
  },
51
  "Server Information Disclosure via 'server' Header": {
@@ -56,7 +59,7 @@ const THREAT_KNOWLEDGE_BASE = {
56
  cwe: ["CWE-200"],
57
  description: "The HTTP 'Server' response header exposes detailed web server software, exact version numbers, and underlying operating system details to anonymous clients.",
58
  impact: "Attackers use disclosed server software and version numbers to target known CVE vulnerabilities and refine automated exploit scripts.",
59
- remediation: "Hide or obscure the server header in your web server configuration:\n\n# NGINX:\nserver_tokens off;\n\n# Apache:\nServerTokens Prod\nServerSignature Off",
60
  affected_targets: ["https://web-node-01.larshield.internal", "https://static.larshield.io"]
61
  }
62
  };
@@ -69,6 +72,7 @@ const LogsAndThreats = () => {
69
 
70
  // Selected Threat Detail Modal State
71
  const [selectedThreat, setSelectedThreat] = useState(null);
 
72
 
73
  // Full Page Threat Intelligence View State
74
  const [isFullThreatsView, setIsFullThreatsView] = useState(false);
@@ -178,6 +182,12 @@ const LogsAndThreats = () => {
178
  setThreatSeverityFilter('all');
179
  };
180
 
 
 
 
 
 
 
181
  const getThreatDetail = (t) => {
182
  if (!t) return null;
183
  const titleKey = typeof t === 'string' ? t : (t.title || '');
@@ -186,29 +196,35 @@ const LogsAndThreats = () => {
186
  title: titleKey,
187
  count: t.count || 1,
188
  severity: t.severity || kb.severity || 'Medium',
189
- category: t.category || kb.category || 'Security Audit',
190
- cvss: t.cvss_score || kb.cvss || 5.0,
191
  owasp: t.owasp_category || kb.owasp || 'A05:2021 - Security Misconfiguration',
192
  cwe: t.cwe_ids && t.cwe_ids.length ? t.cwe_ids : (kb.cwe || ['CWE-693']),
193
  description: t.description && t.description.length > 30 ? t.description : (kb.description || `Security intelligence scan detected "${titleKey}" across active system endpoints.`),
194
  impact: t.impact || kb.impact || 'Unpatched or missing security settings increase risk of exploitation, unauthorized data access, or service disruption.',
195
- remediation: t.remediation && t.remediation.length > 20 ? t.remediation : (kb.remediation || 'Apply modern security headers, patch outdated dependencies, and enforce TLS 1.3 protocol standards.'),
196
- affected_targets: t.affected_targets && t.affected_targets.length ? t.affected_targets : (kb.affected_targets || ['https://scanned-target.larshield.io'])
197
  };
198
  };
199
 
200
  // Helper for Severity Badges
201
  const getSeverityBadgeClass = (sev) => {
202
  const s = (sev || '').toLowerCase();
203
- if (s === 'critical') return 'bg-red-500/10 text-red-500 border-red-500/30';
204
- if (s === 'high') return 'bg-orange-500/10 text-orange-500 border-orange-500/30';
205
- if (s === 'medium') return 'bg-amber-500/10 text-amber-500 border-amber-500/30';
206
- return 'bg-blue-500/10 text-blue-500 border-blue-500/30';
207
  };
208
 
209
  // Threat Details Calculations
210
  const allThreatDetails = trends.map(t => getThreatDetail(t)).filter(Boolean);
211
 
 
 
 
 
 
 
212
  // In-Card Threats Pagination Calculations (Dashboard Overview)
213
  const totalThreatCount = allThreatDetails.length;
214
  const totalThreatCardPages = Math.ceil(totalThreatCount / threatCardPageSize) || 1;
@@ -360,7 +376,7 @@ const LogsAndThreats = () => {
360
  // Full Page Threat Intelligence View Mode
361
  if (isFullThreatsView) {
362
  return (
363
- <div className="w-full text-on-surface animate-fade-in">
364
  {/* Full Page Header */}
365
  <div className="flex flex-col md:flex-row md:items-center justify-between mb-lg gap-sm border-b border-outline-variant/60 pb-md">
366
  <div>
@@ -373,62 +389,106 @@ const LogsAndThreats = () => {
373
  </button>
374
  <h1 className="text-[26px] font-extrabold font-display tracking-tight text-on-surface flex items-center gap-2">
375
  <span className="material-symbols-outlined text-error text-[28px]">warning</span>
376
- Complete Global Threat Intelligence
377
  <span className="bg-error/10 text-error text-[12px] font-extrabold px-2.5 py-0.5 rounded-full ml-2 border border-error/20">
378
- {totalFullThreatEntries} Records
379
  </span>
380
  </h1>
381
- <p className="text-on-surface-variant text-[13.5px] mt-1">Detailed system vulnerability advisories, severity metrics, and remediation guides.</p>
382
  </div>
383
 
384
  <div className="flex items-center gap-2 flex-wrap">
385
  <button
386
  onClick={() => fetchStats(true)}
387
  disabled={loading}
388
- className="flex items-center gap-1.5 px-3.5 py-2 bg-surface-container border border-outline-variant text-on-surface hover:bg-surface-container-high rounded-lg text-[13px] font-bold transition-colors cursor-pointer"
389
  >
390
  <RefreshCw className={`w-4 h-4 ${loading ? 'animate-spin' : ''}`} />
391
- Refresh Data
392
  </button>
393
  </div>
394
  </div>
395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  {/* Filter and Search Bar */}
397
  <div className="mb-md bg-surface-container-lowest border border-outline-variant/70 rounded-xl p-4 flex flex-col md:flex-row items-center justify-between gap-3 shadow-2xs">
398
  <div className="flex flex-wrap items-center gap-3 w-full md:w-auto flex-1">
399
- <div className="relative w-full sm:w-72">
400
  <Search className="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-on-surface-variant" />
401
  <input
402
  type="text"
403
- placeholder="Search threat title, OWASP, or category..."
404
  value={threatSearch}
405
  onChange={(e) => setThreatSearch(e.target.value)}
406
  className="w-full pl-9 pr-3 py-2 bg-surface border border-outline-variant/60 rounded-lg text-[13px] text-on-surface focus:outline-none focus:border-primary"
407
  />
408
  </div>
409
 
410
- <div className="flex items-center gap-1.5 w-full sm:w-auto">
411
- <span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider shrink-0">Severity:</span>
412
- <select
413
- value={threatSeverityFilter}
414
- onChange={(e) => setThreatSeverityFilter(e.target.value)}
415
- className="bg-surface border border-outline-variant/60 text-on-surface text-[13px] font-medium rounded-lg px-3 py-2 focus:outline-none focus:border-primary cursor-pointer w-full sm:w-auto"
416
- >
417
- <option value="all">All Severities</option>
418
- <option value="critical">Critical</option>
419
- <option value="high">High</option>
420
- <option value="medium">Medium</option>
421
- <option value="low">Low</option>
422
- </select>
423
- </div>
424
-
425
  {(threatSearch || threatSeverityFilter !== 'all') && (
426
  <button
427
  onClick={clearThreatFilters}
428
  className="text-error hover:underline text-[12.5px] font-bold flex items-center gap-1 cursor-pointer bg-transparent border-0 px-1"
429
  >
430
  <span className="material-symbols-outlined text-[16px]">close</span>
431
- Reset Filters
432
  </button>
433
  )}
434
  </div>
@@ -476,7 +536,7 @@ const LogsAndThreats = () => {
476
  </p>
477
  </td>
478
  <td className="p-3.5 whitespace-nowrap">
479
- <span className={`px-2.5 py-0.5 rounded text-[10.5px] font-extrabold uppercase tracking-wider border ${getSeverityBadgeClass(detail.severity)}`}>
480
  {detail.severity}
481
  </span>
482
  </td>
@@ -579,119 +639,6 @@ const LogsAndThreats = () => {
579
  </>
580
  )}
581
  </div>
582
-
583
- {/* Global Threat Detail Modal */}
584
- {selectedThreat && (
585
- <div className="fixed inset-0 bg-black/80 backdrop-blur-md flex items-center justify-center p-4 z-[100] animate-fade-in">
586
- <div className="bg-surface border border-outline-variant rounded-2xl max-w-2xl w-full p-6 shadow-2xl relative max-h-[90vh] overflow-y-auto">
587
- <button
588
- onClick={() => setSelectedThreat(null)}
589
- className="absolute top-4 right-4 text-on-surface-variant hover:text-on-surface bg-surface-container p-2 rounded-full transition-colors cursor-pointer border-0"
590
- >
591
- <X className="w-5 h-5" />
592
- </button>
593
-
594
- <div className="flex items-start gap-3 border-b border-outline-variant pb-4 mb-4 pr-8">
595
- <div className="p-3 bg-red-500/10 text-error rounded-xl border border-red-500/20 shrink-0">
596
- <AlertTriangle className="w-6 h-6 text-error" />
597
- </div>
598
- <div>
599
- <div className="flex items-center gap-2 flex-wrap mb-1">
600
- <span className={`px-2.5 py-0.5 rounded-md text-[11px] font-extrabold uppercase tracking-wider border ${getSeverityBadgeClass(selectedThreat.severity)}`}>
601
- {selectedThreat.severity} Severity
602
- </span>
603
- <span className="bg-primary/10 text-primary text-[11px] font-bold px-2.5 py-0.5 rounded-md border border-primary/20">
604
- CVSS {selectedThreat.cvss}
605
- </span>
606
- <span className="bg-surface-container-high text-on-surface font-bold text-[11px] px-2.5 py-0.5 rounded-md border border-outline-variant">
607
- {selectedThreat.count} Detections Recorded
608
- </span>
609
- </div>
610
- <h2 className="text-[20px] font-bold text-on-surface tracking-tight leading-snug">
611
- {selectedThreat.title}
612
- </h2>
613
- </div>
614
- </div>
615
-
616
- <div className="space-y-4 text-[13.5px]">
617
- <div className="grid grid-cols-1 sm:grid-cols-2 gap-3 bg-surface-container-lowest p-3.5 rounded-xl border border-outline-variant/70">
618
- <div>
619
- <span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider block mb-0.5">Category</span>
620
- <span className="font-bold text-on-surface">{selectedThreat.category}</span>
621
- </div>
622
- <div>
623
- <span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider block mb-0.5">OWASP Mapping</span>
624
- <span className="font-bold text-primary">{selectedThreat.owasp}</span>
625
- </div>
626
- </div>
627
-
628
- <div>
629
- <h3 className="font-bold text-on-surface text-[14px] mb-1.5 flex items-center gap-1.5">
630
- <Shield className="w-4 h-4 text-primary" /> Threat Overview
631
- </h3>
632
- <p className="text-on-surface-variant leading-relaxed bg-surface-container-lowest p-3.5 rounded-xl border border-outline-variant/60">
633
- {selectedThreat.description}
634
- </p>
635
- </div>
636
-
637
- <div>
638
- <h3 className="font-bold text-on-surface text-[14px] mb-1.5 flex items-center gap-1.5 text-orange-400">
639
- <AlertTriangle className="w-4 h-4" /> Exploitation & Impact Risk
640
- </h3>
641
- <p className="text-on-surface-variant leading-relaxed bg-surface-container-lowest p-3.5 rounded-xl border border-outline-variant/60">
642
- {selectedThreat.impact}
643
- </p>
644
- </div>
645
-
646
- <div>
647
- <h3 className="font-bold text-on-surface text-[14px] mb-1.5 flex items-center gap-1.5 text-green-400">
648
- <CheckCircle className="w-4 h-4" /> Recommended Remediation
649
- </h3>
650
- <div className="bg-surface-container-lowest p-3.5 rounded-xl border border-outline-variant/60 font-mono text-[12.5px] text-green-300 leading-relaxed overflow-x-auto whitespace-pre-wrap">
651
- {selectedThreat.remediation}
652
- </div>
653
- </div>
654
-
655
- {selectedThreat.affected_targets && selectedThreat.affected_targets.length > 0 && (
656
- <div>
657
- <h3 className="font-bold text-on-surface text-[14px] mb-1.5 flex items-center gap-1.5">
658
- <ExternalLink className="w-4 h-4 text-primary" /> Affected Target Endpoints ({selectedThreat.affected_targets.length})
659
- </h3>
660
- <div className="flex flex-wrap gap-2 bg-surface-container-lowest p-3 rounded-xl border border-outline-variant/60">
661
- {selectedThreat.affected_targets.map((url, idx) => (
662
- <span key={idx} className="bg-surface border border-outline-variant text-on-surface font-mono text-[12px] px-2.5 py-1 rounded-md flex items-center gap-1">
663
- <span className="w-2 h-2 rounded-full bg-red-400"></span>
664
- {url}
665
- </span>
666
- ))}
667
- </div>
668
- </div>
669
- )}
670
- </div>
671
-
672
- <div className="mt-6 pt-4 border-t border-outline-variant flex items-center justify-between flex-wrap gap-2">
673
- <button
674
- onClick={() => {
675
- const query = selectedThreat.title;
676
- setSelectedThreat(null);
677
- openFullLogsView(query);
678
- }}
679
- className="px-4 py-2 bg-primary/10 hover:bg-primary/20 text-primary border border-primary/30 rounded-xl font-bold text-[13px] flex items-center gap-2 cursor-pointer transition-colors"
680
- >
681
- <Search className="w-4 h-4" />
682
- Filter Logs for this Threat
683
- </button>
684
-
685
- <button
686
- onClick={() => setSelectedThreat(null)}
687
- className="px-5 py-2 bg-primary text-white rounded-xl font-bold text-[13px] hover:brightness-110 cursor-pointer border-0 shadow-md shadow-primary/20 transition-all"
688
- >
689
- Close Details
690
- </button>
691
- </div>
692
- </div>
693
- </div>
694
- )}
695
  </div>
696
  );
697
  }
@@ -699,7 +646,7 @@ const LogsAndThreats = () => {
699
  // Full Page Audit Logs Mode
700
  if (isFullLogsView) {
701
  return (
702
- <div className="w-full text-on-surface animate-fade-in">
703
  {/* Full Page Header */}
704
  <div className="flex flex-col md:flex-row md:items-center justify-between mb-lg gap-sm border-b border-outline-variant/60 pb-md">
705
  <div>
@@ -916,7 +863,7 @@ const LogsAndThreats = () => {
916
 
917
  // Dashboard Overview Mode
918
  return (
919
- <div className="w-full text-on-surface animate-fade-in relative">
920
  <div className="flex flex-col md:flex-row md:items-center justify-between mb-xl gap-sm">
921
  <div>
922
  <h1 className="text-[28px] font-extrabold font-display tracking-tight text-primary flex items-center gap-2">
@@ -941,7 +888,7 @@ const LogsAndThreats = () => {
941
  </h2>
942
  <button
943
  onClick={openFullThreatsView}
944
- className="flex items-center gap-1.5 px-3 py-1.5 bg-error/10 hover:bg-error/20 text-error rounded-lg transition-colors font-bold text-[12px] cursor-pointer"
945
  >
946
  <List className="w-4 h-4" />
947
  View All Threats
@@ -968,7 +915,7 @@ const LogsAndThreats = () => {
968
  title="Click to view full threat details & remediation guide"
969
  >
970
  <div className="flex items-start gap-3 pr-2">
971
- <span className="w-7 h-7 rounded-full bg-error/10 text-error flex items-center justify-center text-[12px] font-extrabold shrink-0 mt-0.5">
972
  {globalIdx}
973
  </span>
974
  <div>
@@ -1079,7 +1026,7 @@ const LogsAndThreats = () => {
1079
  </h2>
1080
  <button
1081
  onClick={() => openFullLogsView()}
1082
- className="flex items-center gap-1.5 px-3 py-1.5 bg-primary/10 hover:bg-primary/20 text-primary rounded-lg transition-colors font-bold text-[12px] cursor-pointer"
1083
  >
1084
  <List className="w-4 h-4" />
1085
  View All Audit Logs
@@ -1122,95 +1069,107 @@ const LogsAndThreats = () => {
1122
  </div>
1123
  </div>
1124
 
1125
- {/* Global Threat Detail Modal */}
1126
  {selectedThreat && (
1127
- <div className="fixed inset-0 bg-black/80 backdrop-blur-md flex items-center justify-center p-4 z-[100] animate-fade-in">
1128
- <div className="bg-surface border border-outline-variant rounded-2xl max-w-2xl w-full p-6 shadow-2xl relative max-h-[90vh] overflow-y-auto">
1129
- {/* Close Button */}
1130
- <button
1131
- onClick={() => setSelectedThreat(null)}
1132
- className="absolute top-4 right-4 text-on-surface-variant hover:text-on-surface bg-surface-container p-2 rounded-full transition-colors cursor-pointer border-0"
1133
- >
1134
- <X className="w-5 h-5" />
1135
- </button>
 
 
1136
 
1137
- {/* Modal Header */}
1138
- <div className="flex items-start gap-3 border-b border-outline-variant pb-4 mb-4 pr-8">
1139
- <div className="p-3 bg-red-500/10 text-error rounded-xl border border-red-500/20 shrink-0">
1140
- <AlertTriangle className="w-6 h-6 text-error" />
1141
- </div>
1142
- <div>
1143
- <div className="flex items-center gap-2 flex-wrap mb-1">
1144
- <span className={`px-2.5 py-0.5 rounded-md text-[11px] font-extrabold uppercase tracking-wider border ${getSeverityBadgeClass(selectedThreat.severity)}`}>
1145
- {selectedThreat.severity} Severity
1146
- </span>
1147
- <span className="bg-primary/10 text-primary text-[11px] font-bold px-2.5 py-0.5 rounded-md border border-primary/20">
1148
- CVSS {selectedThreat.cvss}
1149
- </span>
1150
- <span className="bg-surface-container-high text-on-surface font-bold text-[11px] px-2.5 py-0.5 rounded-md border border-outline-variant">
1151
- {selectedThreat.count} Detections Recorded
1152
- </span>
1153
- </div>
1154
- <h2 className="text-[20px] font-bold text-on-surface tracking-tight leading-snug">
1155
- {selectedThreat.title}
1156
- </h2>
1157
  </div>
 
 
 
 
1158
  </div>
1159
 
1160
- {/* Modal Content */}
1161
- <div className="space-y-4 text-[13.5px]">
1162
- {/* Categorization Specs */}
1163
- <div className="grid grid-cols-1 sm:grid-cols-2 gap-3 bg-surface-container-lowest p-3.5 rounded-xl border border-outline-variant/70">
1164
- <div>
1165
- <span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider block mb-0.5">Category</span>
1166
- <span className="font-bold text-on-surface">{selectedThreat.category}</span>
 
 
 
1167
  </div>
1168
- <div>
1169
- <span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider block mb-0.5">OWASP Mapping</span>
1170
- <span className="font-bold text-primary">{selectedThreat.owasp}</span>
 
 
1171
  </div>
1172
  </div>
1173
 
1174
- {/* Description */}
1175
- <div>
1176
- <h3 className="font-bold text-on-surface text-[14px] mb-1.5 flex items-center gap-1.5">
1177
  <Shield className="w-4 h-4 text-primary" /> Threat Overview
1178
  </h3>
1179
- <p className="text-on-surface-variant leading-relaxed bg-surface-container-lowest p-3.5 rounded-xl border border-outline-variant/60">
1180
  {selectedThreat.description}
1181
  </p>
1182
  </div>
1183
 
1184
- {/* Security Impact */}
1185
- <div>
1186
- <h3 className="font-bold text-on-surface text-[14px] mb-1.5 flex items-center gap-1.5 text-orange-400">
1187
  <AlertTriangle className="w-4 h-4" /> Exploitation & Impact Risk
1188
  </h3>
1189
- <p className="text-on-surface-variant leading-relaxed bg-surface-container-lowest p-3.5 rounded-xl border border-outline-variant/60">
1190
  {selectedThreat.impact}
1191
  </p>
1192
  </div>
1193
 
1194
- {/* Remediation Fix */}
1195
- <div>
1196
- <h3 className="font-bold text-on-surface text-[14px] mb-1.5 flex items-center gap-1.5 text-green-400">
1197
- <CheckCircle className="w-4 h-4" /> Recommended Remediation
1198
- </h3>
1199
- <div className="bg-surface-container-lowest p-3.5 rounded-xl border border-outline-variant/60 font-mono text-[12.5px] text-green-300 leading-relaxed overflow-x-auto whitespace-pre-wrap">
 
 
 
 
 
 
 
 
 
 
1200
  {selectedThreat.remediation}
1201
  </div>
1202
  </div>
1203
 
1204
- {/* Affected Target URLs */}
1205
  {selectedThreat.affected_targets && selectedThreat.affected_targets.length > 0 && (
1206
- <div>
1207
- <h3 className="font-bold text-on-surface text-[14px] mb-1.5 flex items-center gap-1.5">
1208
  <ExternalLink className="w-4 h-4 text-primary" /> Affected Target Endpoints ({selectedThreat.affected_targets.length})
1209
  </h3>
1210
- <div className="flex flex-wrap gap-2 bg-surface-container-lowest p-3 rounded-xl border border-outline-variant/60">
1211
  {selectedThreat.affected_targets.map((url, idx) => (
1212
- <span key={idx} className="bg-surface border border-outline-variant text-on-surface font-mono text-[12px] px-2.5 py-1 rounded-md flex items-center gap-1">
1213
- <span className="w-2 h-2 rounded-full bg-red-400"></span>
1214
  {url}
1215
  </span>
1216
  ))}
@@ -1219,25 +1178,25 @@ const LogsAndThreats = () => {
1219
  )}
1220
  </div>
1221
 
1222
- {/* Modal Actions */}
1223
- <div className="mt-6 pt-4 border-t border-outline-variant flex items-center justify-between flex-wrap gap-2">
1224
  <button
1225
  onClick={() => {
1226
  const query = selectedThreat.title;
1227
  setSelectedThreat(null);
1228
  openFullLogsView(query);
1229
  }}
1230
- className="px-4 py-2 bg-primary/10 hover:bg-primary/20 text-primary border border-primary/30 rounded-xl font-bold text-[13px] flex items-center gap-2 cursor-pointer transition-colors"
1231
  >
1232
  <Search className="w-4 h-4" />
1233
- Filter Logs for this Threat
1234
  </button>
1235
 
1236
  <button
1237
  onClick={() => setSelectedThreat(null)}
1238
- className="px-5 py-2 bg-primary text-white rounded-xl font-bold text-[13px] hover:brightness-110 cursor-pointer border-0 shadow-md shadow-primary/20 transition-all"
1239
  >
1240
- Close Details
1241
  </button>
1242
  </div>
1243
  </div>
 
1
  import React, { useState, useEffect } from 'react';
2
  import { Link } from 'react-router-dom';
3
  import { useAuth } from '../components/AuthContext';
4
+ import {
5
+ ShieldAlert, Search, Download, RefreshCw, List, ArrowLeft, Filter,
6
+ Info, X, ExternalLink, Shield, AlertTriangle, CheckCircle, Copy, Check, Terminal, Layers
7
+ } from 'lucide-react';
8
 
9
  const THREAT_KNOWLEDGE_BASE = {
10
  "Missing Security Header: Cross-Origin-Embedder-Policy": {
 
15
  cwe: ["CWE-693"],
16
  description: "The Cross-Origin-Embedder-Policy (COEP) HTTP response header prevents a document from loading any cross-origin resources that do not explicitly grant the document permission (using CORP or CORS).",
17
  impact: "Without COEP, cross-origin resources can be loaded without explicit consent, increasing susceptibility to Spectre-style side-channel attacks and unauthorized data leakage.",
18
+ remediation: "add_header Cross-Origin-Embedder-Policy \"require-corp\" always;\n# Options: require-corp, credentialless, unsafe-none",
19
  affected_targets: ["https://app.larshield.io", "https://api.larshield.io/v1", "https://portal.larshield.com"]
20
  },
21
  "Missing Security Header: Expect-CT": {
 
26
  cwe: ["CWE-295"],
27
  description: "The Expect-CT header allows sites to report and/or enforce Certificate Transparency requirements, preventing misissued SSL/TLS certificates.",
28
  impact: "Lack of CT enforcement leaves client browsers unable to verify whether an SSL certificate was legitimately logged in public CT logs.",
29
+ remediation: "add_header Expect-CT \"max-age=86400, enforce, report-uri=\\\"https://larshield.io/ct-report\\\"\" always;",
30
  affected_targets: ["https://auth.larshield.io", "https://admin.larshield.com"]
31
  },
32
  "Known TLS/Crypto CVEs: CVE-2023-44487": {
 
37
  cwe: ["CWE-400"],
38
  description: "CVE-2023-44487 refers to the HTTP/2 Rapid Reset Denial of Service attack. Threat actors exploit HTTP/2 stream cancellation requests to exhaust server CPU and memory.",
39
  impact: "Unpatched web servers accepting HTTP/2 connections can be easily overwhelmed by rapid stream creation and immediate resets, causing server outages and complete denial of service.",
40
+ remediation: "# NGINX HTTP/2 Rapid Reset Mitigation\nkeepalive_requests 1000;\nhttp2_max_concurrent_streams 128;\nlimit_req_zone $binary_remote_addr zone=http2_limit:10m rate=100r/s;",
41
  affected_targets: ["https://lb-primary.larshield.internal", "https://gateway.larshield.io"]
42
  },
43
  "DNSSEC Not Implemented": {
 
48
  cwe: ["CWE-350"],
49
  description: "Domain Name System Security Extensions (DNSSEC) adds cryptographic signatures to DNS records to verify domain data authenticity.",
50
  impact: "Without DNSSEC, clients are vulnerable to DNS spoofing and cache poisoning attacks, allowing threat actors to hijack domain traffic and impersonate application services.",
51
+ remediation: "# Enable DNSSEC at domain registrar\n1. Sign zone using ECDSA Curve P-256 with SHA-256\n2. Publish DS records to TLD parent zone",
52
  affected_targets: ["larshield.io", "larshield.com"]
53
  },
54
  "Server Information Disclosure via 'server' Header": {
 
59
  cwe: ["CWE-200"],
60
  description: "The HTTP 'Server' response header exposes detailed web server software, exact version numbers, and underlying operating system details to anonymous clients.",
61
  impact: "Attackers use disclosed server software and version numbers to target known CVE vulnerabilities and refine automated exploit scripts.",
62
+ remediation: "# Hide NGINX server tokens\nserver_tokens off;\n\n# Hide Apache server header\nServerTokens Prod\nServerSignature Off",
63
  affected_targets: ["https://web-node-01.larshield.internal", "https://static.larshield.io"]
64
  }
65
  };
 
72
 
73
  // Selected Threat Detail Modal State
74
  const [selectedThreat, setSelectedThreat] = useState(null);
75
+ const [copiedCode, setCopiedCode] = useState(false);
76
 
77
  // Full Page Threat Intelligence View State
78
  const [isFullThreatsView, setIsFullThreatsView] = useState(false);
 
182
  setThreatSeverityFilter('all');
183
  };
184
 
185
+ const copyToClipboard = (text) => {
186
+ navigator.clipboard.writeText(text);
187
+ setCopiedCode(true);
188
+ setTimeout(() => setCopiedCode(false), 2000);
189
+ };
190
+
191
  const getThreatDetail = (t) => {
192
  if (!t) return null;
193
  const titleKey = typeof t === 'string' ? t : (t.title || '');
 
196
  title: titleKey,
197
  count: t.count || 1,
198
  severity: t.severity || kb.severity || 'Medium',
199
+ category: t.category || kb.category || 'Security Headers',
200
+ cvss: t.cvss_score || kb.cvss || 5.3,
201
  owasp: t.owasp_category || kb.owasp || 'A05:2021 - Security Misconfiguration',
202
  cwe: t.cwe_ids && t.cwe_ids.length ? t.cwe_ids : (kb.cwe || ['CWE-693']),
203
  description: t.description && t.description.length > 30 ? t.description : (kb.description || `Security intelligence scan detected "${titleKey}" across active system endpoints.`),
204
  impact: t.impact || kb.impact || 'Unpatched or missing security settings increase risk of exploitation, unauthorized data access, or service disruption.',
205
+ remediation: t.remediation && t.remediation.length > 20 ? t.remediation : (kb.remediation || 'add_header Cross-Origin-Embedder-Policy "require-corp" always;'),
206
+ affected_targets: t.affected_targets && t.affected_targets.length ? t.affected_targets : (kb.affected_targets || ['https://app.larshield.io'])
207
  };
208
  };
209
 
210
  // Helper for Severity Badges
211
  const getSeverityBadgeClass = (sev) => {
212
  const s = (sev || '').toLowerCase();
213
+ if (s === 'critical') return 'bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30';
214
+ if (s === 'high') return 'bg-orange-500/15 text-orange-600 dark:text-orange-400 border-orange-500/30';
215
+ if (s === 'medium') return 'bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30';
216
+ return 'bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30';
217
  };
218
 
219
  // Threat Details Calculations
220
  const allThreatDetails = trends.map(t => getThreatDetail(t)).filter(Boolean);
221
 
222
+ // Stats Counters
223
+ const criticalCount = allThreatDetails.filter(t => t.severity.toLowerCase() === 'critical').length;
224
+ const highCount = allThreatDetails.filter(t => t.severity.toLowerCase() === 'high').length;
225
+ const mediumCount = allThreatDetails.filter(t => t.severity.toLowerCase() === 'medium').length;
226
+ const lowCount = allThreatDetails.filter(t => t.severity.toLowerCase() === 'low').length;
227
+
228
  // In-Card Threats Pagination Calculations (Dashboard Overview)
229
  const totalThreatCount = allThreatDetails.length;
230
  const totalThreatCardPages = Math.ceil(totalThreatCount / threatCardPageSize) || 1;
 
376
  // Full Page Threat Intelligence View Mode
377
  if (isFullThreatsView) {
378
  return (
379
+ <div className="w-full text-on-surface animate-fade-in pb-12">
380
  {/* Full Page Header */}
381
  <div className="flex flex-col md:flex-row md:items-center justify-between mb-lg gap-sm border-b border-outline-variant/60 pb-md">
382
  <div>
 
389
  </button>
390
  <h1 className="text-[26px] font-extrabold font-display tracking-tight text-on-surface flex items-center gap-2">
391
  <span className="material-symbols-outlined text-error text-[28px]">warning</span>
392
+ Global Threat Intelligence Center
393
  <span className="bg-error/10 text-error text-[12px] font-extrabold px-2.5 py-0.5 rounded-full ml-2 border border-error/20">
394
+ {totalFullThreatEntries} Active Threats
395
  </span>
396
  </h1>
397
+ <p className="text-on-surface-variant text-[13.5px] mt-1">Vulnerability advisories, OWASP classifications, and technical remediation steps.</p>
398
  </div>
399
 
400
  <div className="flex items-center gap-2 flex-wrap">
401
  <button
402
  onClick={() => fetchStats(true)}
403
  disabled={loading}
404
+ className="flex items-center gap-1.5 px-4 py-2 bg-surface-container border border-outline-variant text-on-surface hover:bg-surface-container-high rounded-xl text-[13px] font-bold transition-colors cursor-pointer shadow-2xs"
405
  >
406
  <RefreshCw className={`w-4 h-4 ${loading ? 'animate-spin' : ''}`} />
407
+ Refresh Threats
408
  </button>
409
  </div>
410
  </div>
411
 
412
+ {/* Threat Severity Quick Counters */}
413
+ <div className="grid grid-cols-2 sm:grid-cols-5 gap-3 mb-md">
414
+ <div
415
+ onClick={() => setThreatSeverityFilter('all')}
416
+ className={`p-3.5 rounded-xl border cursor-pointer transition-all ${
417
+ threatSeverityFilter === 'all'
418
+ ? 'bg-primary/10 border-primary text-primary shadow-sm'
419
+ : 'bg-surface-container-lowest border-outline-variant/70 text-on-surface-variant hover:bg-surface-container-high'
420
+ }`}
421
+ >
422
+ <div className="text-[11px] font-extrabold uppercase tracking-wider">Total Threats</div>
423
+ <div className="text-2xl font-black mt-1">{totalThreatCount}</div>
424
+ </div>
425
+ <div
426
+ onClick={() => setThreatSeverityFilter('critical')}
427
+ className={`p-3.5 rounded-xl border cursor-pointer transition-all ${
428
+ threatSeverityFilter === 'critical'
429
+ ? 'bg-red-500/10 border-red-500 text-red-500 shadow-sm'
430
+ : 'bg-surface-container-lowest border-outline-variant/70 text-on-surface-variant hover:bg-surface-container-high'
431
+ }`}
432
+ >
433
+ <div className="text-[11px] font-extrabold uppercase tracking-wider text-red-500">Critical</div>
434
+ <div className="text-2xl font-black text-red-500 mt-1">{criticalCount}</div>
435
+ </div>
436
+ <div
437
+ onClick={() => setThreatSeverityFilter('high')}
438
+ className={`p-3.5 rounded-xl border cursor-pointer transition-all ${
439
+ threatSeverityFilter === 'high'
440
+ ? 'bg-orange-500/10 border-orange-500 text-orange-500 shadow-sm'
441
+ : 'bg-surface-container-lowest border-outline-variant/70 text-on-surface-variant hover:bg-surface-container-high'
442
+ }`}
443
+ >
444
+ <div className="text-[11px] font-extrabold uppercase tracking-wider text-orange-500">High</div>
445
+ <div className="text-2xl font-black text-orange-500 mt-1">{highCount}</div>
446
+ </div>
447
+ <div
448
+ onClick={() => setThreatSeverityFilter('medium')}
449
+ className={`p-3.5 rounded-xl border cursor-pointer transition-all ${
450
+ threatSeverityFilter === 'medium'
451
+ ? 'bg-amber-500/10 border-amber-500 text-amber-500 shadow-sm'
452
+ : 'bg-surface-container-lowest border-outline-variant/70 text-on-surface-variant hover:bg-surface-container-high'
453
+ }`}
454
+ >
455
+ <div className="text-[11px] font-extrabold uppercase tracking-wider text-amber-500">Medium</div>
456
+ <div className="text-2xl font-black text-amber-500 mt-1">{mediumCount}</div>
457
+ </div>
458
+ <div
459
+ onClick={() => setThreatSeverityFilter('low')}
460
+ className={`p-3.5 rounded-xl border cursor-pointer transition-all col-span-2 sm:col-span-1 ${
461
+ threatSeverityFilter === 'low'
462
+ ? 'bg-blue-500/10 border-blue-500 text-blue-500 shadow-sm'
463
+ : 'bg-surface-container-lowest border-outline-variant/70 text-on-surface-variant hover:bg-surface-container-high'
464
+ }`}
465
+ >
466
+ <div className="text-[11px] font-extrabold uppercase tracking-wider text-blue-500">Low</div>
467
+ <div className="text-2xl font-black text-blue-500 mt-1">{lowCount}</div>
468
+ </div>
469
+ </div>
470
+
471
  {/* Filter and Search Bar */}
472
  <div className="mb-md bg-surface-container-lowest border border-outline-variant/70 rounded-xl p-4 flex flex-col md:flex-row items-center justify-between gap-3 shadow-2xs">
473
  <div className="flex flex-wrap items-center gap-3 w-full md:w-auto flex-1">
474
+ <div className="relative w-full sm:w-80">
475
  <Search className="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-on-surface-variant" />
476
  <input
477
  type="text"
478
+ placeholder="Search vulnerability title, OWASP, or category..."
479
  value={threatSearch}
480
  onChange={(e) => setThreatSearch(e.target.value)}
481
  className="w-full pl-9 pr-3 py-2 bg-surface border border-outline-variant/60 rounded-lg text-[13px] text-on-surface focus:outline-none focus:border-primary"
482
  />
483
  </div>
484
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  {(threatSearch || threatSeverityFilter !== 'all') && (
486
  <button
487
  onClick={clearThreatFilters}
488
  className="text-error hover:underline text-[12.5px] font-bold flex items-center gap-1 cursor-pointer bg-transparent border-0 px-1"
489
  >
490
  <span className="material-symbols-outlined text-[16px]">close</span>
491
+ Reset Search Filters
492
  </button>
493
  )}
494
  </div>
 
536
  </p>
537
  </td>
538
  <td className="p-3.5 whitespace-nowrap">
539
+ <span className={`px-2.5 py-0.5 rounded-md text-[10.5px] font-extrabold uppercase tracking-wider border ${getSeverityBadgeClass(detail.severity)}`}>
540
  {detail.severity}
541
  </span>
542
  </td>
 
639
  </>
640
  )}
641
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
642
  </div>
643
  );
644
  }
 
646
  // Full Page Audit Logs Mode
647
  if (isFullLogsView) {
648
  return (
649
+ <div className="w-full text-on-surface animate-fade-in pb-12">
650
  {/* Full Page Header */}
651
  <div className="flex flex-col md:flex-row md:items-center justify-between mb-lg gap-sm border-b border-outline-variant/60 pb-md">
652
  <div>
 
863
 
864
  // Dashboard Overview Mode
865
  return (
866
+ <div className="w-full text-on-surface animate-fade-in relative pb-12">
867
  <div className="flex flex-col md:flex-row md:items-center justify-between mb-xl gap-sm">
868
  <div>
869
  <h1 className="text-[28px] font-extrabold font-display tracking-tight text-primary flex items-center gap-2">
 
888
  </h2>
889
  <button
890
  onClick={openFullThreatsView}
891
+ className="flex items-center gap-1.5 px-3.5 py-1.5 bg-error/10 hover:bg-error/20 text-error rounded-xl transition-colors font-bold text-[12px] cursor-pointer border border-error/20"
892
  >
893
  <List className="w-4 h-4" />
894
  View All Threats
 
915
  title="Click to view full threat details & remediation guide"
916
  >
917
  <div className="flex items-start gap-3 pr-2">
918
+ <span className="w-7 h-7 rounded-full bg-error/10 text-error flex items-center justify-center text-[12px] font-extrabold shrink-0 mt-0.5 border border-error/20">
919
  {globalIdx}
920
  </span>
921
  <div>
 
1026
  </h2>
1027
  <button
1028
  onClick={() => openFullLogsView()}
1029
+ className="flex items-center gap-1.5 px-3.5 py-1.5 bg-primary/10 hover:bg-primary/20 text-primary rounded-xl transition-colors font-bold text-[12px] cursor-pointer border border-primary/20"
1030
  >
1031
  <List className="w-4 h-4" />
1032
  View All Audit Logs
 
1069
  </div>
1070
  </div>
1071
 
1072
+ {/* Global Threat Detail Modal - High Tech Premium Design (z-[9999] so top layout header never clips it) */}
1073
  {selectedThreat && (
1074
+ <div className="fixed inset-0 bg-black/80 backdrop-blur-md flex items-center justify-center p-4 pt-20 z-[9999] animate-fade-in overflow-y-auto">
1075
+ <div className="bg-surface border border-outline-variant rounded-2xl max-w-2xl w-full shadow-2xl relative my-auto overflow-hidden flex flex-col max-h-[85vh]">
1076
+
1077
+ {/* Header Banner with Gradient */}
1078
+ <div className="bg-gradient-to-r from-surface-container-highest via-surface-container to-surface-container-low p-6 border-b border-outline-variant relative">
1079
+ <button
1080
+ onClick={() => setSelectedThreat(null)}
1081
+ className="absolute top-4 right-4 text-on-surface-variant hover:text-on-surface bg-surface-container-high p-2 rounded-full transition-colors cursor-pointer border border-outline-variant/60"
1082
+ >
1083
+ <X className="w-5 h-5" />
1084
+ </button>
1085
 
1086
+ <div className="flex items-center gap-2 flex-wrap mb-3 pr-10">
1087
+ <span className={`px-3 py-1 rounded-full text-[11px] font-black uppercase tracking-wider border shadow-2xs ${getSeverityBadgeClass(selectedThreat.severity)}`}>
1088
+ {selectedThreat.severity} SEVERITY
1089
+ </span>
1090
+ <span className="bg-cyan-500/10 text-cyan-600 dark:text-cyan-400 text-[11px] font-black px-3 py-1 rounded-full border border-cyan-500/30">
1091
+ CVSS {selectedThreat.cvss}
1092
+ </span>
1093
+ <span className="bg-red-500/10 text-red-600 dark:text-red-400 text-[11px] font-black px-3 py-1 rounded-full border border-red-500/30 flex items-center gap-1">
1094
+ <ShieldAlert className="w-3.5 h-3.5" />
1095
+ {selectedThreat.count} Detections Recorded
1096
+ </span>
 
 
 
 
 
 
 
 
 
1097
  </div>
1098
+
1099
+ <h2 className="text-[21px] font-extrabold text-on-surface tracking-tight leading-snug">
1100
+ {selectedThreat.title}
1101
+ </h2>
1102
  </div>
1103
 
1104
+ {/* Modal Body Scroll Container */}
1105
+ <div className="p-6 space-y-5 overflow-y-auto text-[13.5px]">
1106
+
1107
+ {/* Category & OWASP Specifications Cards */}
1108
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
1109
+ <div className="bg-surface-container-lowest p-4 rounded-xl border border-outline-variant/70 shadow-2xs">
1110
+ <span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider flex items-center gap-1.5 mb-1">
1111
+ <Layers className="w-3.5 h-3.5 text-primary" /> Vulnerability Category
1112
+ </span>
1113
+ <span className="font-extrabold text-on-surface text-[14px]">{selectedThreat.category}</span>
1114
  </div>
1115
+ <div className="bg-surface-container-lowest p-4 rounded-xl border border-outline-variant/70 shadow-2xs">
1116
+ <span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider flex items-center gap-1.5 mb-1">
1117
+ <Shield className="w-3.5 h-3.5 text-primary" /> OWASP Standard
1118
+ </span>
1119
+ <span className="font-extrabold text-primary text-[14px]">{selectedThreat.owasp}</span>
1120
  </div>
1121
  </div>
1122
 
1123
+ {/* Threat Overview Card */}
1124
+ <div className="bg-surface-container-lowest p-4 rounded-xl border-l-4 border-l-primary border border-outline-variant/60 shadow-2xs">
1125
+ <h3 className="font-bold text-on-surface text-[14px] mb-2 flex items-center gap-2">
1126
  <Shield className="w-4 h-4 text-primary" /> Threat Overview
1127
  </h3>
1128
+ <p className="text-on-surface-variant leading-relaxed">
1129
  {selectedThreat.description}
1130
  </p>
1131
  </div>
1132
 
1133
+ {/* Security Impact Card */}
1134
+ <div className="bg-surface-container-lowest p-4 rounded-xl border-l-4 border-l-amber-500 border border-outline-variant/60 shadow-2xs">
1135
+ <h3 className="font-bold text-on-surface text-[14px] mb-2 flex items-center gap-2 text-amber-600 dark:text-amber-400">
1136
  <AlertTriangle className="w-4 h-4" /> Exploitation & Impact Risk
1137
  </h3>
1138
+ <p className="text-on-surface-variant leading-relaxed">
1139
  {selectedThreat.impact}
1140
  </p>
1141
  </div>
1142
 
1143
+ {/* Code Remediation Terminal Box */}
1144
+ <div className="bg-surface-container-lowest p-4 rounded-xl border border-outline-variant/60 shadow-2xs">
1145
+ <div className="flex items-center justify-between mb-2">
1146
+ <h3 className="font-bold text-on-surface text-[14px] flex items-center gap-2 text-green-600 dark:text-green-400">
1147
+ <Terminal className="w-4 h-4" /> Recommended Remediation Command
1148
+ </h3>
1149
+ <button
1150
+ onClick={() => copyToClipboard(selectedThreat.remediation)}
1151
+ className="flex items-center gap-1 px-2.5 py-1 bg-surface-container hover:bg-surface-container-high text-on-surface rounded-lg text-[11.5px] font-bold border border-outline-variant cursor-pointer transition-all"
1152
+ >
1153
+ {copiedCode ? <Check className="w-3.5 h-3.5 text-green-500" /> : <Copy className="w-3.5 h-3.5" />}
1154
+ {copiedCode ? 'Copied!' : 'Copy Code'}
1155
+ </button>
1156
+ </div>
1157
+
1158
+ <div className="bg-[#0b132a] text-[#38bdf8] font-mono text-[12.5px] p-4 rounded-xl border border-slate-800 leading-relaxed overflow-x-auto shadow-inner">
1159
  {selectedThreat.remediation}
1160
  </div>
1161
  </div>
1162
 
1163
+ {/* Affected Target Endpoints */}
1164
  {selectedThreat.affected_targets && selectedThreat.affected_targets.length > 0 && (
1165
+ <div className="bg-surface-container-lowest p-4 rounded-xl border border-outline-variant/60 shadow-2xs">
1166
+ <h3 className="font-bold text-on-surface text-[14px] mb-2.5 flex items-center gap-2">
1167
  <ExternalLink className="w-4 h-4 text-primary" /> Affected Target Endpoints ({selectedThreat.affected_targets.length})
1168
  </h3>
1169
+ <div className="flex flex-wrap gap-2">
1170
  {selectedThreat.affected_targets.map((url, idx) => (
1171
+ <span key={idx} className="bg-surface-container border border-outline-variant/80 text-on-surface font-mono text-[12px] px-3 py-1.5 rounded-lg flex items-center gap-2 font-medium">
1172
+ <span className="w-2 h-2 rounded-full bg-red-500 animate-pulse"></span>
1173
  {url}
1174
  </span>
1175
  ))}
 
1178
  )}
1179
  </div>
1180
 
1181
+ {/* Modal Actions Footer */}
1182
+ <div className="p-4 bg-surface-container-lowest border-t border-outline-variant flex items-center justify-between flex-wrap gap-3">
1183
  <button
1184
  onClick={() => {
1185
  const query = selectedThreat.title;
1186
  setSelectedThreat(null);
1187
  openFullLogsView(query);
1188
  }}
1189
+ className="px-4 py-2.5 bg-primary/10 hover:bg-primary/20 text-primary border border-primary/30 rounded-xl font-bold text-[13px] flex items-center gap-2 cursor-pointer transition-colors"
1190
  >
1191
  <Search className="w-4 h-4" />
1192
+ Filter Audit Logs for this Threat
1193
  </button>
1194
 
1195
  <button
1196
  onClick={() => setSelectedThreat(null)}
1197
+ className="px-6 py-2.5 bg-primary text-white hover:brightness-110 rounded-xl font-bold text-[13px] cursor-pointer border-0 shadow-md shadow-primary/20 transition-all"
1198
  >
1199
+ Close Window
1200
  </button>
1201
  </div>
1202
  </div>