/** * Input Validator - Comprehensive Input Validation * * Provides Zod-based validation schemas for all security-critical inputs. * * Security Properties: * - Type-safe validation * - Custom error messages * - Sanitization transforms * - Reusable schemas * * @module v3/security/input-validator */ import { z } from 'zod'; /** * Common validation patterns as reusable regex */ declare const PATTERNS: { SAFE_IDENTIFIER: RegExp; SAFE_FILENAME: RegExp; SAFE_PATH_SEGMENT: RegExp; NO_SHELL_CHARS: RegExp; SEMVER: RegExp; }; /** * Validation limits */ declare const LIMITS: { MIN_PASSWORD_LENGTH: number; MAX_PASSWORD_LENGTH: number; MAX_EMAIL_LENGTH: number; MAX_IDENTIFIER_LENGTH: number; MAX_PATH_LENGTH: number; MAX_CONTENT_LENGTH: number; MAX_ARRAY_LENGTH: number; MAX_OBJECT_KEYS: number; }; /** * Safe string that cannot contain shell metacharacters */ export declare const SafeStringSchema: z.ZodString; /** * Safe identifier for IDs, names, etc. */ export declare const IdentifierSchema: z.ZodString; /** * Safe filename */ export declare const FilenameSchema: z.ZodString; /** * Email schema with length limit */ export declare const EmailSchema: z.ZodString; /** * Password schema with complexity requirements */ export declare const PasswordSchema: z.ZodEffects, string, string>, string, string>; /** * UUID schema */ export declare const UUIDSchema: z.ZodString; /** * URL schema with HTTPS enforcement */ export declare const HttpsUrlSchema: z.ZodEffects; /** * URL schema (allows HTTP for development) */ export declare const UrlSchema: z.ZodString; /** * Semantic version schema */ export declare const SemverSchema: z.ZodString; /** * Port number schema */ export declare const PortSchema: z.ZodNumber; /** * IP address schema (v4) */ export declare const IPv4Schema: z.ZodString; /** * IP address schema (v4 or v6) */ export declare const IPSchema: z.ZodString; /** * User role schema */ export declare const UserRoleSchema: z.ZodEnum<["admin", "operator", "developer", "viewer", "service"]>; /** * Permission schema */ export declare const PermissionSchema: z.ZodEnum<["swarm.create", "swarm.read", "swarm.update", "swarm.delete", "swarm.scale", "agent.spawn", "agent.read", "agent.terminate", "task.create", "task.read", "task.cancel", "metrics.read", "system.admin", "api.access"]>; /** * Login request schema */ export declare const LoginRequestSchema: z.ZodObject<{ email: z.ZodString; password: z.ZodString; mfaCode: z.ZodOptional; }, "strip", z.ZodTypeAny, { email: string; password: string; mfaCode?: string | undefined; }, { email: string; password: string; mfaCode?: string | undefined; }>; /** * User creation schema */ export declare const CreateUserSchema: z.ZodObject<{ email: z.ZodString; password: z.ZodEffects, string, string>, string, string>; role: z.ZodEnum<["admin", "operator", "developer", "viewer", "service"]>; permissions: z.ZodOptional, "many">>; isActive: z.ZodDefault>; }, "strip", z.ZodTypeAny, { email: string; password: string; role: "admin" | "operator" | "developer" | "viewer" | "service"; isActive: boolean; permissions?: ("swarm.create" | "swarm.read" | "swarm.update" | "swarm.delete" | "swarm.scale" | "agent.spawn" | "agent.read" | "agent.terminate" | "task.create" | "task.read" | "task.cancel" | "metrics.read" | "system.admin" | "api.access")[] | undefined; }, { email: string; password: string; role: "admin" | "operator" | "developer" | "viewer" | "service"; permissions?: ("swarm.create" | "swarm.read" | "swarm.update" | "swarm.delete" | "swarm.scale" | "agent.spawn" | "agent.read" | "agent.terminate" | "task.create" | "task.read" | "task.cancel" | "metrics.read" | "system.admin" | "api.access")[] | undefined; isActive?: boolean | undefined; }>; /** * API key creation schema */ export declare const CreateApiKeySchema: z.ZodObject<{ name: z.ZodString; permissions: z.ZodOptional, "many">>; expiresAt: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; permissions?: ("swarm.create" | "swarm.read" | "swarm.update" | "swarm.delete" | "swarm.scale" | "agent.spawn" | "agent.read" | "agent.terminate" | "task.create" | "task.read" | "task.cancel" | "metrics.read" | "system.admin" | "api.access")[] | undefined; expiresAt?: Date | undefined; }, { name: string; permissions?: ("swarm.create" | "swarm.read" | "swarm.update" | "swarm.delete" | "swarm.scale" | "agent.spawn" | "agent.read" | "agent.terminate" | "task.create" | "task.read" | "task.cancel" | "metrics.read" | "system.admin" | "api.access")[] | undefined; expiresAt?: Date | undefined; }>; /** * Agent type schema */ export declare const AgentTypeSchema: z.ZodEnum<["coder", "reviewer", "tester", "planner", "researcher", "security-architect", "security-auditor", "memory-specialist", "swarm-specialist", "integration-architect", "performance-engineer", "core-architect", "test-architect", "queen-coordinator", "project-coordinator"]>; /** * Agent spawn request schema */ export declare const SpawnAgentSchema: z.ZodObject<{ type: z.ZodEnum<["coder", "reviewer", "tester", "planner", "researcher", "security-architect", "security-auditor", "memory-specialist", "swarm-specialist", "integration-architect", "performance-engineer", "core-architect", "test-architect", "queen-coordinator", "project-coordinator"]>; id: z.ZodOptional; config: z.ZodOptional>; timeout: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator"; config?: Record | undefined; timeout?: number | undefined; id?: string | undefined; }, { type: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator"; config?: Record | undefined; timeout?: number | undefined; id?: string | undefined; }>; /** * Task input schema */ export declare const TaskInputSchema: z.ZodObject<{ taskId: z.ZodString; content: z.ZodString; agentType: z.ZodEnum<["coder", "reviewer", "tester", "planner", "researcher", "security-architect", "security-auditor", "memory-specialist", "swarm-specialist", "integration-architect", "performance-engineer", "core-architect", "test-architect", "queen-coordinator", "project-coordinator"]>; priority: z.ZodOptional>; metadata: z.ZodOptional>; }, "strip", z.ZodTypeAny, { taskId: string; content: string; agentType: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator"; priority?: "critical" | "high" | "medium" | "low" | undefined; metadata?: Record | undefined; }, { taskId: string; content: string; agentType: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator"; priority?: "critical" | "high" | "medium" | "low" | undefined; metadata?: Record | undefined; }>; /** * Command argument schema */ export declare const CommandArgumentSchema: z.ZodEffects, string, string>; /** * Path schema */ export declare const PathSchema: z.ZodEffects, string, string>; /** * Security configuration schema */ export declare const SecurityConfigSchema: z.ZodObject<{ bcryptRounds: z.ZodDefault; jwtExpiresIn: z.ZodDefault; sessionTimeout: z.ZodDefault; maxLoginAttempts: z.ZodDefault; lockoutDuration: z.ZodDefault; requireMFA: z.ZodDefault; }, "strip", z.ZodTypeAny, { bcryptRounds: number; jwtExpiresIn: string; sessionTimeout: number; maxLoginAttempts: number; lockoutDuration: number; requireMFA: boolean; }, { bcryptRounds?: number | undefined; jwtExpiresIn?: string | undefined; sessionTimeout?: number | undefined; maxLoginAttempts?: number | undefined; lockoutDuration?: number | undefined; requireMFA?: boolean | undefined; }>; /** * Executor configuration schema */ export declare const ExecutorConfigSchema: z.ZodObject<{ allowedCommands: z.ZodArray; blockedPatterns: z.ZodOptional>; timeout: z.ZodDefault; maxBuffer: z.ZodDefault; cwd: z.ZodOptional, string, string>>; allowSudo: z.ZodDefault; }, "strip", z.ZodTypeAny, { allowedCommands: string[]; timeout: number; maxBuffer: number; allowSudo: boolean; blockedPatterns?: string[] | undefined; cwd?: string | undefined; }, { allowedCommands: string[]; blockedPatterns?: string[] | undefined; timeout?: number | undefined; maxBuffer?: number | undefined; cwd?: string | undefined; allowSudo?: boolean | undefined; }>; /** * Sanitizes a string by removing dangerous characters */ export declare function sanitizeString(input: string): string; /** * Sanitizes HTML entities */ export declare function sanitizeHtml(input: string): string; /** * Sanitizes a path by removing traversal patterns */ export declare function sanitizePath(input: string): string; export declare class InputValidator { /** * Validates input against a schema */ static validate(schema: z.ZodSchema, input: unknown): T; /** * Safely validates input, returning result */ static safeParse(schema: z.ZodSchema, input: unknown): z.SafeParseReturnType; /** * Validates email */ static validateEmail(email: string): string; /** * Validates password */ static validatePassword(password: string): string; /** * Validates identifier */ static validateIdentifier(id: string): string; /** * Validates path */ static validatePath(path: string): string; /** * Validates command argument */ static validateCommandArg(arg: string): string; /** * Validates login request */ static validateLoginRequest(data: unknown): z.infer; /** * Validates user creation request */ static validateCreateUser(data: unknown): z.infer; /** * Validates task input */ static validateTaskInput(data: unknown): z.infer; } export { z, PATTERNS, LIMITS, }; //# sourceMappingURL=input-validator.d.ts.map