/** * Tactics Module Registry and Dispatcher * * Provides specialized vulnerability detection for each focus area. * Each tactic module contains domain-specific patterns, LLM prompt * enhancements, and PoC generation logic. * * @module agents/adversary/tactics */ import type { AdversaryConfig, AdversaryFinding, AttackFocusArea, ProofOfConcept } from "../types.js"; /** * File context for analysis */ export interface FileContext { path: string; relativePath: string; content: string; language: string; lines: string[]; } /** * Vulnerability pattern for detection */ export interface VulnerabilityPattern { id: string; name: string; description: string; cwe: string; severity: "critical" | "high" | "medium" | "low"; regex?: RegExp; astPattern?: string; detectFn?: (content: string, context: FileContext) => PatternMatch[]; } /** * Pattern match result */ export interface PatternMatch { patternId: string; line: number; column?: number; match: string; context: string; confidence: number; } /** * Finding from tactic analysis (before LLM enrichment) */ export interface TacticFinding { id: string; tacticName: string; focusArea: AttackFocusArea; patternId: string; file: string; line: number; column?: number; message: string; severity: "critical" | "high" | "medium" | "low"; confidence: number; evidence: string; cweIds: string[]; mitreIds: string[]; suggestedFix?: string; } /** * Tactic module interface */ export interface TacticModule { /** Focus area this tactic covers */ focusArea: AttackFocusArea; /** Display name */ name: string; /** Description */ description: string; /** Vulnerability patterns to detect */ patterns: VulnerabilityPattern[]; /** Analyze a file for vulnerabilities */ analyzeFile(file: FileContext, config: AdversaryConfig): Promise; /** Generate PoC for a finding */ generatePoC(finding: TacticFinding): Promise; /** Get LLM prompt enhancement for this tactic */ getPromptEnhancement(): string; /** Get file patterns this tactic is interested in */ getRelevantFilePatterns(): string[]; } /** * Register a tactic module */ export declare function registerTactic(tactic: TacticModule): void; /** * Get tactic module for a focus area */ export declare function getTactic(focusArea: AttackFocusArea): TacticModule | undefined; /** * Get all registered tactics */ export declare function getAllTactics(): TacticModule[]; /** * Get tactics for specified focus areas */ export declare function getTacticsForFocusAreas(areas: AttackFocusArea[]): TacticModule[]; /** * Convert a glob pattern to an anchored RegExp. * * Rules (applied in order so longer tokens are matched first): * "**\/": zero-or-more directory segments — so root files match without a slash. * "**" (bare): any path sequence. * "*" (single): any sequence within one path segment (no slash). * Other regex-special chars are literal-escaped. * * The result is anchored with ^...$ and tested against file.relativePath. */ export declare function globToRegExp(glob: string): RegExp; /** * Run tactic analysis on a file */ export declare function runTacticAnalysis(file: FileContext, tactics: TacticModule[], config: AdversaryConfig): Promise; /** * Build combined LLM prompt enhancement from tactics */ export declare function buildCombinedPromptEnhancement(tactics: TacticModule[]): string; /** * Convert tactic findings to adversary findings */ export declare function tacticFindingsToAdversaryFindings(tacticFindings: TacticFinding[]): Partial[]; /** * Detect language from file extension */ export declare function detectLanguage(filePath: string): string; /** * Create file context from path and content */ export declare function createFileContext(projectPath: string, filePath: string, content: string): FileContext; /** * Extract context around a match */ export declare function extractContext(lines: string[], lineNum: number, contextLines?: number): string; /** * Generate unique finding ID */ export declare function generateFindingId(tacticName: string, file: string, line: number, patternId: string): string; //# sourceMappingURL=index.d.ts.map