Build a collaborative threat modeling portal with code integration: asset cataloging,…
- User
Build a collaborative threat modeling portal with code integration: asset cataloging, STRIDE automation, mitigation tracking, and governance.
- Assistant
Build a collaborative threat modeling portal with code integration: asset cataloging, STRIDE automation, mitigation tracking, and governance.
Here's a thinking process that leads to the provided HTML solution:
Analyze the Request:
Deconstruct the UI/UX for a Threat Modeling Portal:
Apply the Neo-Brutalism / Y2K Aesthetic:
box-shadow: 4px 4px 0px #000.clip-path or transforms).Drafting the Structure (HTML):
header: Logo (text based), Navigation (tabs), Status Marquee.main:
section#dashboard: Large stat cards.section#assets: Table/List of assets with "Add Asset" form.section#stride: Form to select asset -> generate threats table.section#mitigations: Kanban-style or table for tracking.section#governance: Simple audit log view.footer: Credits/Status.dialog: Modals for adding data.Tailwind Setup (via CDN):
lime-400 or custom hex #ccff00. For "Hot Pink", fuchsia-500. I'll stick to Tailwind's utility classes mostly, but might need some custom CSS for specific glitch effects.JavaScript Logic (Vue-like but in Vanilla JS):
store holding assets, threats, mitigations, audit logs.renderAssets(), renderSTRIDE(), renderMitigations(), logEvent().Step-by-Step Implementation details:
Global Styles:
body { font-family: 'Courier New', monospace; background: #f0f0f0; color: #000; }
.hard-border { border: 3px solid #000; }
.hard-shadow { box-shadow: 6px 6px 0px 0px #000; }
.chunky-btn { transition: all 0.1s; }
.chunky-btn:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0px 0px #000; }
Glitch Effect (CSS):
Keyframes shifting background position, or clip-path. I'll do a simple RGB shift with text-shadows on hover.
Marquee:
CSS animation translateX from 0 to -100%.
Data Model (Mock):
const state = {
assets: [
{ id: 1, name: "Core DB", type: "DATABASE", ip: "10.0.0.5", owner: "DBA" },
{ id: 2, name: "API Gateway", type: "SERVICE", ip: "10.0.0.1", owner: "DevOps" }
],
threats: [], // will be populated
mitigations: []
};
STRIDE Logic: When an asset is selected, generate a list of standard threat suggestions based on asset type.
GSAP Integration:
Use gsap.from to animate elements when tabs switch.
Refining the Aesthetic (Self-Correction during thought process):
bg-[#e0e0e0] (concrete gray) to make the white panels pop with heavy borders.text-6xl).Writing the Code (Mental Draft & Assembly):
Polishing the "Edge":
border-3 or border-4 (using border-[4px] in Tailwind).mix-blend-mode on overlapping badges.Final Code Structure Review:
<style>.<script>.Generating the Response: (Proceeding to generate the HTML string with the requested characteristics). Self-correction: The user asked for "collaborative threat modeling portal". I need to simulate "collaborative" features like assigning users to mitigations or showing "last updated" timestamps.
Implementation Details Specifics:
clip-path.Final Polish: Ensure all JS works (no syntax errors). Check tab switching logic.
(Self-Correction during coding): Tailwind via CDN is large and sometimes FOUC. I'll accept that for this demo.
I will implement a "Matrix/Rain" canvas effect in the background but keep it subtle (opacity-20) so it doesn't interfere with readability.
Let's write the code. Here is a complete, self-contained HTML file implementing a Neo-Brutalism / Y2K styled Collaborative Threat Modeling Portal.
This solution includes:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>THREAT.MODELER // PROTOCOL</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- GSAP Animation -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/SteppedEase.min.js"></script>
<!-- Configuration for Custom Colors/Fonts -->
<script>
tailwind.config = {
theme: {
extend: {
colors: {
'acid-green': '#ccff00',
'neon-pink': '#ff00ff',
'cyber-blue': '#00ffff',
'deep-y2k': '#6600cc',
'crash-black': '#0a0a0a',
'concrete': '#e5e5e5',
},
fontFamily: {
'raw': ['"Courier New"', 'Courier', 'monospace'],
'display': ['"Impact"', 'Arial Black', 'sans-serif'],
},
boxShadow: {
'hard': '6px 6px 0px 0px #000000',
'hard-sm': '3px 3px 0px 0px #000000',
'hard-hover': '2px 2px 0px 0px #000000',
},
borderWidth: {
'raw': '4px',
}
}
}
}
</script>
<style>
/* Custom Global Styles */
body {
background-color: #f0f0f0;
color: #000;
overflow-x: hidden;
font-family: 'Courier New', monospace;
cursor: crosshair;
}
/* CRT/Scanline Overlay */
.scanlines {
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
background-size: 100% 4px;
pointer-events: none;
z-index: 50;
}
/* Glitch Effect */
.glitch-text {
position: relative;
}
.glitch-text::before,
.glitch-text::after {
content: attr(data-text);
position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
background: #f0f0f0;
}
.glitch-text::before {
left: 2px;
text-shadow: -1px 0 #ff00ff;
clip: rect(44px, 450px, 56px, 0);
animation: glitch-anim 5s infinite linear alternate-reverse;
}
.glitch-text::after {
left: -2px;
text-shadow: -1px 0 #00ffff;
clip: rect(44px, 450px, 56px, 0);
animation: glitch-anim2 5s infinite linear alternate-reverse;
}
@keyframes glitch-anim {
0% { clip: rect(30px, 9999px, 10px, 0); }
5% { clip: rect(80px, 9999px, 100px, 0); }
10% { clip: rect(10px, 9999px, 40px, 0); }
15% { clip: rect(60px, 9999px, 20px, 0); }
20% { clip: rect(20px, 9999px, 50px, 0); }
100% { clip: rect(70px, 9999px, 90px, 0); }
}
@keyframes glitch-anim2 {
0% { clip: rect(10px, 9999px, 80px, 0); }
5% { clip: rect(50px, 9999px, 10px, 0); }
10% { clip: rect(90px, 9999px, 20px, 0); }
15% { clip: rect(20px, 9999px, 60px, 0); }
20% { clip: rect(50px, 9999px, 30px, 0); }
100% { clip: rect(10px, 9999px, 50px, 0); }
}
/* Marquee */
.marquee-container {
overflow: hidden;
white-space: nowrap;
background: #000;
color: #ccff00;
border-bottom: 4px solid #000;
font-weight: bold;
font-size: 0.9rem;
}
.marquee-content {
display: inline-block;
animation: marquee 20s linear infinite;
}
@keyframes marquee {
0% { transform: translateX(100vw); }
100% { transform: translateX(-100%); }
}
/* Raw Buttons */
.btn-raw {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.75rem 1.5rem;
font-family: 'Impact', sans-serif;
font-size: 1.25rem;
text-transform: uppercase;
border: 4px solid #000;
box-shadow: 4px 4px 0 #000;
transition: all 0.1s ease;
cursor: pointer;
background: #fff;
color: #000;
}
.btn-raw:hover {
transform: translate(-2px, -2px);
box-shadow: 6px 6px 0 #000;
}
.btn-raw:active {
transform: translate(2px, 2px);
box-shadow: 0px 0px 0 #000;
}
.btn-acid { background: #ccff00; color: #000; }
.btn-pink { background: #ff00ff; color: #fff; }
.btn-blue { background: #00ffff; color: #000; }
.btn-red { background: #ff3333; color: #fff; }
/* Tab styling */
.tab-btn {
width: 100%;
text-align: left;
border-right: 4px solid transparent;
padding: 1rem;
font-weight: bold;
text-transform: uppercase;
}
.tab-btn.active {
background: #fff;
border-right-color: #ff00ff;
box-shadow: 4px 0 0 0 #000 inset;
}
/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; background: #000; }
::-webkit-scrollbar-thumb { background: #ccff00; border: 2px solid #000; }
::-webkit-scrollbar-track { background: #000; }
.card-raw {
background: #fff;
border: 4px solid #000;
margin-bottom: 1.5rem;
position: relative;
}
.card-raw::after {
content: '';
position: absolute;
top: 4px; left: 4px; width: 100%; height: 100%;
border: 1px dashed #ccc;
z-index: 0;
pointer-events: none;
}
.card-content {
position: relative;
z-index: 1;
}
.badge-raw {
display: inline-block;
padding: 2px 8px;
border: 2px solid #000;
font-size: 0.75rem;
font-weight: bold;
text-transform: uppercase;
background: #ccc;
}
.threat-critical { background: #ff3333; color: #fff; }
.threat-high { background: #ff9900; color: #000; }
.threat-medium { background: #ffff00; color: #000; }
.threat-low { background: #00ff00; color: #000; }
/* Input */
input, select, textarea {
border: 3px solid #000;
background: #fff;
padding: 0.5rem;
font-family: 'Courier New', monospace;
font-weight: bold;
width: 100%;
outline: none;
}
input:focus {
background: #ffffcc;
border-color: #ff00ff;
}
/* Canvas */
#noise-canvas {
position: fixed;
top: 0; left: 0;
width: 100%; height: 100%;
z-index: -1;
opacity: 0.15;
mix-blend-mode: multiply;
}
</style>
</head>
<body>
<!-- Background Noise Canvas -->
<canvas id="noise-canvas"></canvas>
<!-- Scanlines -->
<div class="scanlines"></div>
<!-- Marquee Alert -->
<div class="marquee-container">
<div class="marquee-content">
SYSTEM ALERT: UNAUTHORIZED ACCESS DETECTED IN SECTOR 7G // REAL-TIME THREAT MODELING ACTIVE // REFRESHING SIGNATURES... // PLEASE REPORT SUSPICIOUS ACTIVITY // THIS TERMINAL IS MONITORED //
</div>
</div>
<div class="flex min-h-screen max-w-[1600px] mx-auto border-x-4 border-black bg-[#e0e0e0]">
<!-- SIDEBAR NAV -->
<nav class="w-80 bg-black text-white flex flex-col shrink-0 z-10">
<div class="p-6 border-b-4 border-white">
<h1 class="font-display text-4xl leading-none text-acid-green glitch-text" data-text="THREAT.MODELER">
THREAT.MODELER
</h1>
<p class="text-xs mt-2 text-gray-400">V.3.1.0 [COLLABORATIVE]</p>
</div>
<div class="flex-1 py-4">
<button class="tab-btn active" data-target="dashboard">
<span class="mr-2">[01]</span> DASHBOARD
</button>
<button class="tab-btn" data-target="assets">
<span class="mr-2">[02]</span> ASSET CATALOG
</button>
<button class="tab-btn" data-target="stride">
<span class="mr-2">[03]</span> STRIDE AUTO
</button>
<button class="tab-btn" data-target="mitigations">
<span class="mr-2">[04]</span> MITIGATION TRACKER
</button>
<button class="tab-btn" data-target="governance">
<span class="mr-2">[05]</span> GOVERNANCE & AUDIT
</button>
</div>
<div class="p-4 border-t-4 border-white bg-gray-900">
<div class="flex items-center gap-2 mb-2">
<div class="w-3 h-3 bg-acid-green rounded-full animate-pulse"></div>
<span class="text-xs">CONN: ESTABLISHED</span>
</div>
<p class="text-[10px] text-gray-500">USER: ADMIN@CORE</p>
<p class="text-[10px] text-gray-500">ROLE: ARCHITECT</p>
</div>
</nav>
<!-- MAIN CONTENT -->
<main class="flex-1 border-l-4 border-black relative bg-[#f4f4f4] shadow-[10px_0_0_0_#000] z-0 overflow-y-auto">
<!-- Top Bar -->
<header class="sticky top-0 bg-[#f4f4f4] border-b-4 border-black p-4 flex justify-between items-center z-10">
<h2 id="page-title" class="text-3xl font-display uppercase tracking-tighter border-b-4 border-black inline-block pb-1">
DASHBOARD
</h2>
<div class="flex gap-3">
<button class="btn-raw btn-acid border-2 text-sm" onclick="generateRandomThreat()">
SIMULATE ATTACK
</button>
<button class="btn-raw btn-red border-2 text-sm" onclick="triggerSystemCrash()">
CRASH SYSTEM
</button>
</div>
</header>
<!-- VIEW: DASHBOARD -->
<section id="view-dashboard" class="p-6 section">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
<!-- KPI Cards -->
<div class="card-raw p-6 bg-white relative overflow-hidden group">
<div class="absolute top-0 right-0 p-2 bg-black text-white text-xs font-bold rotate-12 translate-x-2 -translate-y-2">TOTAL</div>
<p class="text-sm font-bold uppercase mb-2">Assets Owned</p>
<p class="text-6xl font-display" id="dash-assets-count">0</p>
<div class="h-2 w-full bg-black mt-4">
<div class="h-full bg-acid-green w-[75%]"></div>
</div>
</div>
<div class="card-raw p-6 bg-[#00ffff] group">
<div class="absolute top-0 right-0 p-2 bg-black text-white text-xs font-bold rotate-12 translate-x-2 -translate-y-2">THREATS</div>
<p class="text-sm font-bold uppercase mb-2">STRIDE Identified</p>
<p class="text-6xl font-display text-black" id="dash-threats-count">0</p>
<div class="mt-4 text-xs font-bold uppercase text-right animate-pulse">LIVE FEED</div>
</div>
<div class="card-raw p-6 bg-[#ff00ff] group">
<div class="absolute top-0 right-0 p-2 bg-black text-white text-xs font-bold rotate-12 translate-x-2 -translate-y-2">RISK</div>
<p class="text-sm font-bold uppercase mb-2 text-white">Critical Mitigations</p>
<p class="text-6xl font-display text-white" id="dash-critical-count">0</p>
<div class="mt-4 border-2 border-white p-1 text-xs font-bold text-center text-white bg-black">ACTION REQUIRED</div>
</div>
<div class="card-raw p-6 bg-[#ccff00] group">
<div class="absolute top-0 right-0 p-2 bg-black text-white text-xs font-bold rotate-12 translate-x-2 -translate-y-2">GOV</div>
<p class="text-sm font-bold uppercase mb-2">Compliance Score</p>
<p class="text-6xl font-display text-black">82%</p>
</div>
</div>
<div class="mt-8 grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Recent Audit Log -->
<div class="card-raw p-0 lg:col-span-1">
<div class="bg-black text-acid-green px-4 py-2 font-bold uppercase">LIVE AUDIT TRAIL</div>
<ul class="p-4 font-raw text-sm space-y-3" id="dash-audit-list">
<!-- Populated by JS -->
</ul>
</div>
<!-- Graphical Representation (CSS Only Rough) -->
<div class="card-raw p-6 lg:col-span-2">
<div class="border-b-4 border-black pb-2 mb-4 flex justify-between items-end">
<span class="font-bold uppercase">THREAT LANDSCAPE</span>
<span class="text-xs font-raw">SOURCE: CLOUD_SENSOR</span>
</div>
<div class="flex items-end justify-between h-48 gap-2 px-2">
<div class="w-1/5 bg-acid-green border-4 border-b-0 border-black relative group hover:bg-white transition-colors">
<div class="h-1/2 w-full border-b-4 border-black"></div>
<span class="absolute -top-6 left-1/2 -translate-x-1/2 text-xs font-bold whitespace-nowrap">SPOOF</span>
</div>
<div class="w-1/5 bg-neon-pink border-4 border-b-0 border-black relative group hover:bg-white">
<div class="h-3/4 w-full border-b-4 border-black"></div>
<span class="absolute -top-6 left-1/2 -translate-x-1/2 text-xs font-bold whitespace-nowrap">TAMPER</span>
</div>
<div class="w-1/5 bg-cyber-blue border-4 border-b-0 border-black relative group hover:bg-white">
<div class="h-1/3 w-full border-b-4 border-black"></div>
<span class="absolute -top-6 left-1/2 -translate-x-1/2 text-xs font-bold whitespace-nowrap">REPUD</span>
</div>
<div class="w-1/5 bg-deep-y2k border-4 border-b-0 border-black relative group hover:bg-white">
<div class="h-5/6 w-full border-b-4 border-black"></div>
<span class="absolute -top-6 left-1/2 -translate-x-1/2 text-xs font-bold whitespace-nowrap">INFO</span>
</div>
<div class="w-1/5 bg-red-600 border-4 border-b-0 border-white relative group hover:bg-white">
<div class="h-[90%] w-full border-b-4 border-black"></div>
<span class="absolute -top-6 left-1/2 -translate-x-1/2 text-xs font-bold whitespace-nowrap">DOS</span>
</div>
</div>
<p class="text-xs mt-2 font-raw italic">WARNING: ELEVATION OF PRIVILEGE DETECTED IN LOGS.</p>
</div>
</div>
</section>
<!-- VIEW: ASSETS -->
<section id="view-assets" class="p-6 section hidden">
<div class="flex justify-between items-center mb-6">
<h3 class="font-display text-2xl underline">ASSET REGISTRY</h3>
<button class="btn-raw btn-acid" onclick="toggleAssetForm()">+ NEW ASSET</button>
</div>
<!-- Form Overlay (Hidden Toggle) -->
<div id="asset-form-container" class="hidden mb-8 card-raw p-6 bg-[#ffffcc] animate-bounce-once">
<h4 class="font-bold text-lg mb-4 border-b-2 border-black pb-2">REGISTER NEW ASSET</h4>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="text-xs font-bold uppercase">Asset Name</label>
<input type="text" id="new-asset-name" placeholder="e.g. Main DB Cluster">
</div>
<div>
<label class="text-xs font-bold uppercase">Asset Type</label>
<select id="new-asset-type" class="bg-gray-100">
<option value="SERVICE">SERVICE</option>
<option value="DATABASE">DATABASE</option>
<option value="INFRA">INFRASTRUCTURE</option>
<option value="ENDPOINT">ENDPOINT</option>
</select>
</div>
<div>
<label class="text-xs font-bold uppercase">IP Address / Hostname</label>
<input type="text" id="new-asset-ip" placeholder="192.168.1.1">
</div>
<div>
<label class="text-xs font-bold uppercase">Owner Team</label>
<input type="text" id="new-asset-owner" placeholder="DevOps">
</div>
</div>
<div class="flex gap-2">
<button class="btn-raw btn-blue" onclick="addAsset()">SAVE RECORD</button>
<button class="btn-raw bg-gray-300 border-black" onclick="toggleAssetForm()">CANCEL</button>
</div>
</div>
<!-- Table -->
<div class="card-raw overflow-hidden bg-white">
<table class="w-full text-left font-raw">
<thead class="bg-black text-white uppercase">
<tr>
<th class="p-4 border-b-4 border-white">ID</th>
<th class="p-4 border-b-4 border-white">Name</th>
<th class="p-4 border-b-4 border-white">Type</th>
<th class="p-4 border-b-4 border-white">IP</th>
<th class="p-4 border-b-4 border-white">Owner</th>
<th class="p-4 border-b-4 border-white text-center">THREATS</th>
<th class="p-4 border-b-4 border-white">ACTION</th>
</tr>
</thead>
<tbody id="assets-table-body">
<!-- Rows generated by JS -->
</tbody>
</table>
</div>
</section>
<!-- VIEW: STRIDE -->
<section id="view-stride" class="p-6 section hidden">
<div class="mb-6 card-raw p-4 bg-[#ff00ff] text-white">
<h3 class="font-display text-2xl uppercase mb-2">STRIDE AUTOMATION ENGINE</h3>
<p class="text-sm font-raw opacity-90">Select an asset to automatically generate threat scenarios based on the STRIDE classification model. System analyzes data flow dependencies in real-time.</p>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Asset Selector -->
<div class="lg:col-span-1">
<div class="card-raw p-4 h-full">
<h4 class="font-bold border-b-4 border-black mb-4 pb-2">SELECT TARGET</h4>
<select id="stride-asset-select" class="mb-4 bg-white" onchange="generateSTRIDEThreats()">
<option value="">-- Choose Asset --</option>
<!-- Populated JS -->
</select>
<div id="stride-selected-info" class="hidden mt-4 p-4 bg-black text-white font-raw text-xs">
<p><strong>IP:</strong> <span id="info-ip"></span></p>
<p><strong>TYPE:</strong> <span id="info-type"></span></p>
</div>
<button id="btn-run-scan" class="btn-raw w-full mt-4 btn-acid" disabled onclick="generateSTRIDEThreats()">
RUN ANALYSIS
</button>
</div>
</div>
<!-- Results Area -->
<div class="lg:col-span-2">
<div id="stride-results" class="space-y-4">
<div class="p-8 text-center border-4 border-dashed border-black text-gray-500 font-raw">
NO THREAT MODEL GENERATED. SELECT AN ASSET AND RUN ANALYSIS.
</div>
</div>
</div>
</div>
</section>
<!-- VIEW: MITIGATIONS -->
<section id="view-mitigations" class="p-6 section hidden">
<div class="flex justify-between items-center mb-6">
<h3 class="font-display text-2xl underline">MITIGATION TRACKER</h3>
<div class="flex gap-2">
<button class="btn-raw bg-gray-300 border-2 text-sm" onclick="renderMitigations()">REFRESH</button>
</div>
</div>
<div class="card-raw overflow-hidden bg-white p-2">
<table class="w-full text-left font-raw">
<thead class="bg-acid-green border-b-4 border-black">
<tr>
<th class="p-3 text-center">Priority</th>
<th class="p-3">Threat</th>
<th class="p-3">Target Asset</th>
<th class="p-3">Mitigation</th>
<th class="p-3">Owner</th>
<th class="p-3 text-center">Status</th>
<th class="p-3">Action</th>
</tr>
</thead>
<tbody id="mitigations-table-body">
<!-- JS Populated -->
</tbody>
</table>
</div>
</section>
<!-- VIEW: GOVERNANCE -->
<section id="view-governance" class="p-6 section hidden">
<div class="mb-8 card-raw p-6 bg-[#000] text-[#00ff00] font-raw">
<h3 class="text-xl mb-4 font-bold border-b-2 border-[#00ff00]">SYSTEM COMPLIANCE LOG</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
<div>
<span class="block text-gray-500 uppercase">Framework</span>
ISO 27001:2022
</div>
<div>
<span class="block text-gray-500 uppercase">Last Policy Pull</span>
2023-10-27 04:00:00 UTC
</div>
<div>
<span class="block text-gray-500 uppercase">Risk Acceptance</span>
3 items pending CISO
</div>
</div>
</div>
<div class="card-raw bg-white">
<div class="bg-black text-white px-4 py-2 font-bold uppercase flex justify-between">
<span>AUDIT HISTORY</span>
<span>FIRST 50 RECORDS</span>
</div>
<div class="max-h-96 overflow-y-auto font-raw text-sm">
<table class="w-full border-collapse">
<thead class="bg-gray-200 sticky top-0">
<tr>
<th class="p-2 border-b-2 border-black text-left">Timestamp</th>
<th class="p-2 border-b-2 border-black text-left">User</th>
<th class="p-2 border-b-2 border-black text-left">Action</th>
<th class="p-2 border-b-2 border-black text-left">Target</th>
<th class="p-2 border-b-2 border-black text-left">IP</th>
</tr>
</thead>
<tbody id="governance-table-body">
<!-- Populated JS -->
</tbody>
</table>
</div>
</div>
</section>
</main>
</div>
<!-- Notification Toast -->
<div id="toast" class="fixed bottom-5 right-5 bg-black text-acid-green border-4 border-acid-green p-4 font-raw text-sm transform translate-y-20 transition-transform z-50">
>> SYSTEM MESSAGE
</div>
<script>
// --- STATE MANAGEMENT ---
const store = {
assets: [
{ id: 'A-1001', name: 'CORE_DB_CLUSTER', type: 'DATABASE', ip: '10.10.1.5', owner: 'DBA', threats: 3 },
{ id: 'A-1002', name: 'PAYMENT_GATEWAY', type: 'SERVICE', ip: '10.20.5.12', owner: 'Backend', threats: 2 },
{ id: 'A-1003', name: 'USER_AUTH_SVC', type: 'SERVICE', ip: '10.20.5.20', owner: 'SecEng', threats: 5 },
{ id: 'A-1004', name: 'WORKSTATION_01', type: 'ENDPOINT', ip: '192.168.0.101', owner: 'Alice', threats: 0 },
{ id: 'A-1005', name: 'BACKUP_S3_BUCKET', type: 'INFRA', ip: 's3.amazon.com', owner: 'DevOps', threats: 1 },
],
threats: [
{ id: 'T-001', assetId: 'A-1002', category: 'Spoofing', title: 'API Key Theft', severity: 'High', status: 'Mitigated' },
{ id: 'T-002', assetId: 'A-1003', category: 'Tampering', title: 'JWT Token Manipulation', severity: 'Critical', status: 'Open' },
{ id: 'T-003', assetId: 'A-1001', category: 'Information Disclosure', title: 'SQL Injection', severity: 'Critical', status: 'Open' },
{ id: 'T-004', assetId: 'A-1001', category: 'Denial of Service', title: 'Query Flood', severity: 'Medium', status: 'Mitigated' },
{ id: 'T-005', assetId: 'A-1003', category: 'Elevation of Privilege', title: 'Missing RBAC', severity: 'High', status: 'Open' },
],
mitigations: [
{ id: 'M-001', threatId: 'T-002', text: 'Implement JWT signature validation (RS256)', owner: 'SecEng', status: 'In Progress' },
{ id: 'M-002', threatId: 'T-003', text: 'Parameterized queries', owner: 'DBA', status: 'Done' },
{ id: 'M-003', threatId: 'T-005', text: 'Add role checks on /admin routes', owner: 'Backend', status: 'Open' },
],
auditLog: [
{ ts: new Date().toLocaleString(), user: 'SYSTEM', action: 'SYSTEM BOOT', ip: '127.0.0.1' },
{ ts: new Date().toLocaleString(), user: 'ADMIN', action: 'LOGIN', ip: '10.0.0.45' },
{ ts: new Date().toLocaleString(), user: 'ADMIN', action: 'VIEWED ASSET A-1001', ip: '10.0.0.45' },
]
};
// --- NOISE CANVAS ---
function initNoise() {
const canvas = document.getElementById('noise-canvas');
const ctx = canvas.getContext('2d');
const resize = () => { canvas.width = window.innerWidth; canvas.height = window.innerHeight; };
window.addEventListener('resize', resize);
resize();
function loop() {
const w = canvas.width; const h = canvas.height;
const idata = ctx.createImageData(w, h);
const buffer32 = new Uint32Array(idata.data.buffer);
const len = buffer32.length;
for (let i = 0; i < len; i++) {
if (Math.random() < 0.1) {
buffer32[i] = 0xff000000 | (Math.random()*255 << 16) | (Math.random()*255 << 8) | Math.random()*255;
}
}
ctx.putImageData(idata, 0, 0);
requestAnimationFrame(loop);
}
loop();
}
// --- NAVIGATION LOGIC ---
const tabs = document.querySelectorAll('.tab-btn');
const sections = document.querySelectorAll('.section');
const titleEl = document.getElementById('page-title');
function switchTab(targetId) {
// Update active tab
tabs.forEach(t => t.classList.remove('active'));
document.querySelector(`[data-target="${targetId}"]`).classList.add('active');
// Hide all, show target
sections.forEach(s => {
if (s.id === `view-${targetId}`) {
s.classList.remove('hidden');
// GSAP entrance
gsap.fromTo(s, { opacity: 0, y: 20 }, { opacity: 1, y: 0, duration: 0.4, ease: "power2.out" });
} else {
s.classList.add('hidden');
}
});
// Update title with glitch trigger
const newTitle = targetId.toUpperCase(); // Simple mapping
// In a real app we'd map specific titles
let titleText = "DASHBOARD";
if(targetId === 'assets') titleText = "ASSET CATALOG";
if(targetId === 'stride') titleText = "STRIDE ENGINE";
if(targetId === 'mitigations') titleText = "MITIGATION TRACKER";
if(targetId === 'governance') titleText = "GOVERNANCE LOG";
// Glitch effect on title change
titleEl.innerText = titleText;
titleEl.style.animation = 'none';
void titleEl.offsetWidth; // trigger reflow
titleEl.style.animation = 'glitch-anim 0.3s infinite';
setTimeout(() => titleEl.style.animation = '', 300);
}
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const target = tab.getAttribute('data-target');
switchTab(target);
});
});
// --- DATA RENDERING ---
function getStats() {
document.getElementById('dash-assets-count').innerText = store.assets.length;
document.getElementById('dash-threats-count').innerText = store.threats.length;
const critical = store.threats.filter(t => t.severity === 'Critical' || t.severity === 'High' && t.status === 'Open').length;
document.getElementById('dash-critical-count').innerText = critical;
}
function renderAssetsTable() {
const tbody = document.getElementById('assets-table-body');
tbody.innerHTML = '';
store.assets.forEach(asset => {
const tr = document.createElement('tr');
tr.className = "border-b-2 border-black hover:bg-[#ffffcc] transition-colors";
// Count threats for this asset
const threatCount = store.threats.filter(t => t.assetId === asset.id).length;
const displayCount = threatCount > 0 ? `<span class="bg-red-600 text-white font-bold px-2 py-1 text-xs border-2 border-black">${threatCount}</span>` : '<span class="text-gray-400">0</span>';
tr.innerHTML = `
<td class="p-3 font-raw text-sm text-gray-600">${asset.id}</td>
<td class="p-3 font-bold">${asset.name}</td>
<td class="p-3"><span class="badge-raw bg-blue-100">${asset.type}</span></td>
<td class="p-3 font-raw">${asset.ip}</td>
<td class="p-3 font-raw">${asset.owner}</td>
<td class="p-3 text-center">${displayCount}</td>
<td class="p-3">
<button class="btn-raw text-xs py-1 px-2 bg-gray-200" onclick="scanAsset('${asset.id}')">SCAN</button>
</td>
`;
tbody.appendChild(tr);
});
// Update select options in Stride view
const select = document.getElementById('stride-asset-select');
select.innerHTML = '<option value="">-- Choose Asset --</option>';
store.assets.forEach(a => {
const opt = document.createElement('option');
opt.value = a.id;
opt.innerText = `${a.name} (${a.type})`;
select.appendChild(opt);
});
getStats();
}
function renderMitigations() {
const tbody = document.getElementById('mitigations-table-body');
tbody.innerHTML = '';
// Join threats with mitigations
store.mitigations.forEach(mit => {
const threat = store.threats.find(t => t.id === mit.threatId);
if (!threat) return;
const tr = document.createElement('tr');
tr.className = "border-b-2 border-black bg-white hover:bg-[#ccffcc]";
let badgeClass = 'bg-red-200 text-red-800';
if(threat.severity === 'Medium') badgeClass = 'bg-yellow-200 text-yellow-800';
if(threat.severity === 'Low') badgeClass = 'bg-green-200 text-green-800';
let statusClass = 'bg-gray-200';
if(mit.status === 'Done') statusClass = 'bg-acid-green text-black';
if(mit.status === 'In Progress') statusClass = 'bg-cyber-blue text-black';
tr.innerHTML = `
<td class="p-3 text-center">
<span class="badge-raw text-xs ${badgeClass}">${threat.severity.toUpperCase()}</span>
</td>
<td class="p-3 font-bold text-sm">${threat.title}</td>
<td class="p-3 font-raw text-xs">${threat.assetId}</td>
<td class="p-3 font-raw text-sm">${mit.text}</td>
<td class="p-3 font-raw text-sm">${mit.owner}</td>
<td class="p-3 text-center">
<span class="badge-raw text-xs border-2 border-black ${statusClass}">${mit.status.replace(' ', '<br>')}</span>
</td>
<td class="p-3">
${mit.status !== 'Done' ? `<button class="btn-raw text-xs py-0 px-2 bg-[#ff00ff] text-white" onclick="completeMitigation('${mit.id}')">DONE</button>` : '<span class="text-green-600 font-bold">✓ CLOSED</span>'}
</td>
`;
tbody.appendChild(tr);
});
}
function renderGovernance() {
const tbody = document.getElementById('governance-table-body');
tbody.innerHTML = store.auditLog.map(log => `
<tr class="border-b border-gray-200">
<td class="p-2 font-raw text-xs">${log.ts}</td>
<td class="p-2 font-bold text-sm">${log.user}</td>
<td class="p-2 font-raw">${log.action}</td>
<td class="p-2 font-raw italic">${log.target || '-'}</td>
<td class="p-2 font-mono text-xs bg-gray-100">${log.ip}</td>
</tr>
`).join('');
}
// --- ACTIONS ---
function toggleAssetForm() {
const form = document.getElementById('asset-form-container');
form.classList.toggle('hidden');
}
function addAsset() {
const name = document.getElementById('new-asset-name').value;
const type = document.getElementById('new-asset-type').value;
const ip = document.getElementById('new-asset-ip').value;
const owner = document.getElementById('new-asset-owner').value;
if(!name || !ip) {
showToast("ERROR: MISSING REQUIRED FIELDS");
return;
}
const newId = `A-${1000 + store.assets.length + 1}`;
store.assets.push({ id: newId, name, type, ip, owner, threats: 0 });
logAudit('ADMIN', `CREATED ASSET ${newId}`, ip);
renderAssetsTable();
toggleAssetForm();
showToast(`ASSET ${newId} REGISTERED`);
// clear inputs
document.getElementById('new-asset-name').value = '';
document.getElementById('new-asset-ip').value = '';
document.getElementById('new-asset-owner').value = '';
}
function generateSTRIDEThreats() {
const select = document.getElementById('stride-asset-select');
const assetId = select.value;
const resultsDiv = document.getElementById('stride-results');
const infoDiv = document.getElementById('stride-selected-info');
const runBtn = document.getElementById('btn-run-scan');
if (!assetId) return;
const asset = store.assets.find(a => a.id === assetId);
if(asset) {
infoDiv.classList.remove('hidden');
document.getElementById('info-ip').innerText = asset.ip;
document.getElementById('info-type').innerText = asset.type;
runBtn.disabled = false;
}
// Simulate processing
resultsDiv.innerHTML = `
<div class="p-4 bg-black text-[#00ff00] font-raw text-sm">
> INITIALIZING THREAT MODEL MATRIX...<br>
> ANALYZING: ${asset.name}<br>
> EXTRACTING DATA FLOWS...<br>
</div>
`;
setTimeout(() => {
const threats = generateThreatsForAsset(asset);
// Visual container
let html = `<div class="space-y-4">`;
threats.forEach((t, index) => {
const colorMap = {
'Spoofing': 'bg-[#ff00ff]',
'Tampering': 'bg-[#ff9900]',
'Repudiation': 'bg-[#00ffff]',
'Information Disclosure': 'bg-[#6600cc]',
'Denial of Service': 'bg-[#ff3333]',
'Elevation of Privilege': 'bg-[#000] text-white'
};
const bgClass = colorMap[t.category] || 'bg-gray-400';
html += `
<div class="card-raw p-4 flex items-center gap-4 bg-white" style="animation-delay: ${index * 100}ms">
<div class="w-16 h-16 flex items-center justify-center text-white font-bold text-xl border-4 border-black shadow-hard shrink-0 ${bgClass}">
${t.category.substring(0,1)}
</div>
<div class="flex-1">
<div class="flex justify-between">
<h5 class="font-display text-xl uppercase">${t.title}</h5>
<span class="badge-raw ${t.severity === 'Critical' ? 'bg-red-600 text-white' : 'bg-yellow-400'}">${t.severity}</span>
</div>
<p class="font-raw text-sm mt-1 text-gray-700">${t.desc}</p>
<div class="mt-3 flex gap-2">
<button class="btn-raw text-xs py-1 btn-acid" onclick="createMitigation('${t.category}', '${t.title}')">ADD MITIGATION</button>
</div>
</div>
</div>
`;
});
html += `</div>`;
resultsDiv.innerHTML = html;
// Add new threats to store (Simulation)
threats.forEach(t => {
if(!store.threats.some(st => st.title === t.title && st.assetId === assetId)) {
store.threats.push({
id: `T-${1000 + store.threats.length + 1}`,
assetId: asset.id,
category: t.category,
title: t.title,
severity: t.severity,
status: 'Open'
});
}
});
renderAssetsTable(); // Update counts in table
logAudit('SYSTEM', `STRIDE SCAN COMPLETED ON ${asset.id}`, asset.ip);
showToast("ANALYSIS COMPLETE");
}, 1200);
}
function generateThreatsForAsset(asset) {
// Pseudo-random generation based on type
const possible = [];
if (asset.type === 'DATABASE') {
possible.push({ category: 'Tampering', title: 'SQL Injection via Input Validation', severity: 'Critical', desc: 'Malicious SQL code inserted via application input.' });
possible.push({ category: 'Information Disclosure', title: 'Sensitive Data Export', severity: 'High', desc: 'Unauthorized export of tables containing PII.' });
possible.push({ category: 'Denial of Service', title: 'Query Flood Attack', severity: 'Medium', desc: 'Overwhelming DB resources with complex joins.' });
}
if (asset.type === 'SERVICE' || asset.type === 'ENDPOINT') {
possible.push({ category: 'Spoofing', title: 'API Key Theft / Replay', severity: 'High', desc: 'Stealing credentials to impersonate legitimate client.' });
possible.push({ category: 'Elevation of Privilege', title: 'Missing Authorization Checks', severity: 'Critical', desc: 'Access to admin endpoints without proper role validation.' });
possible.push({ category: 'Denial of Service', title: 'Resource Exhaustion', severity: 'Medium', desc: 'Sending requests that keep connections open indefinitely.' });
}
if (asset.type === 'INFRA') {
possible.push({ category: 'Tampering', title: 'Configuration Tampering', severity: 'Critical', desc: 'Modifying infrastructure as code templates.' });
possible.push({ category: 'Repudiation', title: 'Lack of CloudTrail Logs', severity: 'Low', desc: 'Actions on S3 buckets not logged for accountability.' });
}
// Shuffle and pick 2-3
possible.sort(() => Math.random() - 0.5);
return possible.slice(0, Math.floor(Math.random() * 2) + 2);
}
function createMitigation(category, title) {
// In a real app, we'd link to the specific threat. Here we just add a generic mitigation.
const mitigationText = `Implement specific controls for ${title}`;
const owner = "Unassigned";
store.mitigations.push({
id: `M-${1000 + store.mitigations.length + 1}`,
threatId: 'T-MANUAL',
text: mitigationText,
owner: owner,
status: 'Open'
});
showToast("MITIGATION TASK CREATED");
// Switch to mitigation tab to see it
setTimeout(() => switchTab('mitigations'), 500);
}
function completeMitigation(mitId) {
const idx = store.mitigations.findIndex(m => m.id === mitId);
if(idx > -1) {
store.mitigations[idx].status = 'Done';
showToast("MITIGATION MARKED AS COMPLETED");
renderMitigations();
logAudit('ADMIN', `COMPLETED MITIGATION ${mitId}`, '127.0.0.1');
}
}
function scanAsset(assetId) {
// Switch to stride tab and select
switchTab('stride');
const select = document.getElementById('stride-asset-select');
select.value = assetId;
generateSTRIDEThreats();
}
// --- GOVERNANCE & UTILS ---
function logAudit(user, action, target, ip = '127.0.0.1') {
store.auditLog.unshift({
ts: new Date().toLocaleString(),
user,
action,
target,
ip
});
renderGovernance();
}
function showToast(msg) {
const toast = document.getElementById('toast');
toast.innerText = `>> ${msg}`;
toast.classList.remove('translate-y-20');
setTimeout(() => {
toast.classList.add('translate-y-20');
}, 3000);
}
function generateRandomThreat() {
// Simulates a live attack scenario generating a new threat
const asset = store.assets[Math.floor(Math.random() * store.assets.length)];
const categories = ['Spoofing', 'Tampering', 'Repudiation', 'Information Disclosure', 'Denial of Service', 'Elevation of Privilege'];
const cat = categories[Math.floor(Math.random() * categories.length)];
const titles = [cat + ' Breach', 'Advanced ' + cat, 'Zero-day ' + cat, 'Critical ' + cat];
const title = titles[Math.floor(Math.random() * titles.length)];
store.threats.push({
id: `T-${1000 + store.threats.length + 1}`,
assetId: asset.id,
category: cat,
title: title,
severity: 'Critical',
status: 'Open'
});
logAudit('SEC_ENGINE', 'AUTO-DETECTED NEW THREAT', `${asset.id}: ${title}`, '10.10.10.10');
renderAssetsTable();
renderMitigations();
getStats();
// Flash effect on dashboard if active
gsap.fromTo('#dash-threats-count', { scale: 2, color: '#ff0000' }, { scale: 1, color: '#000', duration: 0.5 });
showToast("ALERT: NEW THREAT DETECTED!");
}
function triggerSystemCrash() {
document.body.style.filter = "invert(1)";
setTimeout(() => {
document.body.style.filter = "none";
}, 500);
showToast("SYSTEM INTEGRITY CHECK pass_fail");
}
// --- INITIALIZATION ---
window.onload = () => {
initNoise();
renderAssetsTable();
renderMitigations();
renderGovernance();
getStats();
// Initial animation for main container
gsap.from("nav", { x: -300, duration: 1, ease: "power4.out" });
gsap.from(".section", { opacity: 0, y: 20, duration: 0.8, delay: 0.5, stagger: 0.1 });
};
</script>
</body>
</html>