windows-exe-decompiler-mcp-server 0.1.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.
- package/CODEX_INSTALLATION.md +69 -0
- package/COPILOT_INSTALLATION.md +77 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/bin/windows-exe-decompiler-mcp-server.js +3 -0
- package/dist/analysis-provenance.d.ts +184 -0
- package/dist/analysis-provenance.js +74 -0
- package/dist/analysis-task-runner.d.ts +31 -0
- package/dist/analysis-task-runner.js +160 -0
- package/dist/artifact-inventory.d.ts +23 -0
- package/dist/artifact-inventory.js +175 -0
- package/dist/cache-manager.d.ts +128 -0
- package/dist/cache-manager.js +454 -0
- package/dist/confidence-semantics.d.ts +66 -0
- package/dist/confidence-semantics.js +122 -0
- package/dist/config.d.ts +335 -0
- package/dist/config.js +193 -0
- package/dist/database.d.ts +227 -0
- package/dist/database.js +601 -0
- package/dist/decompiler-worker.d.ts +441 -0
- package/dist/decompiler-worker.js +1962 -0
- package/dist/dynamic-trace.d.ts +95 -0
- package/dist/dynamic-trace.js +629 -0
- package/dist/env-validator.d.ts +15 -0
- package/dist/env-validator.js +249 -0
- package/dist/error-handler.d.ts +28 -0
- package/dist/error-handler.example.d.ts +22 -0
- package/dist/error-handler.example.js +141 -0
- package/dist/error-handler.js +139 -0
- package/dist/ghidra-analysis-status.d.ts +49 -0
- package/dist/ghidra-analysis-status.js +178 -0
- package/dist/ghidra-config.d.ts +134 -0
- package/dist/ghidra-config.js +464 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +200 -0
- package/dist/job-queue.d.ts +169 -0
- package/dist/job-queue.js +407 -0
- package/dist/logger.d.ts +106 -0
- package/dist/logger.js +176 -0
- package/dist/policy-guard.d.ts +115 -0
- package/dist/policy-guard.js +243 -0
- package/dist/process-output.d.ts +15 -0
- package/dist/process-output.js +90 -0
- package/dist/prompts/function-explanation-review.d.ts +5 -0
- package/dist/prompts/function-explanation-review.js +64 -0
- package/dist/prompts/semantic-name-review.d.ts +5 -0
- package/dist/prompts/semantic-name-review.js +63 -0
- package/dist/runtime-correlation.d.ts +34 -0
- package/dist/runtime-correlation.js +279 -0
- package/dist/runtime-paths.d.ts +3 -0
- package/dist/runtime-paths.js +11 -0
- package/dist/selection-diff.d.ts +667 -0
- package/dist/selection-diff.js +53 -0
- package/dist/semantic-name-suggestion-artifacts.d.ts +116 -0
- package/dist/semantic-name-suggestion-artifacts.js +314 -0
- package/dist/server.d.ts +129 -0
- package/dist/server.js +578 -0
- package/dist/tools/artifact-read.d.ts +235 -0
- package/dist/tools/artifact-read.js +317 -0
- package/dist/tools/artifacts-diff.d.ts +728 -0
- package/dist/tools/artifacts-diff.js +304 -0
- package/dist/tools/artifacts-list.d.ts +515 -0
- package/dist/tools/artifacts-list.js +389 -0
- package/dist/tools/attack-map.d.ts +290 -0
- package/dist/tools/attack-map.js +519 -0
- package/dist/tools/cache-observability.d.ts +4 -0
- package/dist/tools/cache-observability.js +36 -0
- package/dist/tools/code-function-cfg.d.ts +50 -0
- package/dist/tools/code-function-cfg.js +102 -0
- package/dist/tools/code-function-decompile.d.ts +55 -0
- package/dist/tools/code-function-decompile.js +103 -0
- package/dist/tools/code-function-disassemble.d.ts +43 -0
- package/dist/tools/code-function-disassemble.js +185 -0
- package/dist/tools/code-function-explain-apply.d.ts +255 -0
- package/dist/tools/code-function-explain-apply.js +225 -0
- package/dist/tools/code-function-explain-prepare.d.ts +535 -0
- package/dist/tools/code-function-explain-prepare.js +276 -0
- package/dist/tools/code-function-explain-review.d.ts +397 -0
- package/dist/tools/code-function-explain-review.js +589 -0
- package/dist/tools/code-function-rename-apply.d.ts +248 -0
- package/dist/tools/code-function-rename-apply.js +220 -0
- package/dist/tools/code-function-rename-prepare.d.ts +506 -0
- package/dist/tools/code-function-rename-prepare.js +279 -0
- package/dist/tools/code-function-rename-review.d.ts +574 -0
- package/dist/tools/code-function-rename-review.js +761 -0
- package/dist/tools/code-functions-list.d.ts +37 -0
- package/dist/tools/code-functions-list.js +91 -0
- package/dist/tools/code-functions-rank.d.ts +34 -0
- package/dist/tools/code-functions-rank.js +90 -0
- package/dist/tools/code-functions-reconstruct.d.ts +2725 -0
- package/dist/tools/code-functions-reconstruct.js +2807 -0
- package/dist/tools/code-functions-search.d.ts +39 -0
- package/dist/tools/code-functions-search.js +90 -0
- package/dist/tools/code-reconstruct-export.d.ts +1212 -0
- package/dist/tools/code-reconstruct-export.js +4002 -0
- package/dist/tools/code-reconstruct-plan.d.ts +274 -0
- package/dist/tools/code-reconstruct-plan.js +342 -0
- package/dist/tools/dotnet-metadata-extract.d.ts +541 -0
- package/dist/tools/dotnet-metadata-extract.js +355 -0
- package/dist/tools/dotnet-reconstruct-export.d.ts +567 -0
- package/dist/tools/dotnet-reconstruct-export.js +1151 -0
- package/dist/tools/dotnet-types-list.d.ts +325 -0
- package/dist/tools/dotnet-types-list.js +201 -0
- package/dist/tools/dynamic-dependencies.d.ts +115 -0
- package/dist/tools/dynamic-dependencies.js +213 -0
- package/dist/tools/dynamic-memory-import.d.ts +10 -0
- package/dist/tools/dynamic-memory-import.js +567 -0
- package/dist/tools/dynamic-trace-import.d.ts +10 -0
- package/dist/tools/dynamic-trace-import.js +235 -0
- package/dist/tools/entrypoint-fallback-disasm.d.ts +30 -0
- package/dist/tools/entrypoint-fallback-disasm.js +89 -0
- package/dist/tools/ghidra-analyze.d.ts +88 -0
- package/dist/tools/ghidra-analyze.js +208 -0
- package/dist/tools/ghidra-health.d.ts +37 -0
- package/dist/tools/ghidra-health.js +212 -0
- package/dist/tools/ioc-export.d.ts +209 -0
- package/dist/tools/ioc-export.js +542 -0
- package/dist/tools/packer-detect.d.ts +165 -0
- package/dist/tools/packer-detect.js +284 -0
- package/dist/tools/pe-exports-extract.d.ts +175 -0
- package/dist/tools/pe-exports-extract.js +253 -0
- package/dist/tools/pe-fingerprint.d.ts +234 -0
- package/dist/tools/pe-fingerprint.js +269 -0
- package/dist/tools/pe-imports-extract.d.ts +105 -0
- package/dist/tools/pe-imports-extract.js +245 -0
- package/dist/tools/report-generate.d.ts +157 -0
- package/dist/tools/report-generate.js +457 -0
- package/dist/tools/report-summarize.d.ts +2131 -0
- package/dist/tools/report-summarize.js +596 -0
- package/dist/tools/runtime-detect.d.ts +135 -0
- package/dist/tools/runtime-detect.js +247 -0
- package/dist/tools/sample-ingest.d.ts +94 -0
- package/dist/tools/sample-ingest.js +327 -0
- package/dist/tools/sample-profile-get.d.ts +183 -0
- package/dist/tools/sample-profile-get.js +121 -0
- package/dist/tools/sandbox-execute.d.ts +441 -0
- package/dist/tools/sandbox-execute.js +392 -0
- package/dist/tools/strings-extract.d.ts +375 -0
- package/dist/tools/strings-extract.js +314 -0
- package/dist/tools/strings-floss-decode.d.ts +143 -0
- package/dist/tools/strings-floss-decode.js +259 -0
- package/dist/tools/system-health.d.ts +434 -0
- package/dist/tools/system-health.js +446 -0
- package/dist/tools/task-cancel.d.ts +21 -0
- package/dist/tools/task-cancel.js +70 -0
- package/dist/tools/task-status.d.ts +27 -0
- package/dist/tools/task-status.js +106 -0
- package/dist/tools/task-sweep.d.ts +22 -0
- package/dist/tools/task-sweep.js +77 -0
- package/dist/tools/tool-help.d.ts +340 -0
- package/dist/tools/tool-help.js +261 -0
- package/dist/tools/yara-scan.d.ts +554 -0
- package/dist/tools/yara-scan.js +313 -0
- package/dist/types.d.ts +266 -0
- package/dist/types.js +41 -0
- package/dist/worker-pool.d.ts +204 -0
- package/dist/worker-pool.js +650 -0
- package/dist/workflows/deep-static.d.ts +104 -0
- package/dist/workflows/deep-static.js +276 -0
- package/dist/workflows/function-explanation-review.d.ts +655 -0
- package/dist/workflows/function-explanation-review.js +440 -0
- package/dist/workflows/reconstruct.d.ts +2053 -0
- package/dist/workflows/reconstruct.js +666 -0
- package/dist/workflows/semantic-name-review.d.ts +2418 -0
- package/dist/workflows/semantic-name-review.js +521 -0
- package/dist/workflows/triage.d.ts +659 -0
- package/dist/workflows/triage.js +1374 -0
- package/dist/workspace-manager.d.ts +150 -0
- package/dist/workspace-manager.js +411 -0
- package/ghidra_scripts/DecompileFunction.java +487 -0
- package/ghidra_scripts/DecompileFunction.py +150 -0
- package/ghidra_scripts/ExtractCFG.java +256 -0
- package/ghidra_scripts/ExtractCFG.py +233 -0
- package/ghidra_scripts/ExtractFunctions.java +442 -0
- package/ghidra_scripts/ExtractFunctions.py +101 -0
- package/ghidra_scripts/README.md +125 -0
- package/ghidra_scripts/SearchFunctionReferences.java +380 -0
- package/helpers/DotNetMetadataProbe/DotNetMetadataProbe.csproj +9 -0
- package/helpers/DotNetMetadataProbe/Program.cs +566 -0
- package/install-to-codex.ps1 +178 -0
- package/install-to-copilot.ps1 +303 -0
- package/package.json +101 -0
- package/requirements.txt +9 -0
- package/workers/requirements-dynamic.txt +11 -0
- package/workers/requirements.txt +8 -0
- package/workers/speakeasy_compat.py +175 -0
- package/workers/static_worker.py +5183 -0
- package/workers/yara_rules/default.yar +33 -0
- package/workers/yara_rules/malware_families.yar +93 -0
- package/workers/yara_rules/packers.yar +80 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep Static Analysis Workflow
|
|
3
|
+
*
|
|
4
|
+
* Requirements: 16.1, 16.2, 16.3, 16.4, 16.5
|
|
5
|
+
*
|
|
6
|
+
* Performs comprehensive static analysis including:
|
|
7
|
+
* - Quick triage
|
|
8
|
+
* - Ghidra analysis
|
|
9
|
+
* - Function ranking
|
|
10
|
+
* - Top function decompilation
|
|
11
|
+
* - Report generation
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import type { ToolDefinition, ToolHandler } from '../types.js';
|
|
15
|
+
import type { DatabaseManager } from '../database.js';
|
|
16
|
+
import type { WorkspaceManager } from '../workspace-manager.js';
|
|
17
|
+
import type { CacheManager } from '../cache-manager.js';
|
|
18
|
+
import type { JobQueue } from '../job-queue.js';
|
|
19
|
+
/**
|
|
20
|
+
* Input schema for deep static workflow
|
|
21
|
+
*/
|
|
22
|
+
export declare const deepStaticWorkflowInputSchema: z.ZodObject<{
|
|
23
|
+
sample_id: z.ZodString;
|
|
24
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
top_functions: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
ghidra_timeout: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
include_cfg: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
top_functions?: number | undefined;
|
|
30
|
+
ghidra_timeout?: number | undefined;
|
|
31
|
+
include_cfg?: boolean | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
top_functions?: number | undefined;
|
|
34
|
+
ghidra_timeout?: number | undefined;
|
|
35
|
+
include_cfg?: boolean | undefined;
|
|
36
|
+
}>>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
sample_id: string;
|
|
39
|
+
options?: {
|
|
40
|
+
top_functions?: number | undefined;
|
|
41
|
+
ghidra_timeout?: number | undefined;
|
|
42
|
+
include_cfg?: boolean | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
sample_id: string;
|
|
46
|
+
options?: {
|
|
47
|
+
top_functions?: number | undefined;
|
|
48
|
+
ghidra_timeout?: number | undefined;
|
|
49
|
+
include_cfg?: boolean | undefined;
|
|
50
|
+
} | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
export type DeepStaticWorkflowInput = z.infer<typeof deepStaticWorkflowInputSchema>;
|
|
53
|
+
/**
|
|
54
|
+
* Deep static workflow result
|
|
55
|
+
*/
|
|
56
|
+
export interface DeepStaticWorkflowResult {
|
|
57
|
+
ok: boolean;
|
|
58
|
+
data?: {
|
|
59
|
+
triage_summary: any;
|
|
60
|
+
analysis_id: string;
|
|
61
|
+
function_count: number;
|
|
62
|
+
top_functions: Array<{
|
|
63
|
+
address: string;
|
|
64
|
+
name: string;
|
|
65
|
+
score: number;
|
|
66
|
+
reasons: string[];
|
|
67
|
+
pseudocode?: string;
|
|
68
|
+
cfg?: any;
|
|
69
|
+
}>;
|
|
70
|
+
report_path?: string;
|
|
71
|
+
elapsed_ms: number;
|
|
72
|
+
};
|
|
73
|
+
errors?: string[];
|
|
74
|
+
warnings?: string[];
|
|
75
|
+
}
|
|
76
|
+
export interface DeepStaticWorkflowProgressCallbacks {
|
|
77
|
+
onProgress?: (progress: number, stage: string) => void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Tool definition for deep static workflow
|
|
81
|
+
*/
|
|
82
|
+
export declare const deepStaticWorkflowToolDefinition: ToolDefinition;
|
|
83
|
+
/**
|
|
84
|
+
* Execute deep static analysis workflow
|
|
85
|
+
*
|
|
86
|
+
* Requirements: 16.1, 16.2, 16.3, 16.4, 16.5
|
|
87
|
+
*
|
|
88
|
+
* @param sampleId - Sample identifier
|
|
89
|
+
* @param workspaceManager - Workspace manager
|
|
90
|
+
* @param database - Database manager
|
|
91
|
+
* @param cacheManager - Cache manager
|
|
92
|
+
* @param options - Workflow options
|
|
93
|
+
* @returns Deep static workflow result
|
|
94
|
+
*/
|
|
95
|
+
export declare function deepStaticWorkflow(sampleId: string, workspaceManager: WorkspaceManager, database: DatabaseManager, cacheManager: CacheManager, options?: {
|
|
96
|
+
top_functions?: number;
|
|
97
|
+
ghidra_timeout?: number;
|
|
98
|
+
include_cfg?: boolean;
|
|
99
|
+
}, callbacks?: DeepStaticWorkflowProgressCallbacks): Promise<DeepStaticWorkflowResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Create handler for deep static workflow tool
|
|
102
|
+
*/
|
|
103
|
+
export declare function createDeepStaticWorkflowHandler(workspaceManager: WorkspaceManager, database: DatabaseManager, cacheManager: CacheManager, jobQueue?: JobQueue): ToolHandler;
|
|
104
|
+
//# sourceMappingURL=deep-static.d.ts.map
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep Static Analysis Workflow
|
|
3
|
+
*
|
|
4
|
+
* Requirements: 16.1, 16.2, 16.3, 16.4, 16.5
|
|
5
|
+
*
|
|
6
|
+
* Performs comprehensive static analysis including:
|
|
7
|
+
* - Quick triage
|
|
8
|
+
* - Ghidra analysis
|
|
9
|
+
* - Function ranking
|
|
10
|
+
* - Top function decompilation
|
|
11
|
+
* - Report generation
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { DecompilerWorker } from '../decompiler-worker.js';
|
|
15
|
+
import { logger } from '../logger.js';
|
|
16
|
+
import { triageWorkflow } from './triage.js';
|
|
17
|
+
/**
|
|
18
|
+
* Input schema for deep static workflow
|
|
19
|
+
*/
|
|
20
|
+
export const deepStaticWorkflowInputSchema = z.object({
|
|
21
|
+
sample_id: z.string().describe('Sample identifier (sha256:<hex>)'),
|
|
22
|
+
options: z.object({
|
|
23
|
+
top_functions: z.number().optional().describe('Number of top functions to decompile (default: 10)'),
|
|
24
|
+
ghidra_timeout: z.number().optional().describe('Ghidra analysis timeout in seconds (default: 600)'),
|
|
25
|
+
include_cfg: z.boolean().optional().describe('Include CFG for top functions (default: false)')
|
|
26
|
+
}).optional()
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Tool definition for deep static workflow
|
|
30
|
+
*/
|
|
31
|
+
export const deepStaticWorkflowToolDefinition = {
|
|
32
|
+
name: 'workflow.deep_static',
|
|
33
|
+
description: 'Perform comprehensive static analysis including triage, Ghidra analysis, function ranking, and decompilation of top functions. This is a long-running operation (30-60 minutes).',
|
|
34
|
+
inputSchema: deepStaticWorkflowInputSchema
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Execute deep static analysis workflow
|
|
38
|
+
*
|
|
39
|
+
* Requirements: 16.1, 16.2, 16.3, 16.4, 16.5
|
|
40
|
+
*
|
|
41
|
+
* @param sampleId - Sample identifier
|
|
42
|
+
* @param workspaceManager - Workspace manager
|
|
43
|
+
* @param database - Database manager
|
|
44
|
+
* @param cacheManager - Cache manager
|
|
45
|
+
* @param options - Workflow options
|
|
46
|
+
* @returns Deep static workflow result
|
|
47
|
+
*/
|
|
48
|
+
export async function deepStaticWorkflow(sampleId, workspaceManager, database, cacheManager, options, callbacks) {
|
|
49
|
+
const startTime = Date.now();
|
|
50
|
+
const reportProgress = (progress, stage) => {
|
|
51
|
+
callbacks?.onProgress?.(progress, stage);
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
logger.info({
|
|
55
|
+
sample_id: sampleId,
|
|
56
|
+
options
|
|
57
|
+
}, 'Starting deep static workflow');
|
|
58
|
+
reportProgress(5, 'triage');
|
|
59
|
+
// Step 1: Execute quick triage workflow (Requirement 16.1)
|
|
60
|
+
logger.info({ sample_id: sampleId }, 'Step 1: Executing quick triage');
|
|
61
|
+
const triageResult = await triageWorkflow(sampleId, workspaceManager, database, cacheManager);
|
|
62
|
+
if (!triageResult.ok) {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
errors: triageResult.errors || ['Triage workflow failed']
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
reportProgress(25, 'ghidra_analyze');
|
|
69
|
+
// Step 2: Start Ghidra analysis (Requirement 16.2)
|
|
70
|
+
logger.info({ sample_id: sampleId }, 'Step 2: Starting Ghidra analysis');
|
|
71
|
+
const decompilerWorker = new DecompilerWorker(database, workspaceManager);
|
|
72
|
+
const ghidraTimeout = (options?.ghidra_timeout || 600) * 1000; // Convert to ms
|
|
73
|
+
const analysisResult = await decompilerWorker.analyze(sampleId, {
|
|
74
|
+
timeout: ghidraTimeout,
|
|
75
|
+
maxCpu: '4'
|
|
76
|
+
});
|
|
77
|
+
logger.info({
|
|
78
|
+
analysis_id: analysisResult.analysisId,
|
|
79
|
+
function_count: analysisResult.functionCount
|
|
80
|
+
}, 'Ghidra analysis completed');
|
|
81
|
+
reportProgress(55, 'rank_functions');
|
|
82
|
+
// Step 3: Execute function ranking (Requirement 16.3)
|
|
83
|
+
logger.info({ sample_id: sampleId }, 'Step 3: Ranking functions');
|
|
84
|
+
const topK = options?.top_functions || 10;
|
|
85
|
+
const rankedFunctions = await decompilerWorker.rankFunctions(sampleId, topK);
|
|
86
|
+
logger.info({
|
|
87
|
+
sample_id: sampleId,
|
|
88
|
+
top_k: topK,
|
|
89
|
+
top_score: rankedFunctions[0]?.score || 0
|
|
90
|
+
}, 'Functions ranked');
|
|
91
|
+
reportProgress(75, 'decompile_top_functions');
|
|
92
|
+
// Step 4: Decompile top functions (Requirement 16.4)
|
|
93
|
+
logger.info({
|
|
94
|
+
sample_id: sampleId,
|
|
95
|
+
count: rankedFunctions.length
|
|
96
|
+
}, 'Step 4: Decompiling top functions');
|
|
97
|
+
const decompiledFunctions = [];
|
|
98
|
+
for (const func of rankedFunctions) {
|
|
99
|
+
try {
|
|
100
|
+
logger.debug({
|
|
101
|
+
address: func.address,
|
|
102
|
+
name: func.name
|
|
103
|
+
}, 'Decompiling function');
|
|
104
|
+
const decompiled = await decompilerWorker.decompileFunction(sampleId, func.address, false, // Don't include xrefs for performance
|
|
105
|
+
30000 // 30 second timeout per function
|
|
106
|
+
);
|
|
107
|
+
const funcResult = {
|
|
108
|
+
address: func.address,
|
|
109
|
+
name: func.name,
|
|
110
|
+
score: func.score,
|
|
111
|
+
reasons: func.reasons,
|
|
112
|
+
pseudocode: decompiled.pseudocode
|
|
113
|
+
};
|
|
114
|
+
// Optionally include CFG
|
|
115
|
+
if (options?.include_cfg) {
|
|
116
|
+
try {
|
|
117
|
+
const cfg = await decompilerWorker.getFunctionCFG(sampleId, func.address, 30000);
|
|
118
|
+
funcResult.cfg = cfg;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
logger.warn({
|
|
122
|
+
address: func.address,
|
|
123
|
+
error: error instanceof Error ? error.message : String(error)
|
|
124
|
+
}, 'Failed to extract CFG');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
decompiledFunctions.push(funcResult);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
logger.warn({
|
|
131
|
+
address: func.address,
|
|
132
|
+
name: func.name,
|
|
133
|
+
error: error instanceof Error ? error.message : String(error)
|
|
134
|
+
}, 'Failed to decompile function');
|
|
135
|
+
// Add function without pseudocode
|
|
136
|
+
decompiledFunctions.push({
|
|
137
|
+
address: func.address,
|
|
138
|
+
name: func.name,
|
|
139
|
+
score: func.score,
|
|
140
|
+
reasons: func.reasons,
|
|
141
|
+
pseudocode: null,
|
|
142
|
+
error: error instanceof Error ? error.message : String(error)
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Step 5: Generate report (Requirement 16.5)
|
|
147
|
+
logger.info({ sample_id: sampleId }, 'Step 5: Generating report');
|
|
148
|
+
reportProgress(92, 'generate_report');
|
|
149
|
+
// Report generation would be implemented here
|
|
150
|
+
// For now, we'll just return the data
|
|
151
|
+
const elapsedMs = Date.now() - startTime;
|
|
152
|
+
logger.info({
|
|
153
|
+
sample_id: sampleId,
|
|
154
|
+
elapsed_ms: elapsedMs,
|
|
155
|
+
function_count: analysisResult.functionCount,
|
|
156
|
+
decompiled_count: decompiledFunctions.length
|
|
157
|
+
}, 'Deep static workflow completed');
|
|
158
|
+
reportProgress(100, 'completed');
|
|
159
|
+
return {
|
|
160
|
+
ok: true,
|
|
161
|
+
data: {
|
|
162
|
+
triage_summary: triageResult.data,
|
|
163
|
+
analysis_id: analysisResult.analysisId,
|
|
164
|
+
function_count: analysisResult.functionCount,
|
|
165
|
+
top_functions: decompiledFunctions,
|
|
166
|
+
elapsed_ms: elapsedMs
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
172
|
+
const elapsedMs = Date.now() - startTime;
|
|
173
|
+
logger.error({
|
|
174
|
+
sample_id: sampleId,
|
|
175
|
+
error: errorMessage,
|
|
176
|
+
elapsed_ms: elapsedMs
|
|
177
|
+
}, 'Deep static workflow failed');
|
|
178
|
+
return {
|
|
179
|
+
ok: false,
|
|
180
|
+
errors: [errorMessage]
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create handler for deep static workflow tool
|
|
186
|
+
*/
|
|
187
|
+
export function createDeepStaticWorkflowHandler(workspaceManager, database, cacheManager, jobQueue) {
|
|
188
|
+
return async (args) => {
|
|
189
|
+
try {
|
|
190
|
+
const input = deepStaticWorkflowInputSchema.parse(args);
|
|
191
|
+
logger.info({
|
|
192
|
+
sample_id: input.sample_id,
|
|
193
|
+
options: input.options
|
|
194
|
+
}, 'workflow.deep_static tool called');
|
|
195
|
+
// Check if sample exists
|
|
196
|
+
const sample = database.findSample(input.sample_id);
|
|
197
|
+
if (!sample) {
|
|
198
|
+
return {
|
|
199
|
+
content: [{
|
|
200
|
+
type: 'text',
|
|
201
|
+
text: JSON.stringify({
|
|
202
|
+
ok: false,
|
|
203
|
+
errors: [`Sample not found: ${input.sample_id}`]
|
|
204
|
+
}, null, 2)
|
|
205
|
+
}],
|
|
206
|
+
isError: true
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (jobQueue) {
|
|
210
|
+
const requestedTimeoutSec = input.options?.ghidra_timeout || 600;
|
|
211
|
+
const jobTimeoutMs = Math.max((requestedTimeoutSec + 1200) * 1000, 30 * 60 * 1000);
|
|
212
|
+
const jobId = jobQueue.enqueue({
|
|
213
|
+
type: 'static',
|
|
214
|
+
tool: 'workflow.deep_static',
|
|
215
|
+
sampleId: input.sample_id,
|
|
216
|
+
args: input,
|
|
217
|
+
priority: 5,
|
|
218
|
+
timeout: jobTimeoutMs,
|
|
219
|
+
retryPolicy: {
|
|
220
|
+
maxRetries: 1,
|
|
221
|
+
backoffMs: 5000,
|
|
222
|
+
retryableErrors: ['E_TIMEOUT', 'E_RESOURCE_EXHAUSTED'],
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
return {
|
|
226
|
+
content: [{
|
|
227
|
+
type: 'text',
|
|
228
|
+
text: JSON.stringify({
|
|
229
|
+
ok: true,
|
|
230
|
+
data: {
|
|
231
|
+
job_id: jobId,
|
|
232
|
+
status: 'queued',
|
|
233
|
+
tool: 'workflow.deep_static',
|
|
234
|
+
sample_id: input.sample_id,
|
|
235
|
+
progress: 0,
|
|
236
|
+
}
|
|
237
|
+
}, null, 2)
|
|
238
|
+
}]
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const result = await deepStaticWorkflow(input.sample_id, workspaceManager, database, cacheManager, input.options);
|
|
242
|
+
if (!result.ok) {
|
|
243
|
+
return {
|
|
244
|
+
content: [{
|
|
245
|
+
type: 'text',
|
|
246
|
+
text: JSON.stringify(result, null, 2)
|
|
247
|
+
}],
|
|
248
|
+
isError: true
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
content: [{
|
|
253
|
+
type: 'text',
|
|
254
|
+
text: JSON.stringify(result, null, 2)
|
|
255
|
+
}]
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
260
|
+
logger.error({
|
|
261
|
+
error: errorMessage
|
|
262
|
+
}, 'workflow.deep_static tool failed');
|
|
263
|
+
return {
|
|
264
|
+
content: [{
|
|
265
|
+
type: 'text',
|
|
266
|
+
text: JSON.stringify({
|
|
267
|
+
ok: false,
|
|
268
|
+
errors: [errorMessage]
|
|
269
|
+
}, null, 2)
|
|
270
|
+
}],
|
|
271
|
+
isError: true
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=deep-static.js.map
|