/// import { Request } from '@loopback/rest'; import { XssConfig } from '../types'; import { SecurityLogger } from '../utils/security-logger'; /** * XSS detector that scans for cross-site scripting attack patterns */ export declare class XssDetector { private config?; private logger?; private readonly defaultPatterns; private patterns; private allowedTags; private allowedAttributes; private skipFields; constructor(config?: XssConfig | undefined, logger?: SecurityLogger | undefined, skipFields?: string[]); /** * Detect XSS attacks in the request */ detectXssAttacks(req: Request): Promise; /** * Check if a field should be skipped from XSS detection */ private shouldSkipField; /** * Scan object recursively for XSS patterns */ private scanObject; /** * Scan headers for XSS attempts */ private scanHeaders; /** * Scan header values with more restrictive patterns to avoid false positives * while still catching obvious XSS attempts */ private scanHeaderValueCarefully; /** * Helper method to log and throw XSS detection */ private logAndThrowXss; /** * Scan individual string value for XSS patterns */ private scanStringValue; /** * Decode various encodings to catch evasion attempts */ private decodeValue; /** * Check if content might be allowed based on configuration */ private isAllowedContent; /** * Determine if pattern represents high-risk XSS attempt */ private isHighRiskPattern; /** * Determine if pattern should be blocked even in non-strict mode */ private shouldBlockPattern; /** * Sanitize request data in place */ private sanitizeRequestData; /** * Apply sanitization to nested object structure */ private applySanitization; /** * Sanitize value for logging (remove sensitive content) */ private sanitizeLogValue; /** * Add custom pattern to detection */ addCustomPattern(pattern: RegExp): void; /** * Add allowed tag */ addAllowedTag(tag: string): void; /** * Add allowed attribute */ addAllowedAttribute(attribute: string): void; /** * Get detection statistics */ getStats(): Record; /** * Update configuration */ updateConfig(config: Partial): void; }