/** * @fileoverview Malware Rule Engine - Core Detection Engine * @module rules/malware/engine * * Orchestrates malware detection across all rule categories: * - Multi-pattern matching with timeout protection * - AST-aware analysis * - Dynamic scoring * - Rule correlation * - Finding aggregation and deduplication * - Concurrent execution with limits */ import { MalwareRule, MalwareFinding, MalwarePattern, AnalysisContext, AnalysisOptions, IMalwareRuleEngine, IPatternMatcher, PatternMatch, MalwareSeverity, SupportedLanguage, MalwareCategory, MalwareThreatType } from '../types'; export declare class PatternMatcher implements IPatternMatcher { private timeoutMs; private maxMatches; constructor(options?: { timeoutMs?: number; maxMatches?: number; }); /** * Match patterns against content (implements IPatternMatcher) */ match(content: string, patterns: MalwarePattern[], language: SupportedLanguage): PatternMatch[]; /** * Match with timeout protection (implements IPatternMatcher) */ matchWithTimeout(content: string, patterns: MalwarePattern[], language: SupportedLanguage, timeout: number): Promise; /** * Match a single pattern against code */ matchSinglePattern(pattern: MalwarePattern, code: string, language: SupportedLanguage): PatternMatch[]; /** * Match regex pattern with timeout protection */ private matchRegexPattern; /** * Match literal string pattern */ private matchLiteralPattern; /** * Match heuristic pattern using entropy and obfuscation analysis */ private matchHeuristicPattern; /** * Get line number from character index */ private getLineNumber; } export interface EngineOptions { enableHeuristics: boolean; enableAstAnalysis: boolean; timeoutMs: number; maxFindings: number; minConfidence: number; language?: SupportedLanguage; } export declare class MalwareRuleEngine implements IMalwareRuleEngine { private rules; private patternMatcher; private scoreCalculator; private engineOptions; constructor(rules: MalwareRule[], options?: Partial); /** * Analyze code against all enabled rules (implements IMalwareRuleEngine) */ analyze(context: AnalysisContext, options?: AnalysisOptions): Promise; /** * Convenience method to analyze code string directly */ analyzeCode(code: string, contextOptions?: Partial<{ filePath: string; language?: string; }>): Promise; /** * Get all rules (implements IMalwareRuleEngine) */ getRules(): MalwareRule[]; /** * Get rules by category (implements IMalwareRuleEngine) */ getRulesByCategory(category: MalwareCategory): MalwareRule[]; /** * Get rules by threat type (implements IMalwareRuleEngine) */ getRulesByThreatType(type: MalwareThreatType): MalwareRule[]; /** * Enable/disable a rule (implements IMalwareRuleEngine) */ setRuleEnabled(ruleId: string, enabled: boolean): void; /** * Add a rule (implements IMalwareRuleEngine) */ addRule(rule: MalwareRule): void; /** * Remove a rule (implements IMalwareRuleEngine) */ removeRule(ruleId: string): void; /** * Get enabled rules, optionally filtered by language */ private getEnabledRules; /** * Analyze code with a specific rule */ private analyzeWithRule; /** * Calculate malware score for a finding */ private calculateMalwareScore; /** * Get character index from source location */ private getIndexFromLocation; /** * Calculate overall confidence from pattern matches */ private calculateConfidence; /** * Map numeric confidence to ConfidenceLevel */ private mapConfidenceToLevel; /** * Convert score to severity level */ private scoreToSeverity; /** * Convert score to risk level */ private scoreToRiskLevel; /** * Generate score explanation */ private generateScoreExplanation; /** * Generate analysis explanation for a finding */ private generateAnalysis; /** * Get all rules */ getAllRules(): MalwareRule[]; /** * Get enabled rule count */ getEnabledRuleCount(): number; /** * Analyze multiple files concurrently */ analyzeFiles(files: Array<{ path: string; code: string; language?: string; }>): Promise>; /** * Generate analysis summary */ generateSummary(findings: MalwareFinding[]): { totalFindings: number; bySeverity: Record; byThreatType: Record; highestScore: number; criticalCount: number; }; } /** * Create a rule engine with all default rules */ export declare function createDefaultEngine(options?: Partial): MalwareRuleEngine; /** * Quick scan function for simple use cases */ export declare function quickScan(code: string, language?: string): Promise<{ isMalicious: boolean; score: number; findings: MalwareFinding[]; }>; //# sourceMappingURL=index.d.ts.map