pompelmi 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Dynamic Taint Analysis Engine
3
+ *
4
+ * Advanced taint tracking implementation for comprehensive data flow analysis
5
+ * with support for memory tainting, register tracking, and vulnerability detection.
6
+ */
7
+ import type { TaintSource, TaintLabel, TaintedMemory, TaintedRegister, TaintConfig, TaintAnalysisResult, TaintCapableEngine } from '../types/taint-tracking';
8
+ /**
9
+ * Advanced dynamic taint analysis engine with comprehensive tracking capabilities
10
+ */
11
+ export declare class DynamicTaintEngine implements TaintCapableEngine {
12
+ private config;
13
+ private memoryState;
14
+ private registerState;
15
+ private taintLabels;
16
+ private propagationRules;
17
+ private analysisSession;
18
+ private hipaa;
19
+ private analysisStartTime;
20
+ private instructionCount;
21
+ constructor(config?: Partial<TaintConfig>);
22
+ private createDefaultConfig;
23
+ private createHipaaUtilities;
24
+ private createDefaultRules;
25
+ /**
26
+ * Configure taint tracking settings
27
+ */
28
+ configureTaint(config: TaintConfig): Promise<void>;
29
+ /**
30
+ * Perform comprehensive taint analysis on binary data
31
+ */
32
+ performTaintAnalysis(data: Uint8Array): Promise<TaintAnalysisResult>;
33
+ /**
34
+ * Get current taint state for debugging and analysis
35
+ */
36
+ getTaintState(): Promise<{
37
+ memory: TaintedMemory[];
38
+ registers: TaintedRegister[];
39
+ }>;
40
+ /**
41
+ * Add a custom taint source at a specific location
42
+ */
43
+ addTaintSource(address: string, source: TaintSource, label?: Partial<TaintLabel>): Promise<void>;
44
+ /**
45
+ * Check if a memory location is currently tainted
46
+ */
47
+ isTainted(address: string): Promise<boolean>;
48
+ /**
49
+ * Identify entry points and potential taint sources through static analysis
50
+ */
51
+ private identifyEntryPoints;
52
+ /**
53
+ * Initialize taint sources based on identified entry points
54
+ */
55
+ private initializeTaintSources;
56
+ /**
57
+ * Perform taint propagation analysis through simulated execution
58
+ */
59
+ private performTaintPropagation;
60
+ /**
61
+ * Generate simulated instructions for demonstration
62
+ * In practice, this would come from a real dynamic analysis engine
63
+ */
64
+ private generateSimulatedInstructions;
65
+ /**
66
+ * Process a single instruction for taint propagation
67
+ */
68
+ private processInstruction;
69
+ /**
70
+ * Find the best matching propagation rule for an instruction
71
+ */
72
+ private findMatchingRule;
73
+ /**
74
+ * Get taint information from source operands
75
+ */
76
+ private getSourceTaints;
77
+ /**
78
+ * Get taint labels associated with an operand
79
+ */
80
+ private getTaintsForOperand;
81
+ /**
82
+ * Propagate taint from sources to destinations
83
+ */
84
+ private propagateTaint;
85
+ /**
86
+ * Create a taint flow when reaching a sink
87
+ */
88
+ private createTaintFlow;
89
+ /**
90
+ * Analyze flows for security vulnerabilities
91
+ */
92
+ private analyzeVulnerabilities;
93
+ private getTotalSources;
94
+ private getTotalSinks;
95
+ private isFlowSanitized;
96
+ private isAddressInRange;
97
+ private isRegister;
98
+ private determineSinkType;
99
+ private calculateSeverity;
100
+ private getCWEForSink;
101
+ private getSuggestedMitigations;
102
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Hybrid Analysis Orchestrator
3
+ *
4
+ * Advanced orchestration framework for coordinating multiple analysis engines
5
+ * including Binary Ninja, Ghidra, dynamic taint tracking, and custom engines.
6
+ */
7
+ import type { AnalysisEngine, AnalysisPhase, EngineCapability, HybridConfig, HybridAnalysisResult, HybridOrchestrator } from '../types/taint-tracking';
8
+ /**
9
+ * Main hybrid orchestration engine
10
+ */
11
+ export declare class HybridAnalysisOrchestrator implements HybridOrchestrator {
12
+ private config;
13
+ private engines;
14
+ private correlator;
15
+ private activeSessions;
16
+ /**
17
+ * Configure the orchestrator
18
+ */
19
+ configure(config: HybridConfig): Promise<void>;
20
+ /**
21
+ * Register an analysis engine with the orchestrator
22
+ */
23
+ registerEngine(engine: AnalysisEngine, instance: any, capabilities: EngineCapability): Promise<void>;
24
+ /**
25
+ * Execute comprehensive hybrid analysis
26
+ */
27
+ analyze(data: Uint8Array): Promise<HybridAnalysisResult>;
28
+ /**
29
+ * Get available engines and their capabilities
30
+ */
31
+ getAvailableEngines(): Promise<EngineCapability[]>;
32
+ /**
33
+ * Cancel ongoing analysis
34
+ */
35
+ cancelAnalysis(sessionId: string): Promise<boolean>;
36
+ /**
37
+ * Get analysis progress
38
+ */
39
+ getProgress(sessionId: string): Promise<{
40
+ phase: AnalysisPhase;
41
+ completedTasks: number;
42
+ totalTasks: number;
43
+ estimatedTimeRemaining: number;
44
+ }>;
45
+ /**
46
+ * Generate analysis tasks based on orchestration strategy
47
+ */
48
+ private generateAnalysisTasks;
49
+ /**
50
+ * Execute tasks with proper scheduling and dependency management
51
+ */
52
+ private executeTasks;
53
+ /**
54
+ * Execute a single analysis task
55
+ */
56
+ private executeTask;
57
+ private calculateTaskDependencies;
58
+ private calculateTaskPriority;
59
+ private estimateTaskDuration;
60
+ private calculateResultConfidence;
61
+ private findTaskEngine;
62
+ private determineCurrentPhase;
63
+ private generateHybridResult;
64
+ private generateRecommendations;
65
+ }
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Hybrid Taint Analysis Integration
3
+ *
4
+ * Complete integration package for dynamic taint tracking and hybrid orchestration
5
+ * with existing Pompelmi decompilation engines and HIPAA compliance.
6
+ */
7
+ import type { TaintConfig, TaintAnalysisResult, HybridConfig, HybridAnalysisResult, AnalysisEngine } from '../types/taint-tracking';
8
+ import type { TaintPolicy } from './taint-policies';
9
+ import type { DecompilationScanner, DecompilationResult } from '../types/decompilation';
10
+ /**
11
+ * Enhanced analysis result combining all engines
12
+ */
13
+ export interface EnhancedAnalysisResult {
14
+ /** Analysis session ID */
15
+ sessionId: string;
16
+ /** Overall success status */
17
+ success: boolean;
18
+ /** Total analysis time */
19
+ totalTime: number;
20
+ /** Static analysis results */
21
+ static?: {
22
+ binaryNinja?: DecompilationResult;
23
+ ghidra?: DecompilationResult;
24
+ };
25
+ /** Dynamic taint analysis results */
26
+ taint?: TaintAnalysisResult;
27
+ /** Hybrid orchestration results */
28
+ hybrid?: HybridAnalysisResult;
29
+ /** Policy used for analysis */
30
+ policy?: TaintPolicy;
31
+ /** Security assessment */
32
+ security: {
33
+ riskScore: number;
34
+ vulnerabilities: Array<{
35
+ type: string;
36
+ severity: 'low' | 'medium' | 'high' | 'critical';
37
+ confidence: number;
38
+ description: string;
39
+ evidence: any;
40
+ mitigations: string[];
41
+ }>;
42
+ recommendations: string[];
43
+ };
44
+ /** Compliance assessment */
45
+ compliance?: {
46
+ hipaaCompliant: boolean;
47
+ issues: Array<{
48
+ type: string;
49
+ severity: 'info' | 'warning' | 'critical';
50
+ description: string;
51
+ remediation: string;
52
+ }>;
53
+ auditTrail: any[];
54
+ };
55
+ /** Performance metrics */
56
+ performance: {
57
+ enginesUsed: AnalysisEngine[];
58
+ totalInstructions: number;
59
+ memoryPeak: number;
60
+ cpuTime: number;
61
+ };
62
+ }
63
+ /**
64
+ * Main integration class for hybrid taint analysis
65
+ */
66
+ export declare class HybridTaintAnalyzer {
67
+ private orchestrator;
68
+ private policyManager;
69
+ private taintEngine;
70
+ private registeredEngines;
71
+ constructor();
72
+ /**
73
+ * Initialize the analyzer with registered engines
74
+ */
75
+ initialize(engines: {
76
+ binaryNinja?: DecompilationScanner;
77
+ ghidra?: DecompilationScanner;
78
+ }): Promise<void>;
79
+ /**
80
+ * Perform comprehensive analysis using specified policy
81
+ */
82
+ analyze(data: Uint8Array, policyName?: string, options?: {
83
+ enabledEngines?: AnalysisEngine[];
84
+ customConfig?: Partial<HybridConfig>;
85
+ includeCompliance?: boolean;
86
+ }): Promise<EnhancedAnalysisResult>;
87
+ /**
88
+ * Get available analysis policies
89
+ */
90
+ getAvailablePolicies(): TaintPolicy[];
91
+ /**
92
+ * Get policies by use case
93
+ */
94
+ getPoliciesByUseCase(useCase: 'malware' | 'vulnerability' | 'compliance' | 'forensics' | 'general'): TaintPolicy[];
95
+ /**
96
+ * Register a custom analysis policy
97
+ */
98
+ registerPolicy(policy: TaintPolicy): void;
99
+ /**
100
+ * Perform quick taint analysis without full orchestration
101
+ */
102
+ quickTaintAnalysis(data: Uint8Array, config?: Partial<TaintConfig>): Promise<TaintAnalysisResult>;
103
+ /**
104
+ * Check if data contains taint at specific location
105
+ */
106
+ checkTaint(address: string): Promise<boolean>;
107
+ /**
108
+ * Add custom taint source for analysis
109
+ */
110
+ addTaintSource(address: string, source: string, metadata?: any): Promise<void>;
111
+ private registerEngine;
112
+ private createEngineCapabilities;
113
+ private createHybridConfig;
114
+ private mergeConfigs;
115
+ private processResults;
116
+ private extractStaticResults;
117
+ private calculateSecurityAssessment;
118
+ private calculateComplianceAssessment;
119
+ private calculatePerformanceMetrics;
120
+ private generateSecurityRecommendations;
121
+ private generateAuditTrail;
122
+ private getDefaultTaintConfig;
123
+ private generateSessionId;
124
+ private createFailureResult;
125
+ }
126
+ export declare function analyzeWithTaint(data: Uint8Array, engines: {
127
+ binaryNinja?: DecompilationScanner;
128
+ ghidra?: DecompilationScanner;
129
+ }, policy?: string): Promise<EnhancedAnalysisResult>;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Taint Analysis Policy Configuration
3
+ *
4
+ * Predefined and configurable taint analysis policies for different
5
+ * analysis scenarios including malware analysis, vulnerability assessment,
6
+ * and compliance auditing.
7
+ */
8
+ import type { TaintConfig, OrchestrationStrategy, HybridConfig, AnalysisEngine } from '../types/taint-tracking';
9
+ /**
10
+ * Policy template for different analysis scenarios
11
+ */
12
+ export interface TaintPolicy {
13
+ /** Policy identifier */
14
+ name: string;
15
+ /** Policy description */
16
+ description: string;
17
+ /** Target use case */
18
+ useCase: 'malware' | 'vulnerability' | 'compliance' | 'forensics' | 'general';
19
+ /** Taint tracking configuration */
20
+ taintConfig: TaintConfig;
21
+ /** Hybrid orchestration strategy */
22
+ orchestrationStrategy: OrchestrationStrategy;
23
+ /** Additional metadata */
24
+ metadata: {
25
+ version: string;
26
+ author: string;
27
+ created: string;
28
+ tags: string[];
29
+ riskLevel: 'low' | 'medium' | 'high' | 'critical';
30
+ };
31
+ }
32
+ /**
33
+ * Predefined taint policies for common analysis scenarios
34
+ */
35
+ export declare class TaintPolicyManager {
36
+ private policies;
37
+ private customRules;
38
+ constructor();
39
+ /**
40
+ * Get a policy by name
41
+ */
42
+ getPolicy(name: string): TaintPolicy | null;
43
+ /**
44
+ * Get all available policies
45
+ */
46
+ getAllPolicies(): TaintPolicy[];
47
+ /**
48
+ * Get policies by use case
49
+ */
50
+ getPoliciesByUseCase(useCase: TaintPolicy['useCase']): TaintPolicy[];
51
+ /**
52
+ * Register a custom policy
53
+ */
54
+ registerPolicy(policy: TaintPolicy): void;
55
+ /**
56
+ * Create a hybrid configuration from a policy
57
+ */
58
+ createHybridConfig(policyName: string, engineOverrides?: {
59
+ [engine in AnalysisEngine]?: {
60
+ enabled: boolean;
61
+ config?: any;
62
+ };
63
+ }): HybridConfig;
64
+ /**
65
+ * Initialize predefined policies
66
+ */
67
+ private initializePredefinedPolicies;
68
+ /**
69
+ * Create orchestration strategies for different policies
70
+ */
71
+ private createMalwareStrategy;
72
+ private createVulnerabilityStrategy;
73
+ private createComplianceStrategy;
74
+ private createForensicsStrategy;
75
+ private createFastScreeningStrategy;
76
+ /**
77
+ * Generate custom taint propagation rules for different use cases
78
+ */
79
+ private getMalwareAnalysisRules;
80
+ private getVulnerabilityAssessmentRules;
81
+ private getComplianceAuditRules;
82
+ private getForensicsAnalysisRules;
83
+ private getFastScreeningRules;
84
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * HIPAA Compliance Module for Pompelmi
3
+ *
4
+ * This module provides comprehensive HIPAA compliance features for healthcare environments
5
+ * where Pompelmi is used to analyze potentially compromised systems containing PHI.
6
+ *
7
+ * Key protections:
8
+ * - Data sanitization and redaction
9
+ * - Secure temporary file handling
10
+ * - Audit logging
11
+ * - Memory protection
12
+ * - Error message sanitization
13
+ */
14
+ export interface HipaaConfig {
15
+ enabled: boolean;
16
+ auditLogPath?: string;
17
+ encryptTempFiles?: boolean;
18
+ sanitizeErrors?: boolean;
19
+ sanitizeFilenames?: boolean;
20
+ memoryProtection?: boolean;
21
+ requireSecureTransport?: boolean;
22
+ }
23
+ export interface AuditEvent {
24
+ timestamp: string;
25
+ eventType: 'file_scan' | 'temp_file_created' | 'temp_file_deleted' | 'error_occurred' | 'phi_detected' | 'security_violation';
26
+ sessionId: string;
27
+ userId?: string;
28
+ details: {
29
+ action: string;
30
+ fileHash?: string;
31
+ fileSizeBytes?: number;
32
+ success: boolean;
33
+ sanitizedError?: string;
34
+ metadata?: Record<string, unknown>;
35
+ };
36
+ }
37
+ declare class HipaaComplianceManager {
38
+ private config;
39
+ private sessionId;
40
+ private auditEvents;
41
+ constructor(config: HipaaConfig);
42
+ /**
43
+ * Sanitize filename to prevent PHI leakage in logs
44
+ */
45
+ sanitizeFilename(filename?: string): string;
46
+ /**
47
+ * Sanitize error messages to prevent PHI exposure
48
+ */
49
+ sanitizeError(error: Error | string): string;
50
+ /**
51
+ * Create secure temporary file path with encryption if enabled
52
+ */
53
+ createSecureTempPath(prefix?: string): string;
54
+ /**
55
+ * Get or create secure temporary directory with restricted permissions
56
+ */
57
+ private getSecureTempDir;
58
+ /**
59
+ * Secure file cleanup with multiple overwrite passes
60
+ */
61
+ secureFileCleanup(filePath: string): Promise<void>;
62
+ /**
63
+ * Calculate secure file hash for audit purposes
64
+ */
65
+ calculateFileHash(data: Uint8Array): string;
66
+ /**
67
+ * Log audit event
68
+ */
69
+ auditLog(eventType: AuditEvent['eventType'], details: Partial<AuditEvent['details']>): void;
70
+ /**
71
+ * Write audit event to file
72
+ */
73
+ private writeAuditLog;
74
+ /**
75
+ * Generate cryptographically secure session ID
76
+ */
77
+ private generateSessionId;
78
+ /**
79
+ * Get current audit events for this session
80
+ */
81
+ getAuditEvents(): AuditEvent[];
82
+ /**
83
+ * Clear sensitive data from memory
84
+ */
85
+ clearSensitiveData(): void;
86
+ /**
87
+ * Validate transport security
88
+ */
89
+ validateTransportSecurity(url?: string): boolean;
90
+ }
91
+ /**
92
+ * Initialize HIPAA compliance
93
+ */
94
+ export declare function initializeHipaaCompliance(config: HipaaConfig): HipaaComplianceManager;
95
+ /**
96
+ * Get current HIPAA compliance manager
97
+ */
98
+ export declare function getHipaaManager(): HipaaComplianceManager | null;
99
+ /**
100
+ * HIPAA-compliant error wrapper
101
+ */
102
+ export declare function createHipaaError(error: Error | string, context?: string): Error;
103
+ /**
104
+ * HIPAA-compliant temporary file utilities
105
+ */
106
+ export declare const HipaaTemp: {
107
+ createPath: (prefix?: string) => string;
108
+ cleanup: (filePath: string) => Promise<void>;
109
+ };
110
+ export { HipaaComplianceManager };
@@ -1,7 +1,19 @@
1
- import type { Scanner } from "./types";
2
- export type PresetName = string;
1
+ import type { Scanner, AnalysisDepth } from "./types";
2
+ export type PresetName = 'basic' | 'advanced' | 'malware-analysis' | 'decompilation-basic' | 'decompilation-deep' | string;
3
3
  export interface PresetOptions {
4
+ yaraRules?: string | string[];
5
+ yaraTimeout?: number;
6
+ enableDecompilation?: boolean;
7
+ decompilationEngine?: 'binaryninja-hlil' | 'ghidra-pcode' | 'both';
8
+ decompilationDepth?: AnalysisDepth;
9
+ decompilationTimeout?: number;
10
+ binaryNinjaPath?: string;
11
+ pythonPath?: string;
12
+ ghidraPath?: string;
13
+ analyzeHeadless?: string;
14
+ timeout?: number;
4
15
  [key: string]: unknown;
5
16
  }
6
17
  export declare function composeScanners(...scanners: Scanner[]): Scanner;
7
- export declare function createPresetScanner(_preset: PresetName, _opts?: PresetOptions): Scanner;
18
+ export declare function createPresetScanner(preset: PresetName, opts?: PresetOptions): Scanner;
19
+ export declare const PRESET_CONFIGS: Record<string, PresetOptions>;
@@ -0,0 +1,96 @@
1
+ /** Decompilation-specific types for Pompelmi */
2
+ export type DecompilationEngine = 'binaryninja-hlil' | 'ghidra-pcode';
3
+ export type AnalysisDepth = 'minimal' | 'basic' | 'deep';
4
+ export interface DecompilationMatch {
5
+ rule: string;
6
+ severity?: 'low' | 'medium' | 'high' | 'critical';
7
+ engine: DecompilationEngine;
8
+ confidence: number;
9
+ meta?: {
10
+ function?: string;
11
+ address?: string;
12
+ instruction?: string;
13
+ pattern?: string;
14
+ [key: string]: unknown;
15
+ };
16
+ }
17
+ export interface FunctionAnalysis {
18
+ name: string;
19
+ address: string;
20
+ size: number;
21
+ complexity?: number;
22
+ callCount?: number;
23
+ isObfuscated?: boolean;
24
+ hasAntiAnalysis?: boolean;
25
+ suspiciousCalls?: string[];
26
+ }
27
+ export interface DecompilationResult {
28
+ engine: DecompilationEngine;
29
+ success: boolean;
30
+ functions: FunctionAnalysis[];
31
+ matches: DecompilationMatch[];
32
+ meta?: {
33
+ analysisTime?: number;
34
+ binaryFormat?: string;
35
+ architecture?: string;
36
+ [key: string]: unknown;
37
+ };
38
+ }
39
+ export interface DecompilationScanner {
40
+ scan(bytes: Uint8Array): Promise<DecompilationMatch[]>;
41
+ analyze?(bytes: Uint8Array): Promise<DecompilationResult>;
42
+ }
43
+ export interface HLILInstruction {
44
+ operation: string;
45
+ address: string;
46
+ operands?: any[];
47
+ vars?: string[];
48
+ }
49
+ export interface HLILFunction {
50
+ name: string;
51
+ address: string;
52
+ instructions: HLILInstruction[];
53
+ basicBlocks?: number;
54
+ complexity?: number;
55
+ }
56
+ export interface BinaryNinjaOptions {
57
+ timeout?: number;
58
+ depth?: AnalysisDepth;
59
+ enableHeuristics?: boolean;
60
+ pythonPath?: string;
61
+ binaryNinjaPath?: string;
62
+ }
63
+ export interface PCodeOperation {
64
+ opcode: string;
65
+ address: string;
66
+ inputs?: string[];
67
+ output?: string;
68
+ }
69
+ export interface PCodeFunction {
70
+ name: string;
71
+ address: string;
72
+ operations: PCodeOperation[];
73
+ basicBlocks?: number;
74
+ }
75
+ export interface GhidraOptions {
76
+ timeout?: number;
77
+ depth?: AnalysisDepth;
78
+ enableHeuristics?: boolean;
79
+ ghidraPath?: string;
80
+ analyzeHeadless?: string;
81
+ }
82
+ export interface DecompilationOptions {
83
+ engine: DecompilationEngine;
84
+ timeout?: number;
85
+ depth?: AnalysisDepth;
86
+ enableHeuristics?: boolean;
87
+ binaryNinja?: BinaryNinjaOptions;
88
+ ghidra?: GhidraOptions;
89
+ }
90
+ export interface SuspiciousPattern {
91
+ name: string;
92
+ description: string;
93
+ severity: 'low' | 'medium' | 'high' | 'critical';
94
+ pattern: RegExp | string | ((instruction: any) => boolean);
95
+ }
96
+ export declare const SUSPICIOUS_PATTERNS: SuspiciousPattern[];