Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update frontend/src/pages/LogsAndThreats.jsx
Browse files
frontend/src/pages/LogsAndThreats.jsx
CHANGED
|
@@ -464,108 +464,167 @@ const LogsAndThreats = () => {
|
|
| 464 |
|
| 465 |
const renderThreatModal = () => {
|
| 466 |
if (!selectedThreat) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
return (
|
| 468 |
-
<div className="fixed inset-0 bg-
|
| 469 |
-
<div className=
|
| 470 |
|
| 471 |
-
{/* Header Banner with Gradient */}
|
| 472 |
-
<div className=
|
| 473 |
<button
|
| 474 |
onClick={() => setSelectedThreat(null)}
|
| 475 |
-
className="absolute top-
|
|
|
|
| 476 |
>
|
| 477 |
<X className="w-5 h-5" />
|
| 478 |
</button>
|
| 479 |
|
| 480 |
-
<div className="flex items-center gap-2 flex-wrap mb-3 pr-
|
| 481 |
-
<span className={`px-3 py-1 rounded-full text-[11px] font-black uppercase tracking-wider border shadow-2xs ${getSeverityBadgeClass(selectedThreat.severity)}`}>
|
|
|
|
| 482 |
{selectedThreat.severity} SEVERITY
|
| 483 |
</span>
|
| 484 |
-
<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">
|
| 485 |
CVSS {selectedThreat.cvss}
|
| 486 |
</span>
|
| 487 |
-
<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">
|
| 488 |
-
<
|
| 489 |
{selectedThreat.count} Detections Recorded
|
| 490 |
</span>
|
| 491 |
</div>
|
| 492 |
|
| 493 |
-
<h2 className="text-[
|
| 494 |
{selectedThreat.title}
|
| 495 |
</h2>
|
| 496 |
</div>
|
| 497 |
|
| 498 |
{/* Modal Body Scroll Container */}
|
| 499 |
-
<div className="p-6 space-y-
|
| 500 |
|
| 501 |
{/* Category & OWASP Specifications Cards */}
|
| 502 |
-
<div className="grid grid-cols-1 sm:grid-cols-2 gap-
|
| 503 |
-
<div className="bg-surface-container-lowest p-4 rounded-
|
| 504 |
-
<
|
| 505 |
-
<Layers className="w-
|
| 506 |
-
</
|
| 507 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
</div>
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
</div>
|
| 515 |
</div>
|
| 516 |
|
| 517 |
{/* Threat Overview Card */}
|
| 518 |
-
<div className="bg-surface-container-lowest p-
|
| 519 |
-
<h3 className="font-bold text-on-surface text-[
|
| 520 |
-
<Shield className="w-4 h-4 text-primary" />
|
| 521 |
</h3>
|
| 522 |
-
<p className="text-on-surface-variant leading-relaxed">
|
| 523 |
{selectedThreat.description}
|
| 524 |
</p>
|
| 525 |
</div>
|
| 526 |
|
| 527 |
{/* Security Impact Card */}
|
| 528 |
-
<div className="bg-surface-container-lowest p-
|
| 529 |
-
<h3 className="font-bold text-
|
| 530 |
-
<AlertTriangle className="w-4 h-4" /> Exploitation & Impact Risk
|
| 531 |
</h3>
|
| 532 |
-
<p className="text-on-surface-variant leading-relaxed">
|
| 533 |
{selectedThreat.impact}
|
| 534 |
</p>
|
| 535 |
</div>
|
| 536 |
|
| 537 |
-
{/* Code Remediation Terminal Box */}
|
| 538 |
-
<div className="bg-surface-container-lowest
|
| 539 |
-
<div className="flex items-center justify-between
|
| 540 |
-
<
|
| 541 |
-
<
|
| 542 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 543 |
<button
|
| 544 |
onClick={() => copyToClipboard(selectedThreat.remediation)}
|
| 545 |
-
className="flex items-center gap-1 px-
|
| 546 |
>
|
| 547 |
-
{copiedCode ? <Check className="w-
|
| 548 |
-
{copiedCode ? 'Copied
|
| 549 |
</button>
|
| 550 |
</div>
|
| 551 |
|
| 552 |
-
<div className="bg-[#
|
| 553 |
{selectedThreat.remediation}
|
| 554 |
</div>
|
| 555 |
</div>
|
| 556 |
|
| 557 |
{/* Affected Target Endpoints */}
|
| 558 |
{selectedThreat.affected_targets && selectedThreat.affected_targets.length > 0 && (
|
| 559 |
-
<div className="bg-surface-container-lowest p-
|
| 560 |
-
<h3 className="font-bold text-on-surface text-[
|
| 561 |
-
<ExternalLink className="w-4 h-4 text-primary" /> Affected Target Endpoints ({selectedThreat.affected_targets.length})
|
| 562 |
</h3>
|
| 563 |
-
<div className="flex flex-wrap gap-2">
|
| 564 |
{selectedThreat.affected_targets.map((url, idx) => (
|
| 565 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 566 |
<span className="w-2 h-2 rounded-full bg-red-500 animate-pulse"></span>
|
| 567 |
{url}
|
| 568 |
-
|
|
|
|
| 569 |
))}
|
| 570 |
</div>
|
| 571 |
</div>
|
|
@@ -573,24 +632,24 @@ const LogsAndThreats = () => {
|
|
| 573 |
</div>
|
| 574 |
|
| 575 |
{/* Modal Actions Footer */}
|
| 576 |
-
<div className="p-
|
| 577 |
<button
|
| 578 |
onClick={() => {
|
| 579 |
const query = selectedThreat.title;
|
| 580 |
setSelectedThreat(null);
|
| 581 |
openFullLogsView(query);
|
| 582 |
}}
|
| 583 |
-
className="px-
|
| 584 |
>
|
| 585 |
-
<Search className="w-4 h-4" />
|
| 586 |
Filter Audit Logs for this Threat
|
| 587 |
</button>
|
| 588 |
|
| 589 |
<button
|
| 590 |
onClick={() => setSelectedThreat(null)}
|
| 591 |
-
className="px-
|
| 592 |
>
|
| 593 |
-
Close Window
|
| 594 |
</button>
|
| 595 |
</div>
|
| 596 |
</div>
|
|
|
|
| 464 |
|
| 465 |
const renderThreatModal = () => {
|
| 466 |
if (!selectedThreat) return null;
|
| 467 |
+
|
| 468 |
+
const severityColorMap = {
|
| 469 |
+
critical: {
|
| 470 |
+
border: 'border-l-red-500',
|
| 471 |
+
banner: 'from-red-500/15 via-surface-container to-surface-container-lowest',
|
| 472 |
+
badge: 'bg-red-500/10 text-red-500 border-red-500/30',
|
| 473 |
+
glow: 'shadow-red-500/10',
|
| 474 |
+
},
|
| 475 |
+
high: {
|
| 476 |
+
border: 'border-l-orange-500',
|
| 477 |
+
banner: 'from-orange-500/15 via-surface-container to-surface-container-lowest',
|
| 478 |
+
badge: 'bg-orange-500/10 text-orange-500 border-orange-500/30',
|
| 479 |
+
glow: 'shadow-orange-500/10',
|
| 480 |
+
},
|
| 481 |
+
medium: {
|
| 482 |
+
border: 'border-l-amber-500',
|
| 483 |
+
banner: 'from-amber-500/15 via-surface-container to-surface-container-lowest',
|
| 484 |
+
badge: 'bg-amber-500/10 text-amber-500 border-amber-500/30',
|
| 485 |
+
glow: 'shadow-amber-500/10',
|
| 486 |
+
},
|
| 487 |
+
low: {
|
| 488 |
+
border: 'border-l-blue-500',
|
| 489 |
+
banner: 'from-blue-500/15 via-surface-container to-surface-container-lowest',
|
| 490 |
+
badge: 'bg-blue-500/10 text-blue-500 border-blue-500/30',
|
| 491 |
+
glow: 'shadow-blue-500/10',
|
| 492 |
+
},
|
| 493 |
+
};
|
| 494 |
+
|
| 495 |
+
const sevKey = (selectedThreat.severity || 'medium').toLowerCase();
|
| 496 |
+
const activeSev = severityColorMap[sevKey] || severityColorMap.medium;
|
| 497 |
+
|
| 498 |
return (
|
| 499 |
+
<div className="fixed inset-0 bg-slate-950/80 backdrop-blur-xl flex items-center justify-center p-4 pt-12 sm:pt-16 z-[9999] animate-fade-in overflow-y-auto">
|
| 500 |
+
<div className={`bg-surface border border-outline-variant/80 rounded-3xl max-w-3xl w-full shadow-2xl relative my-auto overflow-hidden flex flex-col max-h-[90vh] transition-all border-t-4 ${activeSev.border}`}>
|
| 501 |
|
| 502 |
+
{/* Header Banner with Premium Gradient Accent */}
|
| 503 |
+
<div className={`bg-gradient-to-r ${activeSev.banner} p-6 sm:p-7 border-b border-outline-variant/70 relative`}>
|
| 504 |
<button
|
| 505 |
onClick={() => setSelectedThreat(null)}
|
| 506 |
+
className="absolute top-5 right-5 text-on-surface-variant hover:text-on-surface bg-surface-container-high/80 hover:bg-surface-container-highest p-2 rounded-full transition-all cursor-pointer border border-outline-variant/60 shadow-2xs hover:scale-105"
|
| 507 |
+
title="Close Diagnostic Window"
|
| 508 |
>
|
| 509 |
<X className="w-5 h-5" />
|
| 510 |
</button>
|
| 511 |
|
| 512 |
+
<div className="flex items-center gap-2.5 flex-wrap mb-3.5 pr-12">
|
| 513 |
+
<span className={`px-3.5 py-1 rounded-full text-[11px] font-black uppercase tracking-wider border shadow-2xs flex items-center gap-1.5 ${getSeverityBadgeClass(selectedThreat.severity)}`}>
|
| 514 |
+
<ShieldAlert className="w-3.5 h-3.5 animate-pulse" />
|
| 515 |
{selectedThreat.severity} SEVERITY
|
| 516 |
</span>
|
| 517 |
+
<span className="bg-cyan-500/10 text-cyan-600 dark:text-cyan-400 text-[11px] font-black px-3.5 py-1 rounded-full border border-cyan-500/30 shadow-2xs font-mono">
|
| 518 |
CVSS {selectedThreat.cvss}
|
| 519 |
</span>
|
| 520 |
+
<span className="bg-red-500/10 text-red-600 dark:text-red-400 text-[11px] font-black px-3.5 py-1 rounded-full border border-red-500/30 shadow-2xs flex items-center gap-1.5">
|
| 521 |
+
<span className="w-2 h-2 rounded-full bg-red-500 animate-ping"></span>
|
| 522 |
{selectedThreat.count} Detections Recorded
|
| 523 |
</span>
|
| 524 |
</div>
|
| 525 |
|
| 526 |
+
<h2 className="text-[22px] sm:text-[24px] font-extrabold text-on-surface tracking-tight leading-snug font-display">
|
| 527 |
{selectedThreat.title}
|
| 528 |
</h2>
|
| 529 |
</div>
|
| 530 |
|
| 531 |
{/* Modal Body Scroll Container */}
|
| 532 |
+
<div className="p-6 sm:p-7 space-y-6 overflow-y-auto text-[13.5px] bg-surface">
|
| 533 |
|
| 534 |
{/* Category & OWASP Specifications Cards */}
|
| 535 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
| 536 |
+
<div className="bg-surface-container-lowest p-4.5 rounded-2xl border border-outline-variant/70 shadow-2xs flex items-start gap-3">
|
| 537 |
+
<div className="p-2.5 rounded-xl bg-primary/10 text-primary border border-primary/20 shrink-0">
|
| 538 |
+
<Layers className="w-5 h-5" />
|
| 539 |
+
</div>
|
| 540 |
+
<div>
|
| 541 |
+
<span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider block mb-0.5">
|
| 542 |
+
Vulnerability Category
|
| 543 |
+
</span>
|
| 544 |
+
<span className="font-extrabold text-on-surface text-[15px]">{selectedThreat.category}</span>
|
| 545 |
+
</div>
|
| 546 |
</div>
|
| 547 |
+
|
| 548 |
+
<div className="bg-surface-container-lowest p-4.5 rounded-2xl border border-outline-variant/70 shadow-2xs flex items-start gap-3">
|
| 549 |
+
<div className="p-2.5 rounded-xl bg-indigo-500/10 text-indigo-500 border border-indigo-500/20 shrink-0">
|
| 550 |
+
<Shield className="w-5 h-5" />
|
| 551 |
+
</div>
|
| 552 |
+
<div>
|
| 553 |
+
<span className="text-[11px] font-bold text-on-surface-variant uppercase tracking-wider block mb-0.5">
|
| 554 |
+
OWASP Standard Compliance
|
| 555 |
+
</span>
|
| 556 |
+
<span className="font-extrabold text-indigo-500 text-[14.5px]">{selectedThreat.owasp}</span>
|
| 557 |
+
</div>
|
| 558 |
</div>
|
| 559 |
</div>
|
| 560 |
|
| 561 |
{/* Threat Overview Card */}
|
| 562 |
+
<div className="bg-surface-container-lowest p-5 rounded-2xl border-l-4 border-l-primary border border-outline-variant/70 shadow-2xs">
|
| 563 |
+
<h3 className="font-bold text-on-surface text-[14.5px] mb-2 flex items-center gap-2">
|
| 564 |
+
<Shield className="w-4.5 h-4.5 text-primary" /> Vulnerability Overview & Technical Details
|
| 565 |
</h3>
|
| 566 |
+
<p className="text-on-surface-variant leading-relaxed text-[14px]">
|
| 567 |
{selectedThreat.description}
|
| 568 |
</p>
|
| 569 |
</div>
|
| 570 |
|
| 571 |
{/* Security Impact Card */}
|
| 572 |
+
<div className="bg-surface-container-lowest p-5 rounded-2xl border-l-4 border-l-amber-500 border border-outline-variant/70 shadow-2xs">
|
| 573 |
+
<h3 className="font-bold text-amber-600 dark:text-amber-400 text-[14.5px] mb-2 flex items-center gap-2">
|
| 574 |
+
<AlertTriangle className="w-4.5 h-4.5" /> Exploitation & Impact Risk Analysis
|
| 575 |
</h3>
|
| 576 |
+
<p className="text-on-surface-variant leading-relaxed text-[14px]">
|
| 577 |
{selectedThreat.impact}
|
| 578 |
</p>
|
| 579 |
</div>
|
| 580 |
|
| 581 |
+
{/* Code Remediation Terminal Box (IDE Style) */}
|
| 582 |
+
<div className="bg-surface-container-lowest rounded-2xl border border-outline-variant/70 shadow-2xs overflow-hidden">
|
| 583 |
+
<div className="bg-surface-container-high/80 px-4 py-3 border-b border-outline-variant/60 flex items-center justify-between">
|
| 584 |
+
<div className="flex items-center gap-2">
|
| 585 |
+
<div className="flex items-center gap-1.5 mr-2">
|
| 586 |
+
<span className="w-3 h-3 rounded-full bg-red-500/80 inline-block"></span>
|
| 587 |
+
<span className="w-3 h-3 rounded-full bg-amber-500/80 inline-block"></span>
|
| 588 |
+
<span className="w-3 h-3 rounded-full bg-green-500/80 inline-block"></span>
|
| 589 |
+
</div>
|
| 590 |
+
<h3 className="font-bold text-on-surface text-[13px] flex items-center gap-2 font-mono">
|
| 591 |
+
<Terminal className="w-4 h-4 text-green-500" /> Recommended Security Fix
|
| 592 |
+
</h3>
|
| 593 |
+
</div>
|
| 594 |
+
|
| 595 |
<button
|
| 596 |
onClick={() => copyToClipboard(selectedThreat.remediation)}
|
| 597 |
+
className="flex items-center gap-1.5 px-3 py-1.5 bg-surface-container hover:bg-surface-container-highest text-on-surface rounded-lg text-[12px] font-bold border border-outline-variant/80 cursor-pointer transition-all active:scale-95 shadow-2xs"
|
| 598 |
>
|
| 599 |
+
{copiedCode ? <Check className="w-4 h-4 text-green-500" /> : <Copy className="w-4 h-4 text-primary" />}
|
| 600 |
+
{copiedCode ? 'Copied to Clipboard' : 'Copy Code Snippet'}
|
| 601 |
</button>
|
| 602 |
</div>
|
| 603 |
|
| 604 |
+
<div className="bg-[#0a0f1d] text-[#38bdf8] font-mono text-[13px] p-4.5 leading-relaxed overflow-x-auto whitespace-pre-wrap selection:bg-primary/30 selection:text-white">
|
| 605 |
{selectedThreat.remediation}
|
| 606 |
</div>
|
| 607 |
</div>
|
| 608 |
|
| 609 |
{/* Affected Target Endpoints */}
|
| 610 |
{selectedThreat.affected_targets && selectedThreat.affected_targets.length > 0 && (
|
| 611 |
+
<div className="bg-surface-container-lowest p-5 rounded-2xl border border-outline-variant/70 shadow-2xs">
|
| 612 |
+
<h3 className="font-bold text-on-surface text-[14.5px] mb-3 flex items-center gap-2">
|
| 613 |
+
<ExternalLink className="w-4.5 h-4.5 text-primary" /> Affected Target Endpoints ({selectedThreat.affected_targets.length})
|
| 614 |
</h3>
|
| 615 |
+
<div className="flex flex-wrap gap-2.5">
|
| 616 |
{selectedThreat.affected_targets.map((url, idx) => (
|
| 617 |
+
<a
|
| 618 |
+
key={idx}
|
| 619 |
+
href={url}
|
| 620 |
+
target="_blank"
|
| 621 |
+
rel="noopener noreferrer"
|
| 622 |
+
className="bg-surface-container border border-outline-variant/80 hover:border-primary/50 text-on-surface font-mono text-[12px] px-3.5 py-2 rounded-xl flex items-center gap-2 font-medium transition-all hover:scale-[1.01]"
|
| 623 |
+
>
|
| 624 |
<span className="w-2 h-2 rounded-full bg-red-500 animate-pulse"></span>
|
| 625 |
{url}
|
| 626 |
+
<ExternalLink className="w-3.5 h-3.5 opacity-50 ml-1" />
|
| 627 |
+
</a>
|
| 628 |
))}
|
| 629 |
</div>
|
| 630 |
</div>
|
|
|
|
| 632 |
</div>
|
| 633 |
|
| 634 |
{/* Modal Actions Footer */}
|
| 635 |
+
<div className="p-5 bg-surface-container-lowest border-t border-outline-variant/80 flex items-center justify-between flex-wrap gap-3">
|
| 636 |
<button
|
| 637 |
onClick={() => {
|
| 638 |
const query = selectedThreat.title;
|
| 639 |
setSelectedThreat(null);
|
| 640 |
openFullLogsView(query);
|
| 641 |
}}
|
| 642 |
+
className="px-5 py-3 bg-primary/10 hover:bg-primary/20 text-primary border border-primary/30 rounded-xl font-bold text-[13.5px] flex items-center gap-2 cursor-pointer transition-all active:scale-95 shadow-2xs"
|
| 643 |
>
|
| 644 |
+
<Search className="w-4.5 h-4.5" />
|
| 645 |
Filter Audit Logs for this Threat
|
| 646 |
</button>
|
| 647 |
|
| 648 |
<button
|
| 649 |
onClick={() => setSelectedThreat(null)}
|
| 650 |
+
className="px-7 py-3 bg-primary text-white hover:brightness-110 rounded-xl font-bold text-[13.5px] cursor-pointer border-0 shadow-lg shadow-primary/25 transition-all active:scale-95"
|
| 651 |
>
|
| 652 |
+
Close Diagnostic Window
|
| 653 |
</button>
|
| 654 |
</div>
|
| 655 |
</div>
|