import { CorsConfig, ErrorResponseConfig, FileUploadConfig, LoggingConfig, SecurityConfig, SecurityHeadersConfig, SqlInjectionConfig, ValidationConfig, XssConfig } from '../types'; /** * Default CORS configuration */ export const DEFAULT_CORS_CONFIG: Required = { enabled: true, origin: ["*.flavorcloud.com", "http://localhost:*", "https://localhost:*", "http://127.0.0.1:*", "https://127.0.0.1:*"], methods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE', 'OPTIONS'], allowedHeaders: [ 'Content-Type', 'Authorization', 'X-Requested-With', 'Accept', 'Accept-Language', 'Accept-Encoding', 'Cache-Control', 'Connection', 'Host', 'Origin', 'Referer', 'User-Agent', 'access-control-allow-origin', 'root-request-id', 'X-CSRF-Token', 'X-Forwarded-For', 'X-Real-IP', 'X-API-Key' ], credentials: true, maxAge: 86400, // 24 hours preflightContinue: false, optionsSuccessStatus: 204 }; /** * Default input validation configuration */ export const DEFAULT_VALIDATION_CONFIG: Required = { enabled: true, sanitizeInput: false, maxBodySize: '10mb', maxParameterLength: 1000, allowedFileTypes: ['.jpg', '.jpeg', '.png', '.pdf', '.doc', '.docx', '.txt'], maxFileSize: 5 * 1024 * 1024, // 5MB validateEmails: false, validateUrls: false, validatePhoneNumbers: false, validateParamLength: false, detectCsvInjection: true, csvInjectionWhitelistedFields: ['phoneNumber', 'phone', 'mobile', 'tel', 'contactNumber', 'contact'], strictMode: false, skipSuspiciousPatterns: false, whitelistedPatterns: [], preserveSlashFields: ['key', 'path', 'filepath', 'filename', 'url', 'uri', 's3key'] }; /** * Default security headers configuration */ export const DEFAULT_SECURITY_HEADERS_CONFIG: Required = { enabled: true, contentSecurityPolicy: true, hsts: {maxAge: 31536000, includeSubDomains: false, preload: false}, noSniff: true, xssFilter: true, referrerPolicy: 'strict-origin-when-cross-origin', frameOptions: 'SAMEORIGIN', // Changed from DENY to SAMEORIGIN for better compatibility permittedCrossDomainPolicies: false, hidePoweredBy: true }; /** * Default SQL injection protection configuration */ export const DEFAULT_SQL_INJECTION_CONFIG: Required = { enabled: true, enableProtection: true, whitelistQueries: [], customPatterns: [], strictMode: false, blockSuspiciousPatterns: true }; /** * Default XSS protection configuration */ export const DEFAULT_XSS_CONFIG: Required = { enabled: true, enableProtection: true, customPatterns: [], sanitizeInput: true, strictMode: false, allowedTags: [], allowedAttributes: [] }; /** * Default logging configuration */ export const DEFAULT_LOGGING_CONFIG: Required = { enabled: true, logLevel: 'info', logSuspiciousActivity: true, logSuccessfulRequests: false, logFailedRequests: true, includeRequestDetails: true, includeResponseDetails: false, maskSensitiveData: true, sensitiveFields: ['password', 'token', 'secret', 'key', 'auth', 'credential'] }; /** * Default error response configuration - controls what clients see when security violations occur */ export const DEFAULT_ERROR_RESPONSE_CONFIG: Required = { exposeDetailedErrors: false, // By default, use generic error messages for security customErrorMessage: 'Request blocked by server' // Default generic message sent to clients }; /** * Default file upload configuration */ export const DEFAULT_FILE_UPLOAD_CONFIG: Required = { enabled: false, maxFileSize: 5 * 1024 * 1024, // 5MB maxFiles: 10, allowedMimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf'], allowedExtensions: ['.jpg', '.jpeg', '.png', '.gif', '.pdf'], scanForMalware: false, quarantineInfected: false, validateFileHeaders: true, validateContent: false, allowExecutables: false, quarantinePath: '/tmp/quarantine' }; /** * Default field names to skip from security checks */ export const DEFAULT_SKIP_FIELDS: string[] = [ 'password', 'pwd', 'passwd', 'secret', 'token', 'auth', 'credential', 'credentials', 'apiKey', 'api_key', 'privateKey', 'private_key', 'secretKey', 'secret_key' ]; /** * Default URL patterns to skip from security checks */ export const DEFAULT_SKIP_URLS: string[] = [ // Add default URL patterns here if needed ]; /** * Default health check paths that bypass security */ export const DEFAULT_HEALTH_CHECK_PATHS: string[] = [ '/health', '/status', '/live', '/ready', '/ping', '/healthcheck', '/health-check', '/server-status', ]; /** * Default comprehensive security configuration */ export const DEFAULT_SECURITY_CONFIG: Required = { skip: false, cors: DEFAULT_CORS_CONFIG, validation: DEFAULT_VALIDATION_CONFIG, headers: DEFAULT_SECURITY_HEADERS_CONFIG, sqlInjection: DEFAULT_SQL_INJECTION_CONFIG, xss: DEFAULT_XSS_CONFIG, logging: DEFAULT_LOGGING_CONFIG, fileUpload: DEFAULT_FILE_UPLOAD_CONFIG, errorResponse: DEFAULT_ERROR_RESPONSE_CONFIG, enableAllProtections: true, skipOnError: false, healthCheckPaths: DEFAULT_HEALTH_CHECK_PATHS, skipFields: DEFAULT_SKIP_FIELDS, skipUrls: DEFAULT_SKIP_URLS };