/** * Logic Flaw Detector Agent * * Finds business logic vulnerabilities that pattern-based scanners miss. * Analyzes control flow, state management, and business rule implementations. * * Focus areas: * - State inconsistency: Variables mutable when should be immutable * - Race conditions: Check-then-act without locks * - Boundary conditions: Off-by-one, integer overflow * - Error handling: Swallowed exceptions, incomplete cleanup * - Trust boundaries: Client-supplied data used unsafely * - Business rule violations: Incorrect implementations of business logic * * @module agents/logic-flaw-detector */ import type { Severity, Finding } from "../certification/types.js"; export type LogicFlawCategory = "state-inconsistency" | "race-condition" | "boundary-violation" | "error-handling" | "trust-boundary" | "business-logic" | "null-safety" | "resource-leak" | "invariant-violation"; export interface LogicFlawFinding { id: string; title: string; description: string; severity: Severity; confidence: number; category: LogicFlawCategory; file: string; line: number; endLine?: number; codeSnippet: string; impact: string; cweIds: string[]; recommendation: string; relatedFunctions?: string[]; } export interface LogicFlawDetectorConfig { focusFiles?: string[]; analysisDepth: "quick" | "standard" | "thorough"; categories?: LogicFlawCategory[]; maxFilesToAnalyze?: number; } export interface LogicFlawDetectorResult { filesAnalyzed: number; findings: LogicFlawFinding[]; categories: LogicFlawCategory[]; recommendations: string[]; /** Which engine produced the findings this run ("pattern-only" or a model id). */ modelUsed?: string; totalTokensUsed?: number; } /** * Collapse ENSEMBLE duplicates — the same bug surfaced by more than one pass. * Keys on file + category + a small line bucket (tolerates the line drift the LLM * shows for the same finding across passes) and keeps the highest-confidence * instance. A no-op for a single pass with no duplicates. */ export declare function dedupeLlmFindings(findings: LogicFlawFinding[]): LogicFlawFinding[]; /** * Run logic flaw detection on a project */ export declare function runLogicFlawDetector(projectPath: string, config: LogicFlawDetectorConfig): Promise; /** * Convert logic flaw findings to certification findings */ export declare function logicFlawToFindings(result: LogicFlawDetectorResult): Finding[]; //# sourceMappingURL=logic-flaw-detector.d.ts.map