UNPKG

pompelmi

Version:

RFI-safe file uploads for Node.js — Express/Koa/Next.js middleware with deep ZIP inspection, MIME/size checks, and optional YARA scanning.

111 lines (110 loc) 3.19 kB
/** * HIPAA Compliance Module for Pompelmi * * This module provides comprehensive HIPAA compliance features for healthcare environments * where Pompelmi is used to analyze potentially compromised systems containing PHI. * * Key protections: * - Data sanitization and redaction * - Secure temporary file handling * - Audit logging * - Memory protection * - Error message sanitization */ export interface HipaaConfig { enabled: boolean; auditLogPath?: string; encryptTempFiles?: boolean; sanitizeErrors?: boolean; sanitizeFilenames?: boolean; memoryProtection?: boolean; requireSecureTransport?: boolean; } export interface AuditEvent { timestamp: string; eventType: 'file_scan' | 'temp_file_created' | 'temp_file_deleted' | 'error_occurred' | 'phi_detected' | 'security_violation'; sessionId: string; userId?: string; details: { action: string; fileHash?: string; fileSizeBytes?: number; success: boolean; sanitizedError?: string; metadata?: Record<string, unknown>; }; } declare class HipaaComplianceManager { private config; private sessionId; private auditEvents; constructor(config: HipaaConfig); /** * Sanitize filename to prevent PHI leakage in logs */ sanitizeFilename(filename?: string): string; /** * Sanitize error messages to prevent PHI exposure */ sanitizeError(error: Error | string): string; /** * Create secure temporary file path with encryption if enabled */ createSecureTempPath(prefix?: string): string; /** * Get or create secure temporary directory with restricted permissions */ private getSecureTempDir; /** * Secure file cleanup with multiple overwrite passes */ secureFileCleanup(filePath: string): Promise<void>; /** * Calculate secure file hash for audit purposes */ calculateFileHash(data: Uint8Array): string; /** * Log audit event */ auditLog(eventType: AuditEvent['eventType'], details: Partial<AuditEvent['details']>): void; /** * Write audit event to file */ private writeAuditLog; /** * Generate cryptographically secure session ID */ private generateSessionId; /** * Get current audit events for this session */ getAuditEvents(): AuditEvent[]; /** * Clear sensitive data from memory */ clearSensitiveData(): void; /** * Validate transport security */ validateTransportSecurity(url?: string): boolean; } /** * Initialize HIPAA compliance */ export declare function initializeHipaaCompliance(config: HipaaConfig): HipaaComplianceManager; /** * Get current HIPAA compliance manager */ export declare function getHipaaManager(): HipaaComplianceManager | null; /** * HIPAA-compliant error wrapper */ export declare function createHipaaError(error: Error | string, context?: string): Error; /** * HIPAA-compliant temporary file utilities */ export declare const HipaaTemp: { createPath: (prefix?: string) => string; cleanup: (filePath: string) => Promise<void>; }; export { HipaaComplianceManager };