pompelmi 0.35.5 → 1.0.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.
Files changed (133) hide show
  1. package/.claude/settings.local.json +40 -0
  2. package/LICENSE +12 -18
  3. package/README.md +159 -183
  4. package/eslint.config.mjs +8 -0
  5. package/package.json +26 -251
  6. package/src/ClamAVDatabaseUpdater.js +48 -0
  7. package/src/ClamAVInstaller.js +49 -0
  8. package/src/ClamAVScanner.js +31 -0
  9. package/src/InstallerCommand.js +11 -0
  10. package/src/config.js +22 -0
  11. package/src/constants.js +3 -0
  12. package/src/favicon.ico +0 -0
  13. package/src/grapefruit.png +0 -0
  14. package/src/index.js +5 -0
  15. package/CHANGELOG.md +0 -71
  16. package/dist/pompelmi.audit.cjs +0 -128
  17. package/dist/pompelmi.audit.cjs.map +0 -1
  18. package/dist/pompelmi.audit.esm.js +0 -107
  19. package/dist/pompelmi.audit.esm.js.map +0 -1
  20. package/dist/pompelmi.browser.cjs +0 -1549
  21. package/dist/pompelmi.browser.cjs.map +0 -1
  22. package/dist/pompelmi.browser.esm.js +0 -1523
  23. package/dist/pompelmi.browser.esm.js.map +0 -1
  24. package/dist/pompelmi.cjs +0 -2591
  25. package/dist/pompelmi.cjs.map +0 -1
  26. package/dist/pompelmi.esm.js +0 -2525
  27. package/dist/pompelmi.esm.js.map +0 -1
  28. package/dist/pompelmi.hooks.cjs +0 -75
  29. package/dist/pompelmi.hooks.cjs.map +0 -1
  30. package/dist/pompelmi.hooks.esm.js +0 -72
  31. package/dist/pompelmi.hooks.esm.js.map +0 -1
  32. package/dist/pompelmi.policy-packs.cjs +0 -240
  33. package/dist/pompelmi.policy-packs.cjs.map +0 -1
  34. package/dist/pompelmi.policy-packs.esm.js +0 -232
  35. package/dist/pompelmi.policy-packs.esm.js.map +0 -1
  36. package/dist/pompelmi.quarantine.cjs +0 -317
  37. package/dist/pompelmi.quarantine.cjs.map +0 -1
  38. package/dist/pompelmi.quarantine.esm.js +0 -293
  39. package/dist/pompelmi.quarantine.esm.js.map +0 -1
  40. package/dist/pompelmi.react.cjs +0 -1580
  41. package/dist/pompelmi.react.cjs.map +0 -1
  42. package/dist/pompelmi.react.esm.js +0 -1553
  43. package/dist/pompelmi.react.esm.js.map +0 -1
  44. package/dist/types/audit.d.ts +0 -84
  45. package/dist/types/browser-index.d.ts +0 -29
  46. package/dist/types/config.d.ts +0 -143
  47. package/dist/types/engines/dynamic-taint.d.ts +0 -102
  48. package/dist/types/engines/hybrid-orchestrator.d.ts +0 -65
  49. package/dist/types/engines/hybrid-taint-integration.d.ts +0 -129
  50. package/dist/types/engines/taint-policies.d.ts +0 -84
  51. package/dist/types/hipaa-compliance.d.ts +0 -110
  52. package/dist/types/hooks.d.ts +0 -89
  53. package/dist/types/index.d.ts +0 -29
  54. package/dist/types/magic.d.ts +0 -7
  55. package/dist/types/node/scanDir.d.ts +0 -30
  56. package/dist/types/policy-packs.d.ts +0 -98
  57. package/dist/types/policy.d.ts +0 -12
  58. package/dist/types/presets.d.ts +0 -72
  59. package/dist/types/quarantine/index.d.ts +0 -18
  60. package/dist/types/quarantine/storage.d.ts +0 -77
  61. package/dist/types/quarantine/types.d.ts +0 -78
  62. package/dist/types/quarantine/workflow.d.ts +0 -97
  63. package/dist/types/react-index.d.ts +0 -13
  64. package/dist/types/risk.d.ts +0 -18
  65. package/dist/types/scan/remote.d.ts +0 -12
  66. package/dist/types/scan.d.ts +0 -17
  67. package/dist/types/scanners/common-heuristics.d.ts +0 -14
  68. package/dist/types/scanners/zip-bomb-guard.d.ts +0 -9
  69. package/dist/types/scanners/zipTraversalGuard.d.ts +0 -19
  70. package/dist/types/src/audit.d.ts +0 -84
  71. package/dist/types/src/browser-index.d.ts +0 -29
  72. package/dist/types/src/config.d.ts +0 -143
  73. package/dist/types/src/engines/dynamic-taint.d.ts +0 -102
  74. package/dist/types/src/engines/hybrid-orchestrator.d.ts +0 -65
  75. package/dist/types/src/engines/hybrid-taint-integration.d.ts +0 -129
  76. package/dist/types/src/engines/taint-policies.d.ts +0 -84
  77. package/dist/types/src/hipaa-compliance.d.ts +0 -110
  78. package/dist/types/src/hooks.d.ts +0 -89
  79. package/dist/types/src/index.d.ts +0 -29
  80. package/dist/types/src/magic.d.ts +0 -7
  81. package/dist/types/src/node/scanDir.d.ts +0 -30
  82. package/dist/types/src/policy-packs.d.ts +0 -98
  83. package/dist/types/src/policy.d.ts +0 -12
  84. package/dist/types/src/presets.d.ts +0 -72
  85. package/dist/types/src/quarantine/index.d.ts +0 -18
  86. package/dist/types/src/quarantine/storage.d.ts +0 -77
  87. package/dist/types/src/quarantine/types.d.ts +0 -78
  88. package/dist/types/src/quarantine/workflow.d.ts +0 -97
  89. package/dist/types/src/react-index.d.ts +0 -13
  90. package/dist/types/src/risk.d.ts +0 -18
  91. package/dist/types/src/scan/remote.d.ts +0 -12
  92. package/dist/types/src/scan.d.ts +0 -17
  93. package/dist/types/src/scanners/common-heuristics.d.ts +0 -14
  94. package/dist/types/src/scanners/zip-bomb-guard.d.ts +0 -11
  95. package/dist/types/src/scanners/zipTraversalGuard.d.ts +0 -19
  96. package/dist/types/src/stream.d.ts +0 -10
  97. package/dist/types/src/types/decompilation.d.ts +0 -96
  98. package/dist/types/src/types/taint-tracking.d.ts +0 -495
  99. package/dist/types/src/types.d.ts +0 -48
  100. package/dist/types/src/useFileScanner.d.ts +0 -15
  101. package/dist/types/src/utils/advanced-detection.d.ts +0 -21
  102. package/dist/types/src/utils/batch-scanner.d.ts +0 -62
  103. package/dist/types/src/utils/cache-manager.d.ts +0 -95
  104. package/dist/types/src/utils/export.d.ts +0 -51
  105. package/dist/types/src/utils/performance-metrics.d.ts +0 -68
  106. package/dist/types/src/utils/threat-intelligence.d.ts +0 -96
  107. package/dist/types/src/validate.d.ts +0 -7
  108. package/dist/types/src/verdict.d.ts +0 -2
  109. package/dist/types/src/yara/browser.d.ts +0 -7
  110. package/dist/types/src/yara/index.d.ts +0 -17
  111. package/dist/types/src/yara/node.d.ts +0 -2
  112. package/dist/types/src/yara/remote.d.ts +0 -10
  113. package/dist/types/src/yara-bridge.d.ts +0 -3
  114. package/dist/types/src/zip.d.ts +0 -13
  115. package/dist/types/stream.d.ts +0 -10
  116. package/dist/types/types/decompilation.d.ts +0 -96
  117. package/dist/types/types/taint-tracking.d.ts +0 -495
  118. package/dist/types/types.d.ts +0 -48
  119. package/dist/types/useFileScanner.d.ts +0 -15
  120. package/dist/types/utils/advanced-detection.d.ts +0 -21
  121. package/dist/types/utils/batch-scanner.d.ts +0 -62
  122. package/dist/types/utils/cache-manager.d.ts +0 -95
  123. package/dist/types/utils/export.d.ts +0 -51
  124. package/dist/types/utils/performance-metrics.d.ts +0 -68
  125. package/dist/types/utils/threat-intelligence.d.ts +0 -96
  126. package/dist/types/validate.d.ts +0 -7
  127. package/dist/types/verdict.d.ts +0 -2
  128. package/dist/types/yara/browser.d.ts +0 -7
  129. package/dist/types/yara/index.d.ts +0 -17
  130. package/dist/types/yara/node.d.ts +0 -2
  131. package/dist/types/yara/remote.d.ts +0 -10
  132. package/dist/types/yara-bridge.d.ts +0 -3
  133. package/dist/types/zip.d.ts +0 -13
