@eyeauras/insight-cli 0.5.8 → 0.6.1
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/.cli-package-build.json +1 -1
- package/SKILL.md +1 -1
- package/dist/src/artifacts.d.ts +1 -1
- package/dist/src/artifacts.js +3 -3
- package/dist/src/cli.js +74 -15
- package/dist/src/contexts.d.ts +120 -10
- package/dist/src/contexts.js +510 -107
- package/dist/src/legacy-migration.d.ts +37 -0
- package/dist/src/legacy-migration.js +238 -0
- package/dist/src/lifecycle.d.ts +16 -5
- package/dist/src/lifecycle.js +43 -6
- package/dist/src/merge.d.ts +1 -1
- package/dist/src/merge.js +2 -2
- package/dist/src/model.d.ts +5 -0
- package/dist/src/model.js +2 -0
- package/dist/src/native-inputs.js +12 -2
- package/dist/src/native-merge-patches.d.ts +6 -0
- package/dist/src/native-merge-patches.js +100 -0
- package/dist/src/persistent-client.d.ts +8 -2
- package/dist/src/persistent-client.js +30 -8
- package/dist/src/projects.js +5 -4
- package/dist/src/research.d.ts +77 -14
- package/dist/src/research.js +99 -123
- package/dist/src/sdk-files.js +3 -3
- package/dist/src/server.d.ts +5 -1
- package/dist/src/server.js +46 -6
- package/dist/src/storage-gc.d.ts +23 -0
- package/dist/src/storage-gc.js +358 -0
- package/dist/src/sync-policy.js +4 -2
- package/dist/src/version-tracking.js +2 -1
- package/dist/src/workspace.d.ts +35 -2
- package/dist/src/workspace.js +91 -7
- package/package.json +1 -1
- package/references/native/APACHE-2.0.txt +202 -0
- package/references/native/HeadlessProgramMergeManager.java +86 -0
- package/references/native/InsightGuiMain.java +1 -0
- package/references/native/InsightHeadlessMain.java +1 -0
- package/references/native/InsightInitialImport.java +1 -1
- package/references/native/InsightNativeCheckout.java +214 -0
- package/references/native/InsightNativeFingerprint.java +53 -0
- package/references/native/InsightNativeMigration.java +155 -0
- package/references/native/InsightNativeRead.java +57 -0
- package/references/native/InsightNativeView.java +29 -0
- package/references/native/InsightOfflineAuthenticator.java +20 -0
- package/references/native/InsightSdkFiles.java +4 -0
- package/references/native/InsightSnapshotFields.java +17 -11
- package/references/native/InsightSnapshotInspect.java +4 -2
- package/references/native/NATIVE-MERGE-NOTICE.txt +15 -0
- package/references/persistent-client.mjs +30 -8
- package/references/persistent.md +47 -7
- package/references/recovery.md +50 -12
- package/references/research.md +25 -22
- package/references/setup.md +13 -3
- package/skill-bundle/insight-artifacts/SKILL.md +1 -1
- package/skill-bundle/insight-artifacts/references/recovery.md +50 -12
- package/skill-bundle/insight-binary/SKILL.md +1 -1
- package/skill-bundle/insight-capture/SKILL.md +1 -1
- package/skill-bundle/insight-cli/SKILL.md +1 -1
- package/skill-bundle/insight-cli/references/persistent-client.mjs +30 -8
- package/skill-bundle/insight-cli/references/persistent.md +47 -7
- package/skill-bundle/insight-cli/references/recovery.md +50 -12
- package/skill-bundle/insight-cli/references/setup.md +13 -3
- package/skill-bundle/insight-die/SKILL.md +1 -1
- package/skill-bundle/insight-dnspy/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-dump/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-stack/SKILL.md +1 -1
- package/skill-bundle/insight-dotnet-trace/SKILL.md +1 -1
- package/skill-bundle/insight-frida/SKILL.md +1 -1
- package/skill-bundle/insight-ghidra/SKILL.md +8 -1
- package/skill-bundle/insight-ghidra/references/persistent-client.mjs +30 -8
- package/skill-bundle/insight-ghidra/references/persistent.md +47 -7
- package/skill-bundle/insight-ghidra/references/recovery.md +50 -12
- package/skill-bundle/insight-ghidra/references/research.md +25 -22
- package/skill-bundle/insight-ghidra/references/setup.md +13 -3
- package/skill-bundle/insight-ilspy/SKILL.md +1 -1
- package/skill-bundle/insight-interop/SKILL.md +1 -1
- package/skill-bundle/insight-lldb/SKILL.md +1 -1
- package/skill-bundle/insight-llvm/SKILL.md +1 -1
- package/skill-bundle/insight-managed-heap/SKILL.md +1 -1
- package/skill-bundle/insight-managed-metadata/SKILL.md +1 -1
- package/skill-bundle/insight-mitmproxy/SKILL.md +1 -1
- package/skill-bundle/insight-overview/SKILL.md +1 -1
- package/skill-bundle/insight-procmon/SKILL.md +1 -1
- package/skill-bundle/insight-re/SKILL.md +1 -1
- package/skill-bundle/insight-re/references/persistent-client.mjs +30 -8
- package/skill-bundle/insight-re/references/persistent.md +47 -7
- package/skill-bundle/insight-re/references/recovery.md +50 -12
- package/skill-bundle/insight-sevenzip/SKILL.md +1 -1
- package/skill-bundle/insight-strace/SKILL.md +1 -1
- package/skill-bundle/insight-tshark/SKILL.md +1 -1
- package/skill-bundle/insight-windbg/SKILL.md +1 -1
- package/skill-bundle/manifest.json +1 -1
- package/skills/insight-artifacts/SKILL.md +1 -1
- package/skills/insight-artifacts/references/recovery.md +50 -12
- package/skills/insight-binary/SKILL.md +1 -1
- package/skills/insight-capture/SKILL.md +1 -1
- package/skills/insight-die/SKILL.md +1 -1
- package/skills/insight-dnspy/SKILL.md +1 -1
- package/skills/insight-dotnet-dump/SKILL.md +1 -1
- package/skills/insight-dotnet-stack/SKILL.md +1 -1
- package/skills/insight-dotnet-trace/SKILL.md +1 -1
- package/skills/insight-frida/SKILL.md +1 -1
- package/skills/insight-ghidra/SKILL.md +8 -1
- package/skills/insight-ghidra/references/persistent-client.mjs +30 -8
- package/skills/insight-ghidra/references/persistent.md +47 -7
- package/skills/insight-ghidra/references/recovery.md +50 -12
- package/skills/insight-ghidra/references/research.md +25 -22
- package/skills/insight-ghidra/references/setup.md +13 -3
- package/skills/insight-ilspy/SKILL.md +1 -1
- package/skills/insight-interop/SKILL.md +1 -1
- package/skills/insight-lldb/SKILL.md +1 -1
- package/skills/insight-llvm/SKILL.md +1 -1
- package/skills/insight-managed-heap/SKILL.md +1 -1
- package/skills/insight-managed-metadata/SKILL.md +1 -1
- package/skills/insight-mitmproxy/SKILL.md +1 -1
- package/skills/insight-overview/SKILL.md +1 -1
- package/skills/insight-procmon/SKILL.md +1 -1
- package/skills/insight-re/SKILL.md +1 -1
- package/skills/insight-re/references/persistent-client.mjs +30 -8
- package/skills/insight-re/references/persistent.md +47 -7
- package/skills/insight-re/references/recovery.md +50 -12
- package/skills/insight-sevenzip/SKILL.md +1 -1
- package/skills/insight-strace/SKILL.md +1 -1
- package/skills/insight-tshark/SKILL.md +1 -1
- package/skills/insight-windbg/SKILL.md +1 -1
package/dist/src/workspace.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
import { chmodSync, mkdirSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { chmodSync, mkdirSync, readFileSync, realpathSync } from 'node:fs';
|
|
3
3
|
import { basename, join } from 'node:path';
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
5
|
import { Artifacts } from './artifacts.js';
|
|
@@ -124,7 +124,7 @@ export class Workspace {
|
|
|
124
124
|
}
|
|
125
125
|
knownSnapshot(artifact) {
|
|
126
126
|
this.artifacts.path(artifact);
|
|
127
|
-
if (artifact.kind
|
|
127
|
+
if (!['snapshot', 'native'].includes(artifact.kind) || this.db.prepare('SELECT data FROM artifacts WHERE id=?').get(artifact.id)?.data !== stable(artifact))
|
|
128
128
|
fail('artifact', 'Context requires a captured immutable snapshot.');
|
|
129
129
|
}
|
|
130
130
|
async captureSnapshot(path) {
|
|
@@ -132,6 +132,7 @@ export class Workspace {
|
|
|
132
132
|
this.rememberArtifact(artifact);
|
|
133
133
|
return artifact;
|
|
134
134
|
}
|
|
135
|
+
async captureNative(path) { const artifact = await this.artifacts.capture(path, 'native'); this.rememberArtifact(artifact); return artifact; }
|
|
135
136
|
async importTarget(path) {
|
|
136
137
|
const name = text(basename(path), 512);
|
|
137
138
|
const input = await this.artifacts.capture(path, 'input');
|
|
@@ -267,6 +268,79 @@ export class Workspace {
|
|
|
267
268
|
const row = this.db.prepare('SELECT data FROM requests WHERE context=? AND (id=? OR caller_id=?)').get(this.context(scope).id, id(identity), id(identity));
|
|
268
269
|
return row ? JSON.parse(String(row.data)) : undefined;
|
|
269
270
|
}
|
|
271
|
+
allContexts() { return this.db.prepare('SELECT data FROM contexts ORDER BY rowid').all().map(row => JSON.parse(String(row.data))); }
|
|
272
|
+
allArtifacts() { return this.db.prepare('SELECT data FROM artifacts ORDER BY rowid').all().map(row => JSON.parse(String(row.data))); }
|
|
273
|
+
/** An abandoned or otherwise unknown terminal effect keeps all of its native evidence. */
|
|
274
|
+
uncertainOutcome(scope) {
|
|
275
|
+
return this.db.prepare("SELECT data FROM requests WHERE context=? AND state='failed'").all(this.context(scope).id)
|
|
276
|
+
.some(row => JSON.parse(String(row.data)).result?.outcome === 'unknown');
|
|
277
|
+
}
|
|
278
|
+
/** Receipt-only comparison; native state is verified separately before any release. */
|
|
279
|
+
unchangedNative(context) {
|
|
280
|
+
if (context.nativeCheckout?.state === 'verified')
|
|
281
|
+
return true;
|
|
282
|
+
if (context.workingSnapshot?.kind !== 'native' || context.baseSnapshot?.kind !== 'native')
|
|
283
|
+
return false;
|
|
284
|
+
try {
|
|
285
|
+
const [local, base] = [context.workingSnapshot, context.baseSnapshot].map(value => JSON.parse(readFileSync(this.artifacts.path(value), 'utf8')));
|
|
286
|
+
return typeof local.fingerprint === 'string' && local.fingerprint === base.fingerprint;
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/** Another context's unresolved operation may still need this checkout's private view. */
|
|
293
|
+
checkoutReferenced(context) {
|
|
294
|
+
const root = context.nativeCheckout?.root, seen = new Set();
|
|
295
|
+
if (!root)
|
|
296
|
+
return false;
|
|
297
|
+
for (const row of this.db.prepare("SELECT data FROM requests WHERE context<>? AND state IN ('running','unknown')").all(context.id))
|
|
298
|
+
for (const match of String(row.data).matchAll(/native:([a-f0-9]{64})/g))
|
|
299
|
+
seen.add(match[1]);
|
|
300
|
+
for (const sha of seen)
|
|
301
|
+
try {
|
|
302
|
+
const value = JSON.parse(readFileSync(join(this.directory, 'artifacts', sha + '.json'), 'utf8'));
|
|
303
|
+
if (value.source === 'checkout' && value.checkout?.root === root)
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
/** Applied requests keep their results; their superseded before-images are not recovery inputs. */
|
|
312
|
+
artifactRoots() {
|
|
313
|
+
const roots = new Set(), scan = (value) => { for (const match of value.matchAll(/(?:input|snapshot|native):[a-f0-9]{64}/g))
|
|
314
|
+
roots.add(match[0]); };
|
|
315
|
+
for (const table of ['targets', 'sessions', 'ghidra_models', 'contexts', 'administration_requests'])
|
|
316
|
+
for (const row of this.db.prepare('SELECT data FROM ' + table).all())
|
|
317
|
+
scan(String(row.data));
|
|
318
|
+
for (const row of this.db.prepare("SELECT data FROM publications WHERE state<>'verified'").all())
|
|
319
|
+
scan(String(row.data));
|
|
320
|
+
for (const row of this.db.prepare('SELECT state,data FROM requests').all())
|
|
321
|
+
scan(row.state === 'applied' ? stable(JSON.parse(String(row.data)).result ?? null) : String(row.data));
|
|
322
|
+
return roots;
|
|
323
|
+
}
|
|
324
|
+
forgetArtifact(artifact) { this.db.prepare('DELETE FROM artifacts WHERE id=?').run(artifact); }
|
|
325
|
+
/** A detached context proved equal to a server version continues from a lazy native checkout. */
|
|
326
|
+
resetMigratedContext(scope) {
|
|
327
|
+
const context = this.context(scope);
|
|
328
|
+
if (context.nativeCheckout || context.scalars.length || context.complexChanges.length || context.debugger?.traces.length || context.debugger?.connected || this.unresolved(scope).length || this.uncertainOutcome(scope))
|
|
329
|
+
fail('blocked', 'Only an unchanged detached context can be reset by migration.');
|
|
330
|
+
this.writeContext(scope, context.generation, { state: 'stopped', workingSnapshot: undefined, baseSnapshot: undefined, baseRevision: undefined, viewEpoch: (context.viewEpoch ?? 0) + 1 });
|
|
331
|
+
}
|
|
332
|
+
recoverMigrationOpen(scope) {
|
|
333
|
+
return this.transaction(() => {
|
|
334
|
+
const context = this.context(scope), unresolved = this.unresolved(scope);
|
|
335
|
+
if (context.nativeCheckout || context.workingSnapshot || context.scalars.length || context.complexChanges.length || context.debugger?.traces.length || unresolved.some(q => q.operation !== 'ghidra.open'))
|
|
336
|
+
fail('blocked', 'Only a proven no-work open can be recovered by migration.');
|
|
337
|
+
for (const request of unresolved)
|
|
338
|
+
this.writeRequest(request.id, 'failed', { ...scope, state: 'not_opened', reason: 'explicit_native_migration_completed', previousResult: request.result ?? null });
|
|
339
|
+
if (unresolved.length)
|
|
340
|
+
this.writeContext(scope, context.generation, { state: 'stopped' });
|
|
341
|
+
return unresolved.length;
|
|
342
|
+
});
|
|
343
|
+
}
|
|
270
344
|
request(request) {
|
|
271
345
|
const row = this.db.prepare('SELECT data FROM requests WHERE id=?').get(id(request));
|
|
272
346
|
if (!row)
|
|
@@ -451,7 +525,7 @@ export class Workspace {
|
|
|
451
525
|
return next;
|
|
452
526
|
});
|
|
453
527
|
}
|
|
454
|
-
finishPublication(publication, publishedRevision, result) {
|
|
528
|
+
finishPublication(publication, publishedRevision, result, sharedSnapshot) {
|
|
455
529
|
version(publishedRevision);
|
|
456
530
|
return this.transaction(() => {
|
|
457
531
|
const previous = this.publication(publication);
|
|
@@ -460,9 +534,13 @@ export class Workspace {
|
|
|
460
534
|
const context = this.context(previous), model = this.model(previous.target);
|
|
461
535
|
if (context.generation !== previous.generation)
|
|
462
536
|
fail('binding', 'Private context changed during publication; preserve both saved versions.');
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
537
|
+
if (sharedSnapshot)
|
|
538
|
+
this.knownSnapshot(sharedSnapshot);
|
|
539
|
+
const saved = sharedSnapshot ?? previous.snapshot;
|
|
540
|
+
this.writeContext(previous, previous.generation, { state: context.nativeCheckout ? 'stopped' : 'ready', baseRevision: publishedRevision, baseSnapshot: saved,
|
|
541
|
+
workingSnapshot: saved, viewEpoch: (context.viewEpoch ?? 0) + 1, scalars: [], complexChanges: [],
|
|
542
|
+
...(context.nativeCheckout ? { nativeCheckout: { ...context.nativeCheckout, state: 'verified', baseVersion: publishedRevision } } : {}) });
|
|
543
|
+
this.db.prepare('UPDATE ghidra_models SET data=? WHERE target=?').run(stable({ ...model, state: 'ready', sharedRevision: publishedRevision, sharedSnapshot: saved }), previous.target);
|
|
466
544
|
this.writeRequest(previous.request, 'applied', result);
|
|
467
545
|
const next = { ...previous, state: 'verified', publishedRevision };
|
|
468
546
|
this.db.prepare('UPDATE publications SET state=?,data=? WHERE id=?').run(next.state, bounded(next), next.id);
|
|
@@ -519,7 +597,7 @@ export class Workspace {
|
|
|
519
597
|
writeContext(scope, expectedGeneration, patch) {
|
|
520
598
|
if (!Number.isSafeInteger(expectedGeneration) || expectedGeneration < 0)
|
|
521
599
|
fail('invalid', 'Invalid context generation.');
|
|
522
|
-
if (Object.keys(patch).some(key => !['state', 'baseRevision', 'baseSnapshot', 'workingSnapshot', 'viewEpoch', 'scalars', 'complexChanges', 'debugger', 'syncPolicy'].includes(key)) ||
|
|
600
|
+
if (Object.keys(patch).some(key => !['state', 'baseRevision', 'baseSnapshot', 'workingSnapshot', 'viewEpoch', 'scalars', 'complexChanges', 'debugger', 'syncPolicy', 'nativeCheckout'].includes(key)) ||
|
|
523
601
|
patch.state !== undefined && !['opening', 'ready', 'stopped', 'needs_recovery'].includes(patch.state))
|
|
524
602
|
fail('invalid', 'Invalid context state update.');
|
|
525
603
|
if (patch.baseRevision !== undefined)
|
|
@@ -530,6 +608,12 @@ export class Workspace {
|
|
|
530
608
|
this.knownSnapshot(patch.baseSnapshot);
|
|
531
609
|
if (patch.workingSnapshot)
|
|
532
610
|
this.knownSnapshot(patch.workingSnapshot);
|
|
611
|
+
if (patch.nativeCheckout) {
|
|
612
|
+
const n = patch.nativeCheckout;
|
|
613
|
+
if (n.schema !== 1 || !['active', 'verified', 'dropped'].includes(n.state) || !Number.isSafeInteger(n.checkoutId) || n.checkoutId < 0 || !Number.isSafeInteger(n.baseVersion) || n.baseVersion < 1 ||
|
|
614
|
+
!/^[a-f0-9]{64}$/.test(n.runtimeFingerprint) || n.context !== this.context(scope).id || !n.root || !n.fileId || !n.origin || !n.repository || n.path !== '/' + scope.target + '.bin')
|
|
615
|
+
fail('binding', 'Native checkout receipt is malformed.');
|
|
616
|
+
}
|
|
533
617
|
if (patch.syncPolicy) {
|
|
534
618
|
const p = patch.syncPolicy;
|
|
535
619
|
if (Object.keys(p).some(k => !['publish', 'refresh'].includes(k)) || !['manual', 'after-edit', 'after-save'].includes(p.publish) || !['manual', 'before-edit'].includes(p.refresh))
|
package/package.json
CHANGED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 LaurieWired (original GhidraMCP project)
|
|
190
|
+
Copyright 2025-2026 Ben Ethington and Ghidra MCP Server contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Headless orchestration around the stock Ghidra 12.1.2 merge manager.
|
|
3
|
+
* Orchestration derives from Ghidra's MergeManager.java,
|
|
4
|
+
* Copyright National Security Agency, licensed under Apache-2.0.
|
|
5
|
+
* The stock superclass creates and orders all native resolvers. No merge
|
|
6
|
+
* algorithms or category selection are implemented by this subclass.
|
|
7
|
+
*/
|
|
8
|
+
package insight.nativecheckout;
|
|
9
|
+
|
|
10
|
+
import java.util.*;
|
|
11
|
+
import javax.swing.JComponent;
|
|
12
|
+
import ghidra.app.merge.*;
|
|
13
|
+
import ghidra.app.merge.tool.ListingMergePanel;
|
|
14
|
+
import ghidra.framework.model.DomainObject;
|
|
15
|
+
import ghidra.framework.plugintool.ModalPluginTool;
|
|
16
|
+
import ghidra.program.model.address.Address;
|
|
17
|
+
import ghidra.program.model.listing.*;
|
|
18
|
+
import ghidra.util.HelpLocation;
|
|
19
|
+
import ghidra.util.exception.CancelledException;
|
|
20
|
+
import ghidra.util.task.TaskMonitor;
|
|
21
|
+
|
|
22
|
+
public class HeadlessProgramMergeManager extends ProgramMultiUserMergeManager {
|
|
23
|
+
public static int invocations;
|
|
24
|
+
public static final List<String> phases = new ArrayList<>();
|
|
25
|
+
public static final class UnresolvedNativeConflict extends RuntimeException {
|
|
26
|
+
UnresolvedNativeConflict(String category) { super("Native conflict requires a decision: " + category); }
|
|
27
|
+
}
|
|
28
|
+
private static String describe(JComponent component){
|
|
29
|
+
StringBuilder text=new StringBuilder();ArrayDeque<java.awt.Component> pending=new ArrayDeque<>();pending.add(component);
|
|
30
|
+
int visited=0;
|
|
31
|
+
while(!pending.isEmpty()&&visited++<256&&text.length()<8192){
|
|
32
|
+
var c=pending.removeFirst();String value=null;
|
|
33
|
+
if(c instanceof javax.swing.JLabel label)value=label.getText();
|
|
34
|
+
else if(c instanceof javax.swing.text.JTextComponent field)value=field.getText();
|
|
35
|
+
if(value!=null&&!value.isBlank())text.append(' ').append(value.substring(0,Math.min(value.length(),512)));
|
|
36
|
+
if(c instanceof java.awt.Container container)pending.addAll(Arrays.asList(container.getComponents()));
|
|
37
|
+
}
|
|
38
|
+
return text.toString();
|
|
39
|
+
}
|
|
40
|
+
public HeadlessProgramMergeManager(Program result, Program mine, Program original,
|
|
41
|
+
Program latest, ProgramChangeSet latestChanges, ProgramChangeSet myChanges) {
|
|
42
|
+
super(result, mine, original, latest, latestChanges, myChanges);
|
|
43
|
+
}
|
|
44
|
+
@Override public boolean merge(TaskMonitor monitor) throws CancelledException {
|
|
45
|
+
if (!java.awt.GraphicsEnvironment.isHeadless()) throw new IllegalStateException("Headless native merge only");
|
|
46
|
+
invocations++;
|
|
47
|
+
for (currentIndex=0; currentIndex<mergeResolvers.length; currentIndex++) {
|
|
48
|
+
monitor.checkCancelled();
|
|
49
|
+
MergeResolver resolver=mergeResolvers[currentIndex];
|
|
50
|
+
phases.add(resolver.getName());
|
|
51
|
+
try { resolver.merge(monitor); }
|
|
52
|
+
catch (CancelledException e) { throw e; }
|
|
53
|
+
catch (RuntimeException e) { throw e; }
|
|
54
|
+
catch (Exception e) { throw new IllegalStateException("Native resolver failed: "+resolver.getName(),e); }
|
|
55
|
+
}
|
|
56
|
+
mergeCompleted=true;
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
@Override protected MergeManagerPlugin createMergeManagerPlugin(ModalPluginTool t,MergeManager m,DomainObject d) { throw new IllegalStateException("GUI forbidden"); }
|
|
60
|
+
@Override protected void initializeMerge() { throw new IllegalStateException("GUI forbidden"); }
|
|
61
|
+
@Override protected void cleanupMerge() {}
|
|
62
|
+
public ListingMergePanel getListingMergePanel() { return null; }
|
|
63
|
+
public boolean isShowListingPanel() { return false; }
|
|
64
|
+
public boolean isMergeToolVisible() { return false; }
|
|
65
|
+
public boolean isShowingListingMergePanel() { return false; }
|
|
66
|
+
public void removeListingMergePanel() {}
|
|
67
|
+
public void refreshListingMergePanel(Address r,Address l,Address m,Address o) {}
|
|
68
|
+
public void showListingMergePanel(Address a) { throw new UnresolvedNativeConflict("listing"); }
|
|
69
|
+
public void showListingMergePanel(Address r,Address l,Address m,Address o) { throw new UnresolvedNativeConflict("listing"); }
|
|
70
|
+
@Override public void showComponent(JComponent component,String id,HelpLocation help) {
|
|
71
|
+
if(component!=null) throw new UnresolvedNativeConflict(id+describe(component));
|
|
72
|
+
}
|
|
73
|
+
@Override public void showDefaultMergePanel(String description) {}
|
|
74
|
+
@Override public void setApplyEnabled(boolean enabled) {}
|
|
75
|
+
@Override public void clearStatusText() {}
|
|
76
|
+
@Override public void setStatusText(String text) {}
|
|
77
|
+
@Override public void showMonitorComponent(boolean visible) {}
|
|
78
|
+
@Override public void showProgressIcon(boolean visible) {}
|
|
79
|
+
@Override public void removeComponent(JComponent component) {}
|
|
80
|
+
@Override public void waitForInput() { throw new UnresolvedNativeConflict("input"); }
|
|
81
|
+
@Override public void setInProgress(String[] phase) {}
|
|
82
|
+
@Override public void setCompleted(String[] phase) {}
|
|
83
|
+
@Override public void updateProgress(int percentage) {}
|
|
84
|
+
@Override public void updateProgress(int percentage,String message) {}
|
|
85
|
+
@Override public void updateProgress(String message) {}
|
|
86
|
+
}
|
|
@@ -14,6 +14,7 @@ class InsightGuiMain {
|
|
|
14
14
|
GhidraApplicationConfiguration configuration=new GhidraApplicationConfiguration();
|
|
15
15
|
configuration.setShowSplashScreen(false);
|
|
16
16
|
Application.initializeApplication(new GhidraApplicationLayout(),configuration);
|
|
17
|
+
insight.nativecheckout.InsightOfflineAuthenticator.install();
|
|
17
18
|
SwingUtilities.invokeAndWait(()->{
|
|
18
19
|
try {
|
|
19
20
|
var manager=new OwnedProjectManager();
|
|
@@ -4,6 +4,7 @@ import com.xebyte.headless.GhidraMCPHeadlessServer;
|
|
|
4
4
|
/** Preserve caller-selected names in the owned facade, including structure fields. */
|
|
5
5
|
class InsightHeadlessMain {
|
|
6
6
|
public static void main(String[] args) {
|
|
7
|
+
insight.nativecheckout.InsightOfflineAuthenticator.install();
|
|
7
8
|
NamingPolicy.getInstance().setStrictNamingEnforcement(false, "insight facade");
|
|
8
9
|
GhidraMCPHeadlessServer.main(args);
|
|
9
10
|
}
|
|
@@ -28,7 +28,7 @@ class InsightInitialImport {
|
|
|
28
28
|
Application.initializeApplication(new GhidraApplicationLayout(),new HeadlessGhidraApplicationConfiguration());
|
|
29
29
|
JsonObject settings=p.getAsJsonObject("settings"),request=new JsonObject();
|
|
30
30
|
request.addProperty("input",input.toString());request.addProperty("output",root.resolve(InsightInitialJournal.text(s,"snapshot")).toString());
|
|
31
|
-
request.add("auto_analyze",settings.get("autoAnalyze"));
|
|
31
|
+
request.add("auto_analyze",settings.get("autoAnalyze"));request.addProperty("native_model",true);
|
|
32
32
|
for(String key:List.of("language","loader"))if(settings.has(key))request.add(key,settings.get(key));
|
|
33
33
|
if(settings.has("compilerSpec"))request.add("compiler_spec",settings.get("compilerSpec"));
|
|
34
34
|
if(settings.has("imageBase"))request.add("image_base",settings.get("imageBase"));
|