/** * Safe Regex Utilities - ReDoS Prevention * * Provides regex validation and safe execution with timeout protection. */ export interface RegexValidationResult { valid: boolean; error?: string; } export interface PCREConversionResult { pattern: string; flags: string; converted: boolean; error?: string; } /** * Convert PCRE inline modifiers to JavaScript flags * Handles: (?i), (?m), (?s), (?x), and combinations like (?im) */ export declare function convertPCREModifiers(pattern: string): PCREConversionResult; /** * Validate a regex pattern for potential ReDoS vulnerabilities */ export declare function validateRegexPattern(pattern: string): RegexValidationResult; /** * Pattern error metrics for monitoring */ export interface PatternErrorMetrics { pcreConversionFailures: number; validationFailures: number; regexCompilationFailures: number; totalPatternsProcessed: number; } /** * Get current pattern error metrics */ export declare function getPatternErrorMetrics(): Readonly; /** * Reset pattern error metrics (useful for testing) */ export declare function resetPatternErrorMetrics(): void; /** * Get a cached regex instance or create a new one */ export declare function getCachedRegex(pattern: string, flags?: string): RegExp | null; /** * Execute regex with content length limit */ export declare function safeRegexExec(regex: RegExp, content: string, maxLength?: number): RegExpExecArray | null; /** * Safe regex test with content length limit */ export declare function safeRegexTest(regex: RegExp, content: string, maxLength?: number): boolean; /** * Create a safe regex with validation * Throws error if pattern is unsafe */ export declare function createSafeRegex(pattern: string, flags?: string): RegExp; /** * Validate multiple regex patterns */ export declare function validateRegexPatterns(patterns: string[]): RegexValidationResult;