/** * Pass #28: infinite-loop (CWE-835, category: reliability) * * Detects loops with no reachable exit edge — i.e., loops that can run * forever because every execution path through the loop body leads back to * the loop header without a break, return, throw, or continue-to-outer. * * Detection strategy: * 1. Identify loop headers: back-edge targets in the CFG (`edge.type === 'back'`). * 2. For each loop, collect the loop body blocks via BFS from the header, * stopping at back-edge sources (the "tail" blocks). * 3. Check whether any block in the body has an outgoing edge that exits * the loop (target not in body set and not back to header). * 4. As a text-level fallback, scan source lines in the loop body for * `return`, `throw`/`raise`, `break`, `System.exit` keywords. * 5. Emit a finding at the loop header's start_line if no exit is found. * * Languages: Java, JavaScript, TypeScript, Python, Rust. Skip Bash. */ import type { AnalysisPass, PassContext } from '../../graph/analysis-pass.js'; export interface InfiniteLoopResult { potentialInfiniteLoops: Array<{ headerLine: number; bodyEndLine: number; }>; } export declare class InfiniteLoopPass implements AnalysisPass { readonly name = "infinite-loop"; readonly category: "reliability"; run(ctx: PassContext): InfiniteLoopResult; } //# sourceMappingURL=infinite-loop-pass.d.ts.map