/** * MongoDB NoSQL Injection Sanitization * * Runs automatically on ALL filter/match inputs before they touch MongoDB. * Extracted from mongo.ts — pure code movement. */ import type { Document, Filter } from 'mongodb'; /** Programmatically enable or disable input sanitization at runtime. */ export declare function configureSanitization(enabled: boolean): void; /** * Recursively sanitize an object to prevent NoSQL injection. * - Allows known-safe MongoDB operators ($gte, $in, $regex, etc.) — values still sanitized * - Strips dangerous operators ($where, $function, $accumulator — JS execution) * - Strips unknown/unrecognized $ keys (defense in depth) * - Strips keys containing `.` (blocks path traversal like `field.nested`) * * This runs automatically on all filter/match inputs before they touch MongoDB. * Internal operations (like $set, $inc in update operators) are NOT sanitized * because they come from trusted application code, not user input. * * Disable with DB_SANITIZE_INPUTS=false or configureSanitization(false). */ export declare function sanitize(input: T): T; /** * Sanitize a filter object (user-facing queries like $match). * Exported for use in custom pipelines where you pass user input. */ export declare function sanitizeFilter(filter: Filter): Filter; /** * Sanitize an aggregation pipeline. * Only sanitizes the value inside $match stages (where user input goes). * Other stages ($sort, $limit, $lookup, etc.) are trusted application code. */ export declare function sanitizePipeline(pipeline: Document[]): Document[]; //# sourceMappingURL=mongo-sanitize.d.ts.map