/** * Copyright (c) 2025 Ofri Peretz * Licensed under the MIT License. Use of this source code is governed by the * MIT license that can be found in the LICENSE file. */ /** * ESLint Rule: no-unchecked-loop-condition * Detects unchecked loop conditions that could cause DoS (CWE-400, CWE-606) * * Loops with unchecked conditions can cause denial of service by consuming * excessive CPU time or memory. This includes infinite loops, loops with * user-controlled bounds, and loops without proper termination conditions. * * False Positive Reduction: * This rule uses security utilities to reduce false positives by detecting: * - Safe loop patterns with clear termination * - Development/debugging loops * - JSDoc annotations (@safe-loop, @intentional) * - Timeout protections */ import type { TSESLint } from '@interlace/eslint-devkit'; import { type SecurityRuleOptions } from '@interlace/eslint-devkit'; type MessageIds = 'uncheckedLoopCondition' | 'infiniteLoop' | 'userControlledLoopBound' | 'missingLoopTermination' | 'largeLoopBound' | 'unsafeRecursion' | 'limitLoopIterations'; export interface Options extends SecurityRuleOptions { /** Maximum allowed loop iterations for static analysis */ maxStaticIterations?: number; /** Variables that contain user input */ userInputVariables?: string[]; /** Allow while(true) loops with breaks */ allowWhileTrueWithBreak?: boolean; /** Maximum recursion depth to allow */ maxRecursionDepth?: number; } type RuleOptions = [Options?]; export declare const noUncheckedLoopCondition: TSESLint.RuleModule & { name: string; }; export {};