Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update frontend/src/pages/LogsAndThreats.jsx
Browse files
frontend/src/pages/LogsAndThreats.jsx
CHANGED
|
@@ -161,6 +161,7 @@ const LogsAndThreats = () => {
|
|
| 161 |
};
|
| 162 |
|
| 163 |
const getThreatDetail = (t) => {
|
|
|
|
| 164 |
const titleKey = typeof t === 'string' ? t : (t.title || '');
|
| 165 |
const kb = THREAT_KNOWLEDGE_BASE[titleKey] || {};
|
| 166 |
return {
|
|
@@ -172,7 +173,7 @@ const LogsAndThreats = () => {
|
|
| 172 |
owasp: t.owasp_category || kb.owasp || 'A05:2021 - Security Misconfiguration',
|
| 173 |
cwe: t.cwe_ids && t.cwe_ids.length ? t.cwe_ids : (kb.cwe || ['CWE-693']),
|
| 174 |
description: t.description && t.description.length > 30 ? t.description : (kb.description || `Security intelligence scan detected "${titleKey}" across active system endpoints.`),
|
| 175 |
-
impact: kb.impact || 'Unpatched or missing security settings increase risk of exploitation, unauthorized data access, or service disruption.',
|
| 176 |
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.'),
|
| 177 |
affected_targets: t.affected_targets && t.affected_targets.length ? t.affected_targets : (kb.affected_targets || ['https://scanned-target.larshield.io'])
|
| 178 |
};
|
|
@@ -188,7 +189,7 @@ const LogsAndThreats = () => {
|
|
| 188 |
};
|
| 189 |
|
| 190 |
// In-Card Threats Pagination Calculations
|
| 191 |
-
const allThreatDetails = trends.map(t => getThreatDetail(t));
|
| 192 |
const totalThreatCount = allThreatDetails.length;
|
| 193 |
const totalThreatCardPages = Math.ceil(totalThreatCount / threatCardPageSize) || 1;
|
| 194 |
const validThreatCardPage = Math.min(Math.max(1, threatCardPage), totalThreatCardPages);
|
|
@@ -587,7 +588,10 @@ const LogsAndThreats = () => {
|
|
| 587 |
return (
|
| 588 |
<li
|
| 589 |
key={i}
|
| 590 |
-
onClick={() =>
|
|
|
|
|
|
|
|
|
|
| 591 |
className="py-3 px-3 rounded-xl flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-surface-container-high/70 cursor-pointer transition-all group border border-transparent hover:border-primary/30 my-1"
|
| 592 |
title="Click to view full threat details & remediation guide"
|
| 593 |
>
|
|
@@ -617,6 +621,7 @@ const LogsAndThreats = () => {
|
|
| 617 |
<button
|
| 618 |
type="button"
|
| 619 |
onClick={(e) => {
|
|
|
|
| 620 |
e.stopPropagation();
|
| 621 |
setSelectedThreat(detail);
|
| 622 |
}}
|
|
@@ -745,7 +750,7 @@ const LogsAndThreats = () => {
|
|
| 745 |
</div>
|
| 746 |
</div>
|
| 747 |
|
| 748 |
-
{/* All Global Threats Modal Popup
|
| 749 |
{showAllThreatsModal && (
|
| 750 |
<div className="fixed inset-0 bg-black/70 backdrop-blur-md flex items-center justify-center p-4 z-50 animate-fade-in">
|
| 751 |
<div className="bg-surface border border-outline-variant rounded-2xl max-w-3xl w-full p-6 shadow-2xl relative max-h-[90vh] flex flex-col">
|
|
@@ -791,7 +796,8 @@ const LogsAndThreats = () => {
|
|
| 791 |
{filteredModalThreats.map((detail, idx) => (
|
| 792 |
<li
|
| 793 |
key={idx}
|
| 794 |
-
onClick={() => {
|
|
|
|
| 795 |
setSelectedThreat(detail);
|
| 796 |
}}
|
| 797 |
className="py-3 px-3 rounded-xl flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-surface-container-high/70 cursor-pointer transition-all group border border-transparent hover:border-primary/30 my-1"
|
|
@@ -822,6 +828,7 @@ const LogsAndThreats = () => {
|
|
| 822 |
<button
|
| 823 |
type="button"
|
| 824 |
onClick={(e) => {
|
|
|
|
| 825 |
e.stopPropagation();
|
| 826 |
setSelectedThreat(detail);
|
| 827 |
}}
|
|
@@ -849,9 +856,9 @@ const LogsAndThreats = () => {
|
|
| 849 |
</div>
|
| 850 |
)}
|
| 851 |
|
| 852 |
-
{/* Global Threat Detail Modal */}
|
| 853 |
{selectedThreat && (
|
| 854 |
-
<div className="fixed inset-0 bg-black/
|
| 855 |
<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">
|
| 856 |
{/* Close Button */}
|
| 857 |
<button
|
|
|
|
| 161 |
};
|
| 162 |
|
| 163 |
const getThreatDetail = (t) => {
|
| 164 |
+
if (!t) return null;
|
| 165 |
const titleKey = typeof t === 'string' ? t : (t.title || '');
|
| 166 |
const kb = THREAT_KNOWLEDGE_BASE[titleKey] || {};
|
| 167 |
return {
|
|
|
|
| 173 |
owasp: t.owasp_category || kb.owasp || 'A05:2021 - Security Misconfiguration',
|
| 174 |
cwe: t.cwe_ids && t.cwe_ids.length ? t.cwe_ids : (kb.cwe || ['CWE-693']),
|
| 175 |
description: t.description && t.description.length > 30 ? t.description : (kb.description || `Security intelligence scan detected "${titleKey}" across active system endpoints.`),
|
| 176 |
+
impact: t.impact || kb.impact || 'Unpatched or missing security settings increase risk of exploitation, unauthorized data access, or service disruption.',
|
| 177 |
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.'),
|
| 178 |
affected_targets: t.affected_targets && t.affected_targets.length ? t.affected_targets : (kb.affected_targets || ['https://scanned-target.larshield.io'])
|
| 179 |
};
|
|
|
|
| 189 |
};
|
| 190 |
|
| 191 |
// In-Card Threats Pagination Calculations
|
| 192 |
+
const allThreatDetails = trends.map(t => getThreatDetail(t)).filter(Boolean);
|
| 193 |
const totalThreatCount = allThreatDetails.length;
|
| 194 |
const totalThreatCardPages = Math.ceil(totalThreatCount / threatCardPageSize) || 1;
|
| 195 |
const validThreatCardPage = Math.min(Math.max(1, threatCardPage), totalThreatCardPages);
|
|
|
|
| 588 |
return (
|
| 589 |
<li
|
| 590 |
key={i}
|
| 591 |
+
onClick={(e) => {
|
| 592 |
+
e.preventDefault();
|
| 593 |
+
setSelectedThreat(detail);
|
| 594 |
+
}}
|
| 595 |
className="py-3 px-3 rounded-xl flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-surface-container-high/70 cursor-pointer transition-all group border border-transparent hover:border-primary/30 my-1"
|
| 596 |
title="Click to view full threat details & remediation guide"
|
| 597 |
>
|
|
|
|
| 621 |
<button
|
| 622 |
type="button"
|
| 623 |
onClick={(e) => {
|
| 624 |
+
e.preventDefault();
|
| 625 |
e.stopPropagation();
|
| 626 |
setSelectedThreat(detail);
|
| 627 |
}}
|
|
|
|
| 750 |
</div>
|
| 751 |
</div>
|
| 752 |
|
| 753 |
+
{/* All Global Threats Modal Popup */}
|
| 754 |
{showAllThreatsModal && (
|
| 755 |
<div className="fixed inset-0 bg-black/70 backdrop-blur-md flex items-center justify-center p-4 z-50 animate-fade-in">
|
| 756 |
<div className="bg-surface border border-outline-variant rounded-2xl max-w-3xl w-full p-6 shadow-2xl relative max-h-[90vh] flex flex-col">
|
|
|
|
| 796 |
{filteredModalThreats.map((detail, idx) => (
|
| 797 |
<li
|
| 798 |
key={idx}
|
| 799 |
+
onClick={(e) => {
|
| 800 |
+
e.preventDefault();
|
| 801 |
setSelectedThreat(detail);
|
| 802 |
}}
|
| 803 |
className="py-3 px-3 rounded-xl flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-surface-container-high/70 cursor-pointer transition-all group border border-transparent hover:border-primary/30 my-1"
|
|
|
|
| 828 |
<button
|
| 829 |
type="button"
|
| 830 |
onClick={(e) => {
|
| 831 |
+
e.preventDefault();
|
| 832 |
e.stopPropagation();
|
| 833 |
setSelectedThreat(detail);
|
| 834 |
}}
|
|
|
|
| 856 |
</div>
|
| 857 |
)}
|
| 858 |
|
| 859 |
+
{/* Global Threat Detail Modal - High Z-Index to stack cleanly */}
|
| 860 |
{selectedThreat && (
|
| 861 |
+
<div className="fixed inset-0 bg-black/80 backdrop-blur-md flex items-center justify-center p-4 z-[100] animate-fade-in">
|
| 862 |
<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">
|
| 863 |
{/* Close Button */}
|
| 864 |
<button
|