/** * File Organizer MCP Server v3.4.2 * Sensitive File Patterns * * Defines patterns for identifying and blocking access to sensitive files. * SECURITY: All patterns must be checked BEFORE any file read operation. * * @module readers/security/sensitive-file-patterns * @security Shepherd-Gamma Approved */ import { FileOrganizerError } from "../../errors.js"; /** * Error thrown when attempting to access a sensitive file * @extends FileOrganizerError */ export declare class FileReadError extends FileOrganizerError { readonly sensitivePath: string; readonly patternMatched: string; constructor(message: string, sensitivePath: string, patternMatched: string); } /** * Result type for operations that can succeed or fail * @template T Success value type * @template E Error type */ export type Result = { readonly success: true; readonly value: T; } | { readonly success: false; readonly error: E; }; /** * Success result factory * @param value - The successful value * @returns Result with success=true */ export declare function ok(value: T): Result; /** * Error result factory * @param error - The error value * @returns Result with success=false */ export declare function err(error: E): Result; /** * Sensitive file patterns that must be blocked from reading. * These patterns are checked BEFORE any file read operation. * * @security CRITICAL: Keep patterns in sync with security policy */ export declare const SENSITIVE_PATTERNS: RegExp[]; /** * Additional directory patterns that should be completely blocked * @security These directories are recursively blocked */ export declare const SENSITIVE_DIRECTORIES: RegExp[]; /** * Checks if a file path matches any sensitive file pattern. * This is a simple boolean check for use in guards and filters. * * @param filePath - The file path to check * @returns True if the path matches a sensitive file pattern * * @example * ```typescript * if (isSensitiveFile('/home/user/.env')) { * console.log('Blocked: sensitive file'); * } * ``` */ export declare function isSensitiveFile(filePath: string): boolean; /** * Comprehensive check for sensitive files with detailed result. * Returns a Result type that includes error details if blocked. * * SECURITY: This function MUST be called BEFORE any file read operation. * * @param filePath - The file path to validate * @returns Result - Success if not sensitive, error with details if sensitive * * @example * ```typescript * const result = checkSensitiveFile('/home/user/.env'); * if (!result.success) { * console.error(result.error.message); * return; * } * // Safe to proceed with file read * ``` */ export declare function checkSensitiveFile(filePath: string): Result; /** * Gets the first matching pattern for a sensitive file. * Useful for logging and debugging which pattern was matched. * * @param filePath - The file path to check * @returns The matched pattern string or null if not sensitive */ export declare function getMatchedPattern(filePath: string): string | null; /** * Sanitizes a file path for logging by redacting sensitive components. * Preserves structure but removes potentially sensitive filename details. * * @param filePath - The file path to sanitize * @returns Sanitized path safe for logging * * @example * ```typescript * sanitizePathForLogging('/home/user/.env') * // Returns: '/home/user/[REDACTED_SENSITIVE]' * ``` */ export declare function sanitizePathForLogging(filePath: string): string; /** * Extended pattern list for stricter security modes. * Includes additional patterns for high-security environments. */ export declare const STRICT_SENSITIVE_PATTERNS: RegExp[]; /** * Performs strict sensitive file check with extended pattern list. * Use this for high-security environments or when handling untrusted paths. * * @param filePath - The file path to check * @returns Result - Stricter check result */ export declare function checkSensitiveFileStrict(filePath: string): Result; //# sourceMappingURL=sensitive-file-patterns.d.ts.map