@@ -1,65 +0,0 @@
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, HybridAnalysisResult, HybridConfig, 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
- }
@@ -1,129 +0,0 @@
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 { DecompilationResult, DecompilationScanner } from "../types/decompilation";
8
- import type { AnalysisEngine, HybridAnalysisResult, HybridConfig, TaintAnalysisResult, TaintConfig } from "../types/taint-tracking";
9
- import type { TaintPolicy } from "./taint-policies";
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>;
@@ -1,84 +0,0 @@
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 { AnalysisEngine, HybridConfig, OrchestrationStrategy, TaintConfig } 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
- }
@@ -1,110 +0,0 @@
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,89 +0,0 @@
1
- /**
2
- * Scan lifecycle hooks for Pompelmi.
3
- *
4
- * Hooks let you observe and react to scan events without modifying the scan
5
- * pipeline itself. They are the recommended integration point for:
6
- * - logging / metrics collection
7
- * - alerting on threats
8
- * - triggering quarantine automatically
9
- * - OpenTelemetry span creation
10
- *
11
- * Usage:
12
- * ```ts
13
- * import { scanBytes } from 'pompelmi';
14
- * import { createScanHooks, withHooks } from 'pompelmi/hooks';
15
- *
16
- * const hooks = createScanHooks({
17
- * onScanComplete(ctx, report) {
18
- * console.log(ctx.filename, report.verdict, report.durationMs + 'ms');
19
- * },
20
- * onThreatDetected(ctx, report) {
21
- * alertTeam({ file: ctx.filename, verdict: report.verdict });
22
- * },
23
- * });
24
- *
25
- * const scan = withHooks(scanBytes, hooks);
26
- * const report = await scan(bytes, { ctx: { filename: 'upload.zip' } });
27
- * ```
28
- *
29
- * @module hooks
30
- */
31
- import type { QuarantineEntry } from "./quarantine/types";
32
- import type { ScanContext, ScanReport } from "./types";
33
- export interface ScanStartContext extends ScanContext {
34
- /** Unique identifier for this scan invocation (useful for correlating logs). */
35
- scanId?: string;
36
- /** Timestamp when the scan started (ms since epoch). */
37
- startedAt: number;
38
- }
39
- export interface ScanCompleteContext extends ScanStartContext {
40
- /** Duration of the scan in milliseconds. */
41
- durationMs: number;
42
- }
43
- /**
44
- * Callbacks for the scan lifecycle. All hooks are optional.
45
- *
46
- * Hooks MUST NOT throw — wrap logic in try/catch if it can fail.
47
- * Async hooks are fire-and-forget; they do not block the scan result.
48
- */
49
- export interface ScanHooks {
50
- /**
51
- * Called immediately before a scan begins.
52
- */
53
- onScanStart?: (ctx: ScanStartContext) => void | Promise<void>;
54
- /**
55
- * Called when a scan completes successfully (any verdict, including clean).
56
- */
57
- onScanComplete?: (ctx: ScanCompleteContext, report: ScanReport) => void | Promise<void>;
58
- /**
59
- * Called when the scan verdict is 'suspicious' or 'malicious'.
60
- * Fired in addition to `onScanComplete`.
61
- */
62
- onThreatDetected?: (ctx: ScanCompleteContext, report: ScanReport) => void | Promise<void>;
63
- /**
64
- * Called when a file has been quarantined.
65
- * Requires wiring with a `QuarantineManager`; not fired automatically by `scanBytes`.
66
- */
67
- onQuarantine?: (entry: QuarantineEntry) => void | Promise<void>;
68
- /**
69
- * Called when a scan throws an unexpected error.
70
- */
71
- onScanError?: (ctx: ScanStartContext, error: unknown) => void | Promise<void>;
72
- }
73
- /**
74
- * Create a `ScanHooks` object with optional defaults.
75
- * This is a thin factory — the value of using it is the inline TS types.
76
- */
77
- export declare function createScanHooks(hooks: ScanHooks): ScanHooks;
78
- type ScanFn = (bytes: Uint8Array, opts?: {
79
- ctx?: ScanContext;
80
- [k: string]: unknown;
81
- }) => Promise<ScanReport>;
82
- /**
83
- * Wrap a scan function with lifecycle hooks.
84
- *
85
- * Returns a new function with the same signature that fires the hooks
86
- * around each scan call.
87
- */
88
- export declare function withHooks(scanFn: ScanFn, hooks: ScanHooks): ScanFn;
89
- export {};
@@ -1,29 +0,0 @@
1
- /**
2
- * src/index.ts — Primary Node.js entry point for Pompelmi.
3
- *
4
- * This is the full API including Node.js-only modules (HIPAA compliance,
5
- * crypto-based caching and hashing, ZIP streaming, YARA native bindings).
6
- *
7
- * For browser-safe usage, import from 'pompelmi/browser'.
8
- * For React hooks, import from 'pompelmi/react'.
9
- */
10
- export { CONFIG_PRESETS, ConfigManager, createConfig, DEFAULT_CONFIG, getPresetConfig, type ScannerConfig, } from "./config";
11
- export { type AuditEvent, createHipaaError, getHipaaManager, type HipaaConfig, HipaaTemp, initializeHipaaCompliance, } from "./hipaa-compliance";
12
- export type { NodeFileEntry, NodeScanOptions } from "./node/scanDir";
13
- export { DEFAULT_POLICY, definePolicy } from "./policy";
14
- export { ARCHIVES, CONSERVATIVE_DEFAULT, DOCUMENTS_ONLY, getPolicyPack, IMAGES_ONLY, POLICY_PACKS, type PolicyPackName, STRICT_PUBLIC_UPLOAD, } from "./policy-packs";
15
- export { type ComposeScannerOptions, composeScanners, createPresetScanner, type NamedScanner, type PresetName, type PresetOptions, } from "./presets";
16
- export { type ScanOptions, scanBytes, scanFile, scanFiles } from "./scan";
17
- export { scanFilesWithRemoteYara } from "./scan/remote";
18
- export { CommonHeuristicsScanner } from "./scanners/common-heuristics";
19
- export { createZipBombGuard } from "./scanners/zip-bomb-guard";
20
- export * from "./types";
21
- export { analyzeNestedArchives, detectObfuscatedScripts, detectPolyglot, } from "./utils/advanced-detection";
22
- export { BatchScanner, type BatchScanOptions, type BatchScanResult, batchScan, type ScanTask, } from "./utils/batch-scanner";
23
- export { type CacheEntry, type CacheOptions, type CacheStats, getDefaultCache, resetDefaultCache, ScanCacheManager, } from "./utils/cache-manager";
24
- export { type ExportFormat, type ExportOptions, exportScanResults, ScanResultExporter, } from "./utils/export";
25
- export { aggregateScanStats, type PerformanceMetrics, PerformanceTracker, type ScanStatistics, } from "./utils/performance-metrics";
26
- export { createThreatIntelligence, type EnhancedScanReport, getFileHash, LocalThreatIntelligence, type ThreatInfo, ThreatIntelligenceAggregator, type ThreatIntelligenceSource, } from "./utils/threat-intelligence";
27
- export { validateFile } from "./validate";
28
- export { mapMatchesToVerdict } from "./verdict";
29
- export type { YaraMatch } from "./yara/index";
@@ -1,7 +0,0 @@
1
- export type Sniff = {
2
- mime: string;
3
- extHint?: string;
4
- confidence: number;
5
- };
6
- export declare function sniff(bytes: Uint8Array): Sniff | null;
7
- export declare function hasSuspiciousJpegTrailer(bytes: Uint8Array, maxTrailer?: number): boolean;
@@ -1,30 +0,0 @@
1
- import type { YaraMatch } from "../yara/index";
2
- export interface NodeScanOptions {
3
- enableYara?: boolean;
4
- yaraRules?: string;
5
- yaraRulesPath?: string;
6
- includeExtensions?: string[];
7
- yaraAsync?: boolean;
8
- maxFileSizeBytes?: number;
9
- yaraSampleBytes?: number;
10
- yaraPreferBuffer?: boolean;
11
- }
12
- export type NodeYaraVerdict = "malicious" | "suspicious" | "clean";
13
- export interface NodeYaraResult {
14
- matches: YaraMatch[];
15
- status: "scanned" | "skipped" | "error";
16
- /** per i 'skipped', perché abbiamo saltato */
17
- reason?: "max-size" | "filtered-ext" | "not-enabled" | "engine-missing" | "error";
18
- /** come abbiamo scansionato quando status = 'scanned' */
19
- mode?: "async" | "file" | "buffer" | "buffer-sampled";
20
- /** verdetto derivato dai match (solo quando status='scanned') */
21
- verdict?: NodeYaraVerdict;
22
- }
23
- export interface NodeFileEntry {
24
- path: string;
25
- absPath: string;
26
- isDir: boolean;
27
- yara?: NodeYaraResult;
28
- }
29
- /** Scansiona una directory in modo ricorsivo, emettendo le entry e (opzionale) i match YARA. */
30
- export declare function scanDir(root: string, opts?: NodeScanOptions): AsyncGenerator<NodeFileEntry>;
@@ -1,98 +0,0 @@
1
- /**
2
- * Policy packs for Pompelmi.
3
- *
4
- * Pre-configured, named policies for common upload scenarios. Each pack
5
- * defines the file type allowlist, size limits, and timeout appropriate for
6
- * its use case.
7
- *
8
- * All packs are built on `definePolicy` and are fully overridable:
9
- *
10
- * ```ts
11
- * import { POLICY_PACKS } from 'pompelmi/policy-packs';
12
- *
13
- * // Use a pack as-is:
14
- * const policy = POLICY_PACKS['images-only'];
15
- *
16
- * // Or override individual fields:
17
- * import { definePolicy } from 'pompelmi';
18
- * const custom = definePolicy({ ...POLICY_PACKS['documents-only'], maxFileSizeBytes: 5 * 1024 * 1024 });
19
- * ```
20
- *
21
- * These packs are *deterministic* and *descriptor-based* — they do not
22
- * depend on any external threat intelligence feed.
23
- *
24
- * @module policy-packs
25
- */
26
- import { type Policy } from "./policy";
27
- /**
28
- * Documents-only policy.
29
- *
30
- * Appropriate for: document management APIs, PDF/Office file upload endpoints,
31
- * data import pipelines.
32
- *
33
- * Allowed: PDF, Word (.docx/.doc), Excel (.xlsx/.xls), PowerPoint (.pptx/.ppt),
34
- * CSV, plain text, JSON, YAML, ODT/ODS/ODP (OpenDocument).
35
- * Max size: 25 MB.
36
- */
37
- export declare const DOCUMENTS_ONLY: Policy;
38
- /**
39
- * Images-only policy.
40
- *
41
- * Appropriate for: avatar uploads, product image APIs, content platforms with
42
- * user-generated imagery.
43
- *
44
- * Allowed: JPEG, PNG, GIF, WebP, AVIF, TIFF, BMP, ICO.
45
- * Max size: 10 MB.
46
- * Note: SVG is intentionally excluded — inline SVGs can contain scripts.
47
- */
48
- export declare const IMAGES_ONLY: Policy;
49
- /**
50
- * Strict public-upload policy.
51
- *
52
- * Appropriate for: anonymous or low-trust upload endpoints, public APIs,
53
- * any surface exposed to untrusted users.
54
- *
55
- * Aggressive size limit (5 MB), short timeout, fail-closed, narrow MIME
56
- * allowlist. Only allows plain images and PDF.
57
- */
58
- export declare const STRICT_PUBLIC_UPLOAD: Policy;
59
- /**
60
- * Conservative default policy.
61
- *
62
- * A hardened version of the built-in `DEFAULT_POLICY` suitable for
63
- * production without further customisation. Stricter size limit and
64
- * shorter timeout than the permissive default.
65
- */
66
- export declare const CONSERVATIVE_DEFAULT: Policy;
67
- /**
68
- * Archives policy.
69
- *
70
- * Appropriate for: endpoints that accept ZIP, tar, or compressed archives.
71
- * Combines a generous size allowance with a longer timeout for deep inspection.
72
- *
73
- * NOTE: Pair this policy with `createZipBombGuard()` to defend against
74
- * decompression-bomb attacks:
75
- *
76
- * ```ts
77
- * import { composeScanners, createZipBombGuard, CommonHeuristicsScanner } from 'pompelmi';
78
- * const scanner = composeScanners(
79
- * [['zipGuard', createZipBombGuard()], ['heuristics', CommonHeuristicsScanner]]
80
- * );
81
- * ```
82
- */
83
- export declare const ARCHIVES: Policy;
84
- export type PolicyPackName = "documents-only" | "images-only" | "strict-public-upload" | "conservative-default" | "archives";
85
- /**
86
- * Named map of all built-in policy packs.
87
- *
88
- * ```ts
89
- * import { POLICY_PACKS } from 'pompelmi/policy-packs';
90
- * const policy = POLICY_PACKS['strict-public-upload'];
91
- * ```
92
- */
93
- export declare const POLICY_PACKS: Record<PolicyPackName, Policy>;
94
- /**
95
- * Look up a policy pack by name.
96
- * Throws if the name is not recognised.
97
- */
98
- export declare function getPolicyPack(name: PolicyPackName): Policy;
@@ -1,12 +0,0 @@
1
- export interface Policy {
2
- includeExtensions: string[];
3
- allowedMimeTypes: string[];
4
- maxFileSizeBytes: number;
5
- timeoutMs: number;
6
- concurrency: number;
7
- failClosed: boolean;
8
- onScanEvent?: (ev: unknown) => void;
9
- }
10
- export type PolicyInput = Partial<Policy>;
11
- export declare const DEFAULT_POLICY: Policy;
12
- export declare function definePolicy(input?: PolicyInput): Policy;