import { useQuery } from "@tanstack/react-query"; import { useNavigate } from "react-router-dom"; import { Loader2, AlertCircle, FlaskConical, Plus } from "lucide-react"; import { getTechniques, type TechniqueSummary } from "../api/techniques"; import type { TestState, TestResult } from "../types/models"; import { useAuth } from "../context/AuthContext"; const testStateBadgeColors: Record = { draft: "bg-gray-800/50 text-gray-400 border-gray-600/30", in_review: "bg-blue-900/50 text-blue-400 border-blue-500/30", validated: "bg-green-900/50 text-green-400 border-green-500/30", rejected: "bg-red-900/50 text-red-400 border-red-500/30", }; const testResultBadgeColors: Record = { detected: "bg-green-900/50 text-green-400 border-green-500/30", not_detected: "bg-red-900/50 text-red-400 border-red-500/30", partially_detected: "bg-yellow-900/50 text-yellow-400 border-yellow-500/30", }; interface TestSummary { id: string; technique_id: string; technique_mitre_id: string; technique_name: string; name: string; state: TestState; result: TestResult | null; platform: string | null; created_at: string; } export default function TestsPage() { const navigate = useNavigate(); const { user } = useAuth(); const canCreate = user?.role === "admin" || user?.role === "red_tech" || user?.role === "blue_tech"; // For now, we'll fetch techniques to get their tests // In a production app, you'd want a dedicated /tests endpoint const { data: techniques, isLoading, error, } = useQuery({ queryKey: ["techniques"], queryFn: () => getTechniques(), }); // Note: Since we don't have a direct /tests list endpoint, we're showing // a message to navigate through techniques. In a full implementation, // you'd add a /tests endpoint to the backend. const formatDate = (dateStr: string) => { return new Date(dateStr).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric", }); }; if (isLoading) { return (
); } if (error) { return (

Failed to load data

); } return (
{/* Header */}

Tests

Security tests for technique validation

{canCreate && ( )}
{/* Info Card */}

Browse Tests by Technique

Tests are organized by MITRE ATT&CK technique. Navigate to a technique from the{" "} {" "} to view and manage its associated tests.

{canCreate && ( )}
{/* Quick Stats */}

Techniques with Tests

{techniques?.filter((t: TechniqueSummary) => t.status_global !== "not_evaluated").length || 0}

Validated

{techniques?.filter((t: TechniqueSummary) => t.status_global === "validated").length || 0}

In Progress

{techniques?.filter((t: TechniqueSummary) => t.status_global === "in_progress").length || 0}

Pending Evaluation

{techniques?.filter((t: TechniqueSummary) => t.status_global === "not_evaluated").length || 0}

{/* Techniques with Recent Activity */}

Techniques Being Tested

{techniques ?.filter((t: TechniqueSummary) => t.status_global !== "not_evaluated") .slice(0, 10) .map((tech: TechniqueSummary) => ( ))}
Technique Name Status Action
{tech.mitre_id} {tech.name} {tech.status_global.replace(/_/g, " ")}
{techniques?.filter((t: TechniqueSummary) => t.status_global !== "not_evaluated").length === 0 && (
No techniques have been tested yet. Create your first test to get started.
)}
); }