@noanswer/context-compose
Version:
Orchestrate complex AI interactions with Context Compose. A powerful CLI and server for building, validating, and managing context for large language models using the Model Context Protocol (MCP).
79 lines (78 loc) • 2.11 kB
TypeScript
import { z } from 'zod';
/**
* Security utilities for path validation and input sanitization
*/
/**
* Path traversal attack prevention
*/
export declare class PathValidator {
private allowedBasePaths;
constructor(allowedBasePaths?: string[]);
/**
* Validate that a path is safe and within allowed directories
*/
validatePath(inputPath: string, basePath?: string): string;
/**
* Validate context compose specific paths
*/
validateContextPath(inputPath: string, projectRoot: string): string;
/**
* Add allowed base path
*/
addAllowedPath(basePath: string): void;
}
/**
* Input validation schemas
*/
export declare const SecuritySchemas: {
safeFilename: z.ZodString;
contextName: z.ZodString;
projectRoot: z.ZodEffects<z.ZodString, string, string>;
yamlFile: z.ZodString;
};
/**
* Sanitize string input by removing dangerous characters
*/
export declare function sanitizeString(input: string, maxLength?: number): string;
/**
* Sanitize filename
*/
export declare function sanitizeFilename(filename: string): string;
/**
* Validate and sanitize context name
*/
export declare function sanitizeContextName(contextName: string): string;
/**
* Check if environment variable key is sensitive
*/
export declare function isSensitiveKey(key: string): boolean;
/**
* Mask sensitive environment variable value
*/
export declare function maskSensitiveValue(key: string, value: string): string;
/**
* Get safe environment variables for logging
*/
export declare function getSafeEnvVars(): Record<string, string>;
/**
* Rate limiting for security
*/
export declare class RateLimiter {
private requests;
private maxRequests;
private windowMs;
constructor(maxRequests?: number, windowMs?: number);
/**
* Check if request is allowed
*/
isAllowed(identifier: string): boolean;
/**
* Clear old entries periodically
*/
cleanup(): void;
}
/**
* Global instances
*/
export declare const defaultPathValidator: PathValidator;
export declare const defaultRateLimiter: RateLimiter;