/** * Evaluation context for query execution * * Tracks state during query evaluation including current position, * filter context, and caching information. */ import type { TONLValue } from '../types.js'; /** * Evaluation context - tracks state during query execution * SECURITY FIX (BF012): Added iteration tracking to prevent query DoS */ export interface EvaluationContext { /** * The root document being queried */ root: TONLValue; /** * Current value being evaluated (for filter expressions with @) */ current?: TONLValue; /** * Maximum recursion depth to prevent infinite loops */ maxDepth: number; /** * Current recursion depth */ currentDepth: number; /** * Maximum iterations (nodes visited) to prevent DoS * SECURITY FIX (BF012): Default 100,000 iterations */ maxIterations: number; /** * Current iteration count * SECURITY FIX (BF012): Tracks total nodes visited */ iterations: number; /** * Whether to enable query result caching */ enableCache: boolean; /** * Cache of evaluated queries (path string -> result) */ cache?: Map; } /** * Create a new evaluation context */ export declare function createContext(root: TONLValue, options?: { maxDepth?: number; maxIterations?: number; enableCache?: boolean; }): EvaluationContext; /** * Create a child context for nested evaluation */ export declare function createChildContext(parent: EvaluationContext, current: TONLValue): EvaluationContext; /** * Check if recursion depth limit has been reached */ export declare function isMaxDepthReached(context: EvaluationContext): boolean; /** * Check and increment iteration counter * SECURITY FIX (BF012): Prevents query DoS via excessive iterations */ export declare function checkIterationLimit(context: EvaluationContext): void; /** * Get cached result for a path */ export declare function getCachedResult(context: EvaluationContext, pathKey: string): any | undefined; /** * Cache a query result */ export declare function cacheResult(context: EvaluationContext, pathKey: string, result: any): void; /** * Clear the query cache */ export declare function clearCache(context: EvaluationContext): void; /** * Generate a cache key from path nodes */ export declare function generateCacheKey(pathNodes: any[]): string; //# sourceMappingURL=context.d.ts.map