/** * Mandatory security limits that CANNOT be disabled or exceeded. * These provide defense-in-depth protection against DoS attacks * that could occur BEFORE AST parsing completes. * * @module pre-scanner/mandatory-limits */ /** * Absolute maximum limits that cannot be exceeded regardless of configuration. * These values are chosen to prevent memory exhaustion and stack overflow * attacks against the parser itself (acorn). */ export declare const MANDATORY_LIMITS: { /** * Maximum input size in bytes (100MB). * Prevents memory exhaustion during parsing. * Even with 64GB RAM, allowing unlimited input could cause issues. */ readonly ABSOLUTE_MAX_INPUT_SIZE: number; /** * Maximum nesting depth for brackets/braces (200 levels). * Prevents stack overflow in recursive descent parsers. * Normal code rarely exceeds 20-30 levels. */ readonly ABSOLUTE_MAX_NESTING: 200; /** * Maximum single line length (100,000 characters). * Prevents memory issues with minified/obfuscated code. * Normal code lines rarely exceed 120 characters. */ readonly ABSOLUTE_MAX_LINE_LENGTH: 100000; /** * Maximum number of lines (1,000,000 lines). * Prevents DoS via extremely long files. * Largest reasonable codebases rarely exceed 100k lines per file. */ readonly ABSOLUTE_MAX_LINES: 1000000; /** * Maximum string literal length (5MB). * Prevents memory exhaustion via huge embedded strings. */ readonly ABSOLUTE_MAX_STRING: number; /** * Maximum regex literal length (1000 characters). * Prevents ReDoS via complex regex patterns. * Most legitimate regex patterns are under 200 characters. */ readonly ABSOLUTE_MAX_REGEX_LENGTH: 1000; /** * Maximum total string content in bytes (50MB). * Prevents memory exhaustion via many smaller strings. */ readonly ABSOLUTE_MAX_TOTAL_STRING_CONTENT: number; /** * Maximum number of regex literals per file (50). * Prevents ReDoS multiplication attacks. * Normal code rarely has more than 10-20 regex patterns. */ readonly ABSOLUTE_MAX_REGEX_COUNT: 50; }; /** * Type for mandatory limit keys */ export type MandatoryLimitKey = keyof typeof MANDATORY_LIMITS; /** * Checks if a value exceeds a mandatory limit. * This function is used internally by the pre-scanner. * * @param limitKey - The limit to check against * @param value - The actual value to check * @returns true if the value exceeds the limit */ export declare function exceedsMandatoryLimit(limitKey: MandatoryLimitKey, value: number): boolean; /** * Returns the effective limit, clamped to mandatory maximum. * Used when user provides a custom limit that might exceed mandatory caps. * * @param limitKey - The mandatory limit to clamp to * @param userLimit - The user-provided limit * @returns The effective limit (minimum of user limit and mandatory cap) */ export declare function clampToMandatoryLimit(limitKey: MandatoryLimitKey, userLimit: number): number; /** * Validates that all user-provided limits respect mandatory caps. * Throws ConfigurationError if any limit exceeds mandatory maximum. * * @param limits - Object mapping limit keys to user values * @throws ConfigurationError if any limit exceeds mandatory maximum */ export declare function validateLimitsAgainstMandatory(limits: Partial>): void;