/** * Input Validation Utilities * * General input sanitization and pattern matching. * * Security Features: * - RegExp injection prevention (SMI-722) * - Input sanitization * - Pattern validation */ /** * Sanitize input string for safe use in various contexts * * Removes or escapes potentially dangerous characters. * * @param input - Input string to sanitize * @param options - Sanitization options * @returns Sanitized string * * @example * ```typescript * sanitizeInput('') // Returns: '<script>alert(1)</script>' * sanitizeInput('../../etc/passwd') // Returns: 'etc/passwd' * ``` */ export declare function sanitizeInput(input: string, options?: { /** Remove path traversal sequences like '../' (default: true) */ removePathTraversal?: boolean; /** HTML-escape special characters (default: true) */ escapeHtml?: boolean; /** Remove null bytes (default: true) */ removeNullBytes?: boolean; }): string; /** * Safely test a string against a pattern, preventing RegExp injection (SMI-722) * * Tries exact match, prefix match, and regex match (with error handling). * Falls back to includes check if regex is invalid. * * @param value - Value to test * @param pattern - Pattern to match (string or regex) * @returns True if value matches pattern * * @example * ```typescript * safePatternMatch('node_modules', 'node_modules') // true (exact) * safePatternMatch('node_modules/pkg', 'node_') // true (prefix) * safePatternMatch('test.js', '\\.js$') // true (regex) * safePatternMatch('test.js', '(evil') // false (invalid regex, falls back) * ``` */ export declare function safePatternMatch(value: string, pattern: string): boolean; /** * Validate that patterns array is safe to use * * Checks for potentially dangerous regex patterns that could cause ReDoS. * * @param patterns - Array of patterns to validate * @returns Array of validation warnings (empty if all patterns are safe) * * @example * ```typescript * validatePatterns(['node_modules', '\\.js$']) // [] * validatePatterns(['(a+)+b']) // ['Pattern may cause ReDoS: (a+)+b'] * ``` */ export declare function validatePatterns(patterns: string[]): string[]; //# sourceMappingURL=input-validators.d.ts.map