/** * @fileoverview Vulnerability Rule Engine - Core Detection Engine * @module rules/vulnerabilities/engine * * Orchestrates vulnerability detection across all rule categories: * - Multi-pattern matching with timeout protection * - Taint analysis integration * - AST-aware analysis * - Dynamic scoring * - Rule correlation * - Finding aggregation and deduplication */ import { VulnerabilityRule, VulnerabilityFinding, VulnerabilityPattern, AnalysisContext, AnalysisOptions, IVulnerabilityRuleEngine, IPatternMatcher, PatternMatch, ConfidenceLevel, SupportedLanguage, TaintFlow, DataFlowTrace } from '../types'; /** * Pattern matcher with timeout protection */ export declare class PatternMatcher implements IPatternMatcher { private timeoutMs; private maxMatches; constructor(options?: { timeoutMs?: number; maxMatches?: number; }); /** * Match patterns against content */ match(content: string, patterns: VulnerabilityPattern[], language: SupportedLanguage): PatternMatch[]; /** * Match with timeout protection */ matchWithTimeout(content: string, patterns: VulnerabilityPattern[], language: SupportedLanguage, timeout: number): Promise; /** * Match a single pattern against code */ private matchSinglePattern; /** * Match literal string pattern */ private matchLiteralPattern; } /** * Simple taint analyzer for detecting data flows */ export declare class SimpleTaintAnalyzer { /** * Analyze taint flows in code */ analyze(context: AnalysisContext, rule: VulnerabilityRule): TaintFlow[]; /** * Convert taint flow to data flow trace for reporting */ createDataFlowTrace(flow: TaintFlow, code: string): DataFlowTrace; } export interface EngineOptions { enableTaintAnalysis: boolean; enableAstAnalysis: boolean; enableCfgAnalysis: boolean; timeoutMs: number; maxFindings: number; minConfidence: ConfidenceLevel; includeInfo: boolean; excludeTestFiles: boolean; excludeVendorCode: boolean; language?: SupportedLanguage; } /** * Main vulnerability detection engine */ export declare class VulnerabilityRuleEngine implements IVulnerabilityRuleEngine { private rules; private patternMatcher; private taintAnalyzer; private scoreCalculator; private engineOptions; constructor(rules: VulnerabilityRule[], options?: Partial); /** * Analyze code against all enabled rules */ analyze(context: AnalysisContext, options?: AnalysisOptions): Promise; /** * Analyze code with a specific rule */ private analyzeWithRule; /** * Create a vulnerability finding */ private createFinding; /** * Generate finding message */ private generateMessage; /** * Generate detailed audit analysis */ private generateAuditAnalysis; /** * Generate developer-friendly explanation */ private generateDeveloperExplanation; /** * Get rules applicable to a language */ private getApplicableRules; /** * Get all registered rules */ getRules(): VulnerabilityRule[]; /** * Get rule by ID */ getRule(id: string): VulnerabilityRule | undefined; /** * Enable/disable a rule */ setRuleEnabled(id: string, enabled: boolean): void; /** * Add a custom rule */ addRule(rule: VulnerabilityRule): void; /** * Group matches by location */ private groupMatchesByLocation; /** * Check if two locations overlap */ private locationsOverlap; /** * Check if confidence meets minimum */ private meetsMinConfidence; /** * Deduplicate findings */ private deduplicateFindings; } /** * Create default vulnerability engine */ export declare function createDefaultEngine(rules: VulnerabilityRule[], options?: Partial): VulnerabilityRuleEngine; /** * Quick scan function for simple usage */ export declare function quickScan(code: string, filePath: string, language: SupportedLanguage, rules: VulnerabilityRule[], options?: Partial): Promise; //# sourceMappingURL=index.d.ts.map