Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

8.8 KB
Raw Blame
import type {
  WazuhAgentsOverview,
  WazuhAlert,
  WazuhAlertTimeline,
  WazuhAuthFailures,
  WazuhFimOverview,
  WazuhSecuritySummary,
  WazuhTopList,
  WazuhVulnerabilityOverview,
} from "./wazuh-types";

const wave = (index: number, base: number, amplitude: number) =>
  Math.max(0, Math.round(base + amplitude * Math.sin(index / 3) + ((index * 7919) % 5)));

const mitre = (ids: string[], tactics: string[], techniques: string[]) => ({ ids, tactics, techniques });

/** Deterministic demo data for the Wazuh widgets (used by the mock integration and the widget previews). */
export const createWazuhMockData = (demoTimestamp: string) => {
  const now = new Date(demoTimestamp).getTime();
  const hour = 60 * 60 * 1000;
  const iso = (offsetMs: number) => new Date(now - offsetMs).toISOString();
  return {
    wazuhAgents: {
      source: "api",
      asOf: demoTimestamp,
      counts: { total: 6, active: 4, disconnected: 1, neverConnected: 1, pending: 0 },
      agents: [
        {
          id: "001",
          name: "edge-proxy",
          status: "active",
          ip: "10.0.0.3",
          osName: "Ubuntu",
          osVersion: "24.04.3 LTS",
          osPlatform: "ubuntu",
          version: "v4.14.8",
          lastKeepAlive: iso(20_000),
          groups: ["default", "dmz"],
        },
        {
          id: "002",
          name: "vpn-gateway",
          status: "active",
          ip: "10.0.0.7",
          osName: "Debian GNU/Linux",
          osVersion: "13",
          osPlatform: "debian",
          version: "v4.14.8",
          lastKeepAlive: iso(35_000),
          groups: ["default"],
        },
        {
          id: "003",
          name: "office-laptop",
          status: "active",
          ip: "10.0.0.31",
          osName: "Microsoft Windows 11 Pro",
          osVersion: "10.0.26200",
          osPlatform: "windows",
          version: "v4.14.1",
          lastKeepAlive: iso(50_000),
          groups: ["workstations"],
        },
        {
          id: "004",
          name: "design-mac",
          status: "active",
          ip: "10.0.0.44",
          osName: "macOS",
          osVersion: "15.6",
          osPlatform: "darwin",
          version: "v4.14.1",
          lastKeepAlive: iso(15_000),
          groups: ["workstations"],
        },
        {
          id: "005",
          name: "media-server",
          status: "disconnected",
          ip: "10.0.0.14",
          osName: "Ubuntu",
          osVersion: "22.04.5 LTS",
          osPlatform: "ubuntu",
          version: "v4.12.0",
          lastKeepAlive: iso(3 * 24 * hour),
          groups: ["default"],
        },
        {
          id: "006",
          name: "new-nas",
          status: "never_connected",
          ip: null,
          osName: null,
          osVersion: null,
          osPlatform: null,
          version: null,
          lastKeepAlive: null,
          groups: [],
        },
      ],
    } satisfies WazuhAgentsOverview,
    wazuhAlerts: [
      {
        id: "a1",
        alertId: "1756036680.1",
        timestamp: iso(2 * 60_000),
        level: 12,
        ruleId: "5763",
        description: "sshd: brute force trying to get access to the system. Authentication failed.",
        agentId: "001",
        agentName: "edge-proxy",
        sourceIp: "203.0.113.24",
        groups: ["syslog", "sshd", "authentication_failures"],
        mitre: mitre(["T1110"], ["Credential Access"], ["Brute Force"]),
      },
      {
        id: "a2",
        alertId: "1756036260.2",
        timestamp: iso(9 * 60_000),
        level: 10,
        ruleId: "5551",
        description: "PAM: Multiple failed logins in a small period of time.",
        agentId: "002",
        agentName: "vpn-gateway",
        sourceIp: null,
        groups: ["pam", "syslog", "authentication_failures"],
        mitre: mitre(["T1110"], ["Credential Access"], ["Brute Force"]),
      },
      {
        id: "a3",
        alertId: "1756035600.3",
        timestamp: iso(20 * 60_000),
        level: 7,
        ruleId: "533",
        description: "Listened ports status (netstat) changed (new port opened or closed).",
        agentId: "003",
        agentName: "office-laptop",
        sourceIp: null,
        groups: ["ossec"],
        mitre: mitre([], [], []),
      },
    ] satisfies WazuhAlert[],
    wazuhSummary: {
      range: "24h",
      alerts: { total: 4821, low: 4410, medium: 392, high: 18, critical: 1 },
      previousAlerts: { total: 5230, low: 4870, medium: 340, high: 20, critical: 0 },
      maxLevel: 15,
      managerVersion: "v4.14.8",
      indexerHealth: "green",
    } satisfies WazuhSecuritySummary,
    wazuhTimeline: {
      range: "24h",
      intervalMs: hour,
      totals: { total: 4821, low: 4410, medium: 392, high: 18, critical: 1 },
      points: Array.from({ length: 24 }, (_, index) => ({
        timestamp: now - (23 - index) * hour,
        low: wave(index, 180, 60),
        medium: wave(index + 4, 16, 8),
        high: index % 7 === 3 ? 3 : 0,
        critical: index === 17 ? 1 : 0,
      })),
    } satisfies WazuhAlertTimeline,
    wazuhTopList: {
      kind: "rules",
      range: "24h",
      total: 4821,
      others: 1240,
      entries: [
        { key: "5503", label: "PAM: User login failed.", detail: "5503", count: 1458, maxLevel: 5, agents: 2 },
        {
          key: "5710",
          label: "sshd: Attempt to login using a non-existent user",
          detail: "5710",
          count: 1120,
          maxLevel: 5,
          agents: 2,
        },
        { key: "5760", label: "sshd: authentication failed.", detail: "5760", count: 731, maxLevel: 5, agents: 1 },
        {
          key: "5551",
          label: "PAM: Multiple failed logins in a small period of time.",
          detail: "5551",
          count: 162,
          maxLevel: 10,
          agents: 2,
        },
        {
          key: "5763",
          label: "sshd: brute force trying to get access to the system.",
          detail: "5763",
          count: 110,
          maxLevel: 10,
          agents: 1,
        },
      ],
    } satisfies WazuhTopList,
    wazuhVulnerabilities: {
      counts: { critical: 12, high: 87, medium: 240, low: 31, unscored: 4 },
      total: 374,
      affectedAgents: 5,
      topCves: [
        { id: "CVE-2026-1001", severity: "Critical", score: 9.8, agents: 4, packages: ["openssl"], reference: null },
        {
          id: "CVE-2026-2044",
          severity: "Critical",
          score: 9.1,
          agents: 2,
          packages: ["linux-image"],
          reference: null,
        },
        { id: "CVE-2026-0311", severity: "High", score: 8.8, agents: 5, packages: ["sudo"], reference: null },
      ],
      topAgents: [
        { id: "005", name: "media-server", total: 160, critical: 7, high: 40 },
        { id: "001", name: "edge-proxy", total: 92, critical: 3, high: 21 },
        { id: "003", name: "office-laptop", total: 70, critical: 2, high: 18 },
      ],
    } satisfies WazuhVulnerabilityOverview,
    wazuhFim: {
      range: "24h",
      counts: { added: 4, modified: 21, deleted: 2 },
      entries: [
        {
          id: "f1",
          alertId: "1756036000.10",
          timestamp: iso(5 * 60_000),
          event: "modified",
          path: "/etc/ssh/sshd_config",
          valueName: null,
          isRegistry: false,
          agentId: "001",
          agentName: "edge-proxy",
          level: 7,
          description: "Integrity checksum changed.",
          user: "root",
        },
        {
          id: "f2",
          alertId: "1756035000.11",
          timestamp: iso(40 * 60_000),
          event: "added",
          path: "/usr/local/bin/backup.sh",
          valueName: null,
          isRegistry: false,
          agentId: "002",
          agentName: "vpn-gateway",
          level: 5,
          description: "File added to the system.",
          user: "admin",
        },
      ],
    } satisfies WazuhFimOverview,
    wazuhAuthFailures: {
      hours: 24,
      totals: { failed: 2410, bruteForce: 96, total: 2506, sourceIps: 41 },
      series: Array.from({ length: 24 }, (_, index) => wave(index, 100, 40)),
      agents: [
        {
          agentId: "001",
          agentName: "edge-proxy",
          failed: 1480,
          bruteForce: 70,
          total: 1550,
          series: Array.from({ length: 24 }, (_, index) => wave(index, 64, 30)),
          topSourceIps: [
            { ip: "203.0.113.24", count: 620 },
            { ip: "198.51.100.8", count: 211 },
          ],
          lastSeen: iso(60_000),
        },
        {
          agentId: "002",
          agentName: "vpn-gateway",
          failed: 930,
          bruteForce: 26,
          total: 956,
          series: Array.from({ length: 24 }, (_, index) => wave(index + 5, 40, 20)),
          topSourceIps: [{ ip: "192.0.2.77", count: 300 }],
          lastSeen: iso(7 * 60_000),
        },
      ],
    } satisfies WazuhAuthFailures,
  };
};