/** * Input validation for claude-config.ts security * * Implements CWE-22 path traversal prevention and input sanitization * for GitHub parameters and file operations. * * @module validation */ /** * Validation error class with structured error information */ export declare class ValidationError extends Error { readonly field: string; readonly value: any; constructor(message: string, field: string, value: any); } /** * Validate project path to prevent path traversal attacks (CWE-22) * * Security checks: * - Must be absolute path * - No path traversal sequences (../) * - No null bytes * - Path must resolve to itself (no symlink tricks) * * @param projectPath - Path to validate * @throws {ValidationError} If validation fails */ export declare function validateProjectPath(projectPath: string): void; /** * Validate GitHub owner name * * GitHub username rules: * - Alphanumeric and hyphens only * - Cannot start or end with hyphen * - Max 39 characters * - Cannot be empty * * @param owner - GitHub owner/username to validate * @throws {ValidationError} If validation fails */ export declare function validateGitHubOwner(owner: string): void; /** * Validate GitHub repository name * * GitHub repository rules: * - Alphanumeric, hyphens, underscores, and dots * - Cannot start with dot or hyphen * - Max 100 characters * - Cannot be empty * * @param repo - GitHub repository name to validate * @throws {ValidationError} If validation fails */ export declare function validateGitHubRepo(repo: string): void; /** * Validate GitHub token format * * GitHub token formats: * - Personal Access Token (classic): ghp_[A-Za-z0-9]{36} * - Fine-grained PAT: github_pat_[A-Za-z0-9_]{82} * - OAuth: gho_[A-Za-z0-9]{36} * - User-to-server: ghu_[A-Za-z0-9]{36} * - Server-to-server: ghs_[A-Za-z0-9]{36} * - Refresh: ghr_[A-Za-z0-9]{36} * * @param token - GitHub token to validate * @throws {ValidationError} If validation fails */ export declare function validateGitHubToken(token: string): void; /** * Validate project name * * Project name rules: * - Non-empty string * - Max 100 characters * - Safe characters only (alphanumeric, hyphens, underscores, spaces) * - No path traversal sequences * * @param projectName - Project name to validate * @throws {ValidationError} If validation fails */ export declare function validateProjectName(projectName: string): void; /** * Validate file path for safe file operations * * Security checks: * - Must be absolute path * - No path traversal sequences * - No null bytes * - Must be within expected directory * * @param filePath - File path to validate * @param baseDir - Optional base directory to restrict path within * @throws {ValidationError} If validation fails */ export declare function validateFilePath(filePath: string, baseDir?: string): void; /** * Validate file size before operations * * Security checks: * - File exists * - Size within reasonable limits (default 10MB) * - Not a directory * * @param filePath - File path to check * @param maxSizeBytes - Maximum allowed size in bytes (default 10MB) * @throws {ValidationError} If validation fails */ export declare function validateFileSize(filePath: string, maxSizeBytes?: number): void; /** * Validate file content for safe operations * * Security checks: * - UTF-8 encoding * - No null bytes * - Reasonable line length * - No binary content * * @param content - File content to validate * @throws {ValidationError} If validation fails */ export declare function validateFileContent(content: string): void; /** * Validate and detect symlinks * * Security checks: * - Detect symbolic links * - Prevent symlink attacks * - Ensure file is a regular file * * @param filePath - File path to check * @throws {ValidationError} If file is a symlink */ export declare function validateSymlink(filePath: string): void; /** * Sanitize template variables to prevent template injection * * Security checks: * - Remove special characters used in template injection * - Limit length * - Allow only safe characters * * @param value - Template variable value to sanitize * @param maxLength - Maximum allowed length (default 200) * @returns Sanitized value * @throws {ValidationError} If value cannot be sanitized safely */ export declare function sanitizeTemplateVariable(value: string, maxLength?: number): string; /** * Validate all parameters for deployClaudeConfig * * Convenience function to validate all parameters at once * * @param projectPath - Project path to validate * @param projectName - Project name to validate * @throws {ValidationError} If any validation fails */ export declare function validateDeployClaudeConfigParams(projectPath: string, projectName: string): void; /** * Validate all parameters for deployClaudeConfigToGitHub * * Convenience function to validate all parameters at once * * @param owner - GitHub owner to validate * @param repo - GitHub repository to validate * @param projectName - Project name to validate * @param token - GitHub token to validate * @throws {ValidationError} If any validation fails */ export declare function validateDeployToGitHubParams(owner: string, repo: string, projectName: string, token: string): void; //# sourceMappingURL=validation.d.ts.map