Files
Aegis/frontend/src/api/system.ts
kitos a4cdc06534
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
fix(evaluations): bypass Cloudflare 403 with browser headers + hardcoded fallback rounds
- Add browser User-Agent and Referer headers to all evals.mitre.org requests
- fetch_rounds_with_status() returns api_reachable flag + rounds list
- Fallback to 5 known public CrowdStrike rounds (APT29/R2 through OilRig/R6)
  when live API is blocked, so UI always shows something actionable
- Router returns {rounds, api_reachable, api_error} instead of plain array
- Frontend shows orange warning banner when using fallback data
- Remove 502 HTTPException - rounds are always returned (live or fallback)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-05 16:10:27 +02:00

105 lines
3.0 KiB
TypeScript

import client from "./client";
export interface SyncMitreResponse {
message: string;
status?: string;
new?: number;
updated?: number;
}
export interface IntelScanResponse {
message: string;
new_items: number;
}
export interface SchedulerJob {
id: string;
name: string;
next_run_time: string | null;
}
export interface SchedulerStatusResponse {
running: boolean;
jobs: SchedulerJob[];
}
/** Manually trigger MITRE ATT&CK sync. */
export async function triggerMitreSync(): Promise<SyncMitreResponse> {
const { data } = await client.post<SyncMitreResponse>("/system/sync-mitre");
return data;
}
/** Manually trigger threat intelligence scan. */
export async function triggerIntelScan(): Promise<IntelScanResponse> {
const { data } = await client.post<IntelScanResponse>("/system/run-intel-scan");
return data;
}
/** Get scheduler status. */
export async function getSchedulerStatus(): Promise<SchedulerStatusResponse> {
const { data } = await client.get<SchedulerStatusResponse>("/system/scheduler-status");
return data;
}
// ── ATT&CK Evaluations ─────────────────────────────────────────────
export interface EvaluationRound {
name: string;
display_name: string;
eval_round: number;
imported: boolean;
imported_at: string | null;
tests_created: number | null;
techniques_covered: number | null;
}
export interface EvaluationRoundsResponse {
rounds: EvaluationRound[];
api_reachable: boolean;
api_error: string | null;
}
export interface EvaluationImportResult {
message: string;
created: number;
skipped: number;
techniques_covered: number;
adversary: string;
eval_round: number;
}
export interface NewRoundCheckResult {
new_round_available: boolean;
already_imported: boolean;
latest_round: { name: string; display_name: string; eval_round: number } | null;
error?: string;
}
/** List all public CrowdStrike evaluation rounds with import status. */
export async function listEvaluationRounds(): Promise<EvaluationRoundsResponse> {
const { data } = await client.get<EvaluationRoundsResponse>("/system/attck-evaluations/rounds");
return data;
}
/** Import a specific evaluation round. */
export async function importEvaluationRound(payload: {
adversary_name: string;
adversary_display: string;
eval_round: number;
}): Promise<EvaluationImportResult> {
const { data } = await client.post<EvaluationImportResult>("/system/attck-evaluations/import", payload);
return data;
}
/** Import the latest available round automatically. */
export async function importLatestEvaluation(): Promise<EvaluationImportResult> {
const { data } = await client.post<EvaluationImportResult>("/system/attck-evaluations/import-latest");
return data;
}
/** Check if a new round is available. */
export async function checkNewEvaluationRound(): Promise<NewRoundCheckResult> {
const { data } = await client.get<NewRoundCheckResult>("/system/attck-evaluations/check-new");
return data;
}