/** * EncodingDetector * * Detects and blocks encoding-based bypass attempts: * - Base64 encoded payloads * - URL encoded attacks * - Unicode/punycode obfuscation * - Hex encoding * - HTML entity encoding * - Mixed encoding attacks */ import { GuardLogger } from "../types"; export interface EncodingDetectorConfig { detectBase64?: boolean; detectURLEncoding?: boolean; detectUnicode?: boolean; detectHex?: boolean; detectHTMLEntities?: boolean; detectMixedEncoding?: boolean; detectROT13?: boolean; detectOctal?: boolean; detectBase32?: boolean; maxDecodingDepth?: number; threatPatterns?: ThreatPattern[]; maxEncodedRatio?: number; logger?: GuardLogger; } export interface ThreatPattern { name: string; pattern: RegExp; severity: "low" | "medium" | "high" | "critical"; } export interface EncodingDetectorResult { allowed: boolean; reason?: string; violations: string[]; encoding_analysis: { encodings_detected: EncodingDetection[]; decoded_content?: string; threats_found: ThreatFound[]; obfuscation_score: number; }; } export interface EncodingDetection { type: string; count: number; locations: string[]; decoded_sample?: string; } export interface ThreatFound { pattern_name: string; severity: string; in_layer: string; } export declare class EncodingDetector { private config; private logger; private defaultThreatPatterns; constructor(config?: EncodingDetectorConfig); /** * Detect encoding and analyze for threats */ detect(input: string, requestId?: string): EncodingDetectorResult; /** * Quick check if input contains encoded threats */ containsEncodedThreat(input: string): boolean; private detectBase64; private detectURLEncoding; private detectUnicode; private detectHex; private detectHTMLEntities; private detectROT13; private detectOctal; private detectBase32; private checkThreats; private fullyDecode; }