MAESTRO: add analysis types

This commit is contained in:
Mariusz Banach
2026-02-17 23:04:16 +01:00
parent 6ce9954d54
commit 8875dd4b84
5 changed files with 730 additions and 1 deletions

View File

@@ -0,0 +1,79 @@
import { describe, expectTypeOf, it } from "vitest";
import type {
AnalysisConfig,
AnalysisProgress,
AnalysisReport,
HeaderInput,
TestResult,
} from "./analysis";
describe("analysis types", () => {
it("matches expected analysis config shape", () => {
expectTypeOf<AnalysisConfig>().toEqualTypeOf<{
testIds: number[];
resolve: boolean;
decodeAll: boolean;
}>();
});
it("matches expected header input shape", () => {
expectTypeOf<HeaderInput>().toEqualTypeOf<{
rawText: string;
source: "paste" | "file";
fileName?: string;
}>();
});
it("matches expected test result shape", () => {
expectTypeOf<TestResult>().toEqualTypeOf<{
testId: number;
testName: string;
headerName: string;
headerValue: string;
analysis: string;
description: string;
severity: "spam" | "suspicious" | "clean" | "info";
status: "success" | "error" | "skipped";
error?: string | null;
}>();
});
it("matches expected report shape", () => {
expectTypeOf<AnalysisReport>().toEqualTypeOf<{
results: TestResult[];
hopChain: {
index: number;
hostname: string;
ip?: string;
timestamp?: string;
serverInfo?: string;
delay?: number | null;
}[];
securityAppliances: {
name: string;
vendor: string;
headers: string[];
}[];
metadata: {
totalTests: number;
passedTests: number;
failedTests: number;
skippedTests: number;
elapsedMs: number;
timedOut: boolean;
incompleteTests: string[];
};
}>();
});
it("matches expected progress shape", () => {
expectTypeOf<AnalysisProgress>().toEqualTypeOf<{
currentIndex: number;
totalTests: number;
currentTest: string;
elapsedMs: number;
percentage: number;
}>();
});
});

View File

@@ -0,0 +1,69 @@
export type HeaderInputSource = "paste" | "file";
export interface HeaderInput {
rawText: string;
source: HeaderInputSource;
fileName?: string;
}
export interface AnalysisConfig {
testIds: number[];
resolve: boolean;
decodeAll: boolean;
}
export type TestSeverity = "spam" | "suspicious" | "clean" | "info";
export type TestStatus = "success" | "error" | "skipped";
export interface TestResult {
testId: number;
testName: string;
headerName: string;
headerValue: string;
analysis: string;
description: string;
severity: TestSeverity;
status: TestStatus;
error?: string | null;
}
export interface HopChainNode {
index: number;
hostname: string;
ip?: string;
timestamp?: string;
serverInfo?: string;
delay?: number | null;
}
export interface SecurityAppliance {
name: string;
vendor: string;
headers: string[];
}
export interface ReportMetadata {
totalTests: number;
passedTests: number;
failedTests: number;
skippedTests: number;
elapsedMs: number;
timedOut: boolean;
incompleteTests: string[];
}
export interface AnalysisReport {
results: TestResult[];
hopChain: HopChainNode[];
securityAppliances: SecurityAppliance[];
metadata: ReportMetadata;
}
export interface AnalysisProgress {
currentIndex: number;
totalTests: number;
currentTest: string;
elapsedMs: number;
percentage: number;
}