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
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for MCP Server
|
|
3
|
+
* Handles loading and validating configuration from files and environment variables
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
7
|
+
server: z.ZodDefault<z.ZodObject<{
|
|
8
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
host: z.ZodDefault<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
port: number;
|
|
12
|
+
host: string;
|
|
13
|
+
}, {
|
|
14
|
+
port?: number | undefined;
|
|
15
|
+
host?: string | undefined;
|
|
16
|
+
}>>;
|
|
17
|
+
database: z.ZodDefault<z.ZodObject<{
|
|
18
|
+
type: z.ZodDefault<z.ZodEnum<["sqlite", "postgresql"]>>;
|
|
19
|
+
path: z.ZodOptional<z.ZodString>;
|
|
20
|
+
host: z.ZodOptional<z.ZodString>;
|
|
21
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
database: z.ZodOptional<z.ZodString>;
|
|
23
|
+
user: z.ZodOptional<z.ZodString>;
|
|
24
|
+
password: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
type: "sqlite" | "postgresql";
|
|
27
|
+
port?: number | undefined;
|
|
28
|
+
host?: string | undefined;
|
|
29
|
+
path?: string | undefined;
|
|
30
|
+
database?: string | undefined;
|
|
31
|
+
user?: string | undefined;
|
|
32
|
+
password?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
port?: number | undefined;
|
|
35
|
+
host?: string | undefined;
|
|
36
|
+
path?: string | undefined;
|
|
37
|
+
type?: "sqlite" | "postgresql" | undefined;
|
|
38
|
+
database?: string | undefined;
|
|
39
|
+
user?: string | undefined;
|
|
40
|
+
password?: string | undefined;
|
|
41
|
+
}>>;
|
|
42
|
+
workspace: z.ZodDefault<z.ZodObject<{
|
|
43
|
+
root: z.ZodDefault<z.ZodString>;
|
|
44
|
+
maxSampleSize: z.ZodDefault<z.ZodNumber>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
root: string;
|
|
47
|
+
maxSampleSize: number;
|
|
48
|
+
}, {
|
|
49
|
+
root?: string | undefined;
|
|
50
|
+
maxSampleSize?: number | undefined;
|
|
51
|
+
}>>;
|
|
52
|
+
workers: z.ZodDefault<z.ZodObject<{
|
|
53
|
+
ghidra: z.ZodDefault<z.ZodObject<{
|
|
54
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
55
|
+
path: z.ZodOptional<z.ZodString>;
|
|
56
|
+
maxConcurrent: z.ZodDefault<z.ZodNumber>;
|
|
57
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
maxConcurrent: number;
|
|
61
|
+
timeout: number;
|
|
62
|
+
path?: string | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
path?: string | undefined;
|
|
65
|
+
enabled?: boolean | undefined;
|
|
66
|
+
maxConcurrent?: number | undefined;
|
|
67
|
+
timeout?: number | undefined;
|
|
68
|
+
}>>;
|
|
69
|
+
static: z.ZodDefault<z.ZodObject<{
|
|
70
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
71
|
+
pythonPath: z.ZodOptional<z.ZodString>;
|
|
72
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
timeout: number;
|
|
76
|
+
pythonPath?: string | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
enabled?: boolean | undefined;
|
|
79
|
+
timeout?: number | undefined;
|
|
80
|
+
pythonPath?: string | undefined;
|
|
81
|
+
}>>;
|
|
82
|
+
dotnet: z.ZodDefault<z.ZodObject<{
|
|
83
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
84
|
+
ilspyPath: z.ZodOptional<z.ZodString>;
|
|
85
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
timeout: number;
|
|
89
|
+
ilspyPath?: string | undefined;
|
|
90
|
+
}, {
|
|
91
|
+
enabled?: boolean | undefined;
|
|
92
|
+
timeout?: number | undefined;
|
|
93
|
+
ilspyPath?: string | undefined;
|
|
94
|
+
}>>;
|
|
95
|
+
sandbox: z.ZodDefault<z.ZodObject<{
|
|
96
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
timeout: number;
|
|
101
|
+
}, {
|
|
102
|
+
enabled?: boolean | undefined;
|
|
103
|
+
timeout?: number | undefined;
|
|
104
|
+
}>>;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
ghidra: {
|
|
107
|
+
enabled: boolean;
|
|
108
|
+
maxConcurrent: number;
|
|
109
|
+
timeout: number;
|
|
110
|
+
path?: string | undefined;
|
|
111
|
+
};
|
|
112
|
+
static: {
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
timeout: number;
|
|
115
|
+
pythonPath?: string | undefined;
|
|
116
|
+
};
|
|
117
|
+
dotnet: {
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
timeout: number;
|
|
120
|
+
ilspyPath?: string | undefined;
|
|
121
|
+
};
|
|
122
|
+
sandbox: {
|
|
123
|
+
enabled: boolean;
|
|
124
|
+
timeout: number;
|
|
125
|
+
};
|
|
126
|
+
}, {
|
|
127
|
+
ghidra?: {
|
|
128
|
+
path?: string | undefined;
|
|
129
|
+
enabled?: boolean | undefined;
|
|
130
|
+
maxConcurrent?: number | undefined;
|
|
131
|
+
timeout?: number | undefined;
|
|
132
|
+
} | undefined;
|
|
133
|
+
static?: {
|
|
134
|
+
enabled?: boolean | undefined;
|
|
135
|
+
timeout?: number | undefined;
|
|
136
|
+
pythonPath?: string | undefined;
|
|
137
|
+
} | undefined;
|
|
138
|
+
dotnet?: {
|
|
139
|
+
enabled?: boolean | undefined;
|
|
140
|
+
timeout?: number | undefined;
|
|
141
|
+
ilspyPath?: string | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
sandbox?: {
|
|
144
|
+
enabled?: boolean | undefined;
|
|
145
|
+
timeout?: number | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
}>>;
|
|
148
|
+
cache: z.ZodDefault<z.ZodObject<{
|
|
149
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
150
|
+
ttl: z.ZodDefault<z.ZodNumber>;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
enabled: boolean;
|
|
153
|
+
ttl: number;
|
|
154
|
+
}, {
|
|
155
|
+
enabled?: boolean | undefined;
|
|
156
|
+
ttl?: number | undefined;
|
|
157
|
+
}>>;
|
|
158
|
+
logging: z.ZodDefault<z.ZodObject<{
|
|
159
|
+
level: z.ZodDefault<z.ZodEnum<["trace", "debug", "info", "warn", "error", "fatal"]>>;
|
|
160
|
+
pretty: z.ZodDefault<z.ZodBoolean>;
|
|
161
|
+
}, "strip", z.ZodTypeAny, {
|
|
162
|
+
level: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
163
|
+
pretty: boolean;
|
|
164
|
+
}, {
|
|
165
|
+
level?: "trace" | "debug" | "info" | "warn" | "error" | "fatal" | undefined;
|
|
166
|
+
pretty?: boolean | undefined;
|
|
167
|
+
}>>;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
server: {
|
|
170
|
+
port: number;
|
|
171
|
+
host: string;
|
|
172
|
+
};
|
|
173
|
+
database: {
|
|
174
|
+
type: "sqlite" | "postgresql";
|
|
175
|
+
port?: number | undefined;
|
|
176
|
+
host?: string | undefined;
|
|
177
|
+
path?: string | undefined;
|
|
178
|
+
database?: string | undefined;
|
|
179
|
+
user?: string | undefined;
|
|
180
|
+
password?: string | undefined;
|
|
181
|
+
};
|
|
182
|
+
workspace: {
|
|
183
|
+
root: string;
|
|
184
|
+
maxSampleSize: number;
|
|
185
|
+
};
|
|
186
|
+
workers: {
|
|
187
|
+
ghidra: {
|
|
188
|
+
enabled: boolean;
|
|
189
|
+
maxConcurrent: number;
|
|
190
|
+
timeout: number;
|
|
191
|
+
path?: string | undefined;
|
|
192
|
+
};
|
|
193
|
+
static: {
|
|
194
|
+
enabled: boolean;
|
|
195
|
+
timeout: number;
|
|
196
|
+
pythonPath?: string | undefined;
|
|
197
|
+
};
|
|
198
|
+
dotnet: {
|
|
199
|
+
enabled: boolean;
|
|
200
|
+
timeout: number;
|
|
201
|
+
ilspyPath?: string | undefined;
|
|
202
|
+
};
|
|
203
|
+
sandbox: {
|
|
204
|
+
enabled: boolean;
|
|
205
|
+
timeout: number;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
cache: {
|
|
209
|
+
enabled: boolean;
|
|
210
|
+
ttl: number;
|
|
211
|
+
};
|
|
212
|
+
logging: {
|
|
213
|
+
level: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
214
|
+
pretty: boolean;
|
|
215
|
+
};
|
|
216
|
+
}, {
|
|
217
|
+
server?: {
|
|
218
|
+
port?: number | undefined;
|
|
219
|
+
host?: string | undefined;
|
|
220
|
+
} | undefined;
|
|
221
|
+
database?: {
|
|
222
|
+
port?: number | undefined;
|
|
223
|
+
host?: string | undefined;
|
|
224
|
+
path?: string | undefined;
|
|
225
|
+
type?: "sqlite" | "postgresql" | undefined;
|
|
226
|
+
database?: string | undefined;
|
|
227
|
+
user?: string | undefined;
|
|
228
|
+
password?: string | undefined;
|
|
229
|
+
} | undefined;
|
|
230
|
+
workspace?: {
|
|
231
|
+
root?: string | undefined;
|
|
232
|
+
maxSampleSize?: number | undefined;
|
|
233
|
+
} | undefined;
|
|
234
|
+
workers?: {
|
|
235
|
+
ghidra?: {
|
|
236
|
+
path?: string | undefined;
|
|
237
|
+
enabled?: boolean | undefined;
|
|
238
|
+
maxConcurrent?: number | undefined;
|
|
239
|
+
timeout?: number | undefined;
|
|
240
|
+
} | undefined;
|
|
241
|
+
static?: {
|
|
242
|
+
enabled?: boolean | undefined;
|
|
243
|
+
timeout?: number | undefined;
|
|
244
|
+
pythonPath?: string | undefined;
|
|
245
|
+
} | undefined;
|
|
246
|
+
dotnet?: {
|
|
247
|
+
enabled?: boolean | undefined;
|
|
248
|
+
timeout?: number | undefined;
|
|
249
|
+
ilspyPath?: string | undefined;
|
|
250
|
+
} | undefined;
|
|
251
|
+
sandbox?: {
|
|
252
|
+
enabled?: boolean | undefined;
|
|
253
|
+
timeout?: number | undefined;
|
|
254
|
+
} | undefined;
|
|
255
|
+
} | undefined;
|
|
256
|
+
cache?: {
|
|
257
|
+
enabled?: boolean | undefined;
|
|
258
|
+
ttl?: number | undefined;
|
|
259
|
+
} | undefined;
|
|
260
|
+
logging?: {
|
|
261
|
+
level?: "trace" | "debug" | "info" | "warn" | "error" | "fatal" | undefined;
|
|
262
|
+
pretty?: boolean | undefined;
|
|
263
|
+
} | undefined;
|
|
264
|
+
}>;
|
|
265
|
+
export type Config = z.infer<typeof ConfigSchema>;
|
|
266
|
+
/**
|
|
267
|
+
* Load configuration from a JSON file
|
|
268
|
+
*/
|
|
269
|
+
export declare function loadConfigFromFile(filePath: string): Partial<Config>;
|
|
270
|
+
/**
|
|
271
|
+
* Load configuration from environment variables
|
|
272
|
+
*/
|
|
273
|
+
export declare function loadConfigFromEnv(): Record<string, any>;
|
|
274
|
+
/**
|
|
275
|
+
* Merge multiple configuration sources with priority: env > file > defaults
|
|
276
|
+
*/
|
|
277
|
+
export declare function mergeConfigs(...configs: any[]): any;
|
|
278
|
+
/**
|
|
279
|
+
* Load and validate configuration from all sources
|
|
280
|
+
*/
|
|
281
|
+
export declare function loadConfig(configPath?: string): Config;
|
|
282
|
+
/**
|
|
283
|
+
* Default configuration instance
|
|
284
|
+
* Loads configuration from environment variables and default config file
|
|
285
|
+
*/
|
|
286
|
+
export declare const config: {
|
|
287
|
+
server: {
|
|
288
|
+
port: number;
|
|
289
|
+
host: string;
|
|
290
|
+
};
|
|
291
|
+
database: {
|
|
292
|
+
type: "sqlite" | "postgresql";
|
|
293
|
+
port?: number | undefined;
|
|
294
|
+
host?: string | undefined;
|
|
295
|
+
path?: string | undefined;
|
|
296
|
+
database?: string | undefined;
|
|
297
|
+
user?: string | undefined;
|
|
298
|
+
password?: string | undefined;
|
|
299
|
+
};
|
|
300
|
+
workspace: {
|
|
301
|
+
root: string;
|
|
302
|
+
maxSampleSize: number;
|
|
303
|
+
};
|
|
304
|
+
workers: {
|
|
305
|
+
ghidra: {
|
|
306
|
+
enabled: boolean;
|
|
307
|
+
maxConcurrent: number;
|
|
308
|
+
timeout: number;
|
|
309
|
+
path?: string | undefined;
|
|
310
|
+
};
|
|
311
|
+
static: {
|
|
312
|
+
enabled: boolean;
|
|
313
|
+
timeout: number;
|
|
314
|
+
pythonPath?: string | undefined;
|
|
315
|
+
};
|
|
316
|
+
dotnet: {
|
|
317
|
+
enabled: boolean;
|
|
318
|
+
timeout: number;
|
|
319
|
+
ilspyPath?: string | undefined;
|
|
320
|
+
};
|
|
321
|
+
sandbox: {
|
|
322
|
+
enabled: boolean;
|
|
323
|
+
timeout: number;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
cache: {
|
|
327
|
+
enabled: boolean;
|
|
328
|
+
ttl: number;
|
|
329
|
+
};
|
|
330
|
+
logging: {
|
|
331
|
+
level: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
332
|
+
pretty: boolean;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for MCP Server
|
|
3
|
+
* Handles loading and validating configuration from files and environment variables
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
// Configuration schema using Zod
|
|
8
|
+
export const ConfigSchema = z.object({
|
|
9
|
+
server: z.object({
|
|
10
|
+
port: z.number().int().min(1).max(65535).default(3000),
|
|
11
|
+
host: z.string().default('localhost'),
|
|
12
|
+
}).default({}),
|
|
13
|
+
database: z.object({
|
|
14
|
+
type: z.enum(['sqlite', 'postgresql']).default('sqlite'),
|
|
15
|
+
path: z.string().optional(),
|
|
16
|
+
host: z.string().optional(),
|
|
17
|
+
port: z.number().int().optional(),
|
|
18
|
+
database: z.string().optional(),
|
|
19
|
+
user: z.string().optional(),
|
|
20
|
+
password: z.string().optional(),
|
|
21
|
+
}).default({}),
|
|
22
|
+
workspace: z.object({
|
|
23
|
+
root: z.string().default('./workspaces'),
|
|
24
|
+
maxSampleSize: z.number().int().min(1).default(500 * 1024 * 1024), // 500MB
|
|
25
|
+
}).default({}),
|
|
26
|
+
workers: z.object({
|
|
27
|
+
ghidra: z.object({
|
|
28
|
+
enabled: z.boolean().default(false),
|
|
29
|
+
path: z.string().optional(),
|
|
30
|
+
maxConcurrent: z.number().int().min(1).max(16).default(4),
|
|
31
|
+
timeout: z.number().int().min(1).default(300),
|
|
32
|
+
}).default({}),
|
|
33
|
+
static: z.object({
|
|
34
|
+
enabled: z.boolean().default(true),
|
|
35
|
+
pythonPath: z.string().optional(),
|
|
36
|
+
timeout: z.number().int().min(1).default(60),
|
|
37
|
+
}).default({}),
|
|
38
|
+
dotnet: z.object({
|
|
39
|
+
enabled: z.boolean().default(false),
|
|
40
|
+
ilspyPath: z.string().optional(),
|
|
41
|
+
timeout: z.number().int().min(1).default(60),
|
|
42
|
+
}).default({}),
|
|
43
|
+
sandbox: z.object({
|
|
44
|
+
enabled: z.boolean().default(false),
|
|
45
|
+
timeout: z.number().int().min(1).default(120),
|
|
46
|
+
}).default({}),
|
|
47
|
+
}).default({}),
|
|
48
|
+
cache: z.object({
|
|
49
|
+
enabled: z.boolean().default(true),
|
|
50
|
+
ttl: z.number().int().min(0).default(30 * 24 * 60 * 60), // 30 days
|
|
51
|
+
}).default({}),
|
|
52
|
+
logging: z.object({
|
|
53
|
+
level: z.enum(['trace', 'debug', 'info', 'warn', 'error', 'fatal']).default('info'),
|
|
54
|
+
pretty: z.boolean().default(false),
|
|
55
|
+
}).default({}),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Load configuration from a JSON file
|
|
59
|
+
*/
|
|
60
|
+
export function loadConfigFromFile(filePath) {
|
|
61
|
+
try {
|
|
62
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
63
|
+
return JSON.parse(content);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error.code === 'ENOENT') {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`Failed to load config from ${filePath}: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Load configuration from environment variables
|
|
74
|
+
*/
|
|
75
|
+
export function loadConfigFromEnv() {
|
|
76
|
+
const config = {};
|
|
77
|
+
// Server configuration
|
|
78
|
+
if (process.env.SERVER_PORT) {
|
|
79
|
+
if (!config.server)
|
|
80
|
+
config.server = {};
|
|
81
|
+
config.server.port = parseInt(process.env.SERVER_PORT, 10);
|
|
82
|
+
}
|
|
83
|
+
if (process.env.SERVER_HOST) {
|
|
84
|
+
if (!config.server)
|
|
85
|
+
config.server = {};
|
|
86
|
+
config.server.host = process.env.SERVER_HOST;
|
|
87
|
+
}
|
|
88
|
+
// Database configuration
|
|
89
|
+
if (process.env.DB_TYPE) {
|
|
90
|
+
if (!config.database)
|
|
91
|
+
config.database = {};
|
|
92
|
+
config.database.type = process.env.DB_TYPE;
|
|
93
|
+
}
|
|
94
|
+
if (process.env.DB_PATH) {
|
|
95
|
+
if (!config.database)
|
|
96
|
+
config.database = {};
|
|
97
|
+
config.database.path = process.env.DB_PATH;
|
|
98
|
+
}
|
|
99
|
+
if (process.env.DB_HOST) {
|
|
100
|
+
if (!config.database)
|
|
101
|
+
config.database = {};
|
|
102
|
+
config.database.host = process.env.DB_HOST;
|
|
103
|
+
}
|
|
104
|
+
if (process.env.DB_PORT) {
|
|
105
|
+
if (!config.database)
|
|
106
|
+
config.database = {};
|
|
107
|
+
config.database.port = parseInt(process.env.DB_PORT, 10);
|
|
108
|
+
}
|
|
109
|
+
// Workspace configuration
|
|
110
|
+
if (process.env.WORKSPACE_ROOT) {
|
|
111
|
+
if (!config.workspace)
|
|
112
|
+
config.workspace = {};
|
|
113
|
+
config.workspace.root = process.env.WORKSPACE_ROOT;
|
|
114
|
+
}
|
|
115
|
+
if (process.env.MAX_SAMPLE_SIZE) {
|
|
116
|
+
if (!config.workspace)
|
|
117
|
+
config.workspace = {};
|
|
118
|
+
config.workspace.maxSampleSize = parseInt(process.env.MAX_SAMPLE_SIZE, 10);
|
|
119
|
+
}
|
|
120
|
+
// Worker configuration
|
|
121
|
+
if (process.env.GHIDRA_PATH || process.env.GHIDRA_INSTALL_DIR) {
|
|
122
|
+
if (!config.workers)
|
|
123
|
+
config.workers = {};
|
|
124
|
+
if (!config.workers.ghidra)
|
|
125
|
+
config.workers.ghidra = {};
|
|
126
|
+
config.workers.ghidra.path = process.env.GHIDRA_PATH || process.env.GHIDRA_INSTALL_DIR;
|
|
127
|
+
config.workers.ghidra.enabled = true;
|
|
128
|
+
}
|
|
129
|
+
if (process.env.PYTHON_PATH) {
|
|
130
|
+
if (!config.workers)
|
|
131
|
+
config.workers = {};
|
|
132
|
+
if (!config.workers.static)
|
|
133
|
+
config.workers.static = {};
|
|
134
|
+
config.workers.static.pythonPath = process.env.PYTHON_PATH;
|
|
135
|
+
}
|
|
136
|
+
// Logging configuration
|
|
137
|
+
if (process.env.LOG_LEVEL) {
|
|
138
|
+
if (!config.logging)
|
|
139
|
+
config.logging = {};
|
|
140
|
+
config.logging.level = process.env.LOG_LEVEL;
|
|
141
|
+
}
|
|
142
|
+
return config;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Deep merge helper function
|
|
146
|
+
*/
|
|
147
|
+
function deepMerge(target, source) {
|
|
148
|
+
const output = { ...target };
|
|
149
|
+
if (isObject(target) && isObject(source)) {
|
|
150
|
+
Object.keys(source).forEach(key => {
|
|
151
|
+
if (isObject(source[key])) {
|
|
152
|
+
if (!(key in target)) {
|
|
153
|
+
output[key] = source[key];
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
output[key] = deepMerge(target[key], source[key]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
output[key] = source[key];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return output;
|
|
165
|
+
}
|
|
166
|
+
function isObject(item) {
|
|
167
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Merge multiple configuration sources with priority: env > file > defaults
|
|
171
|
+
*/
|
|
172
|
+
export function mergeConfigs(...configs) {
|
|
173
|
+
return configs.reduce((acc, config) => deepMerge(acc, config), {});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Load and validate configuration from all sources
|
|
177
|
+
*/
|
|
178
|
+
export function loadConfig(configPath) {
|
|
179
|
+
const fileConfig = configPath ? loadConfigFromFile(configPath) : {};
|
|
180
|
+
const envConfig = loadConfigFromEnv();
|
|
181
|
+
const mergedConfig = mergeConfigs(fileConfig, envConfig);
|
|
182
|
+
const result = ConfigSchema.safeParse(mergedConfig);
|
|
183
|
+
if (!result.success) {
|
|
184
|
+
throw new Error(`Configuration validation failed: ${result.error.message}`);
|
|
185
|
+
}
|
|
186
|
+
return result.data;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Default configuration instance
|
|
190
|
+
* Loads configuration from environment variables and default config file
|
|
191
|
+
*/
|
|
192
|
+
export const config = loadConfig();
|
|
193
|
+
//# sourceMappingURL=config.js.map
|