@eyeauras/insight-cli 0.8.2 → 0.8.4
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/README.md +53 -7
- package/SKILL.md +4 -8
- package/dist/src/administration.js +1 -1
- package/dist/src/archive.js +1 -1
- package/dist/src/artifacts.d.ts +2 -1
- package/dist/src/artifacts.js +6 -5
- package/dist/src/binary.js +1 -1
- package/dist/src/capture.js +3 -3
- package/dist/src/cli.js +17 -16
- package/dist/src/contexts.js +14 -17
- package/dist/src/cross.js +1 -1
- package/dist/src/debugger.js +1 -1
- package/dist/src/die.js +1 -1
- package/dist/src/dnspy.js +1 -1
- package/dist/src/dotnet-diagnostics.js +1 -1
- package/dist/src/ilspy.js +1 -1
- package/dist/src/lifecycle.js +5 -5
- package/dist/src/lldb.js +1 -1
- package/dist/src/llvm.js +1 -1
- package/dist/src/managed-heap.js +1 -1
- package/dist/src/managed-metadata.js +1 -1
- package/dist/src/mitmproxy.js +1 -1
- package/dist/src/model.d.ts +6 -1
- package/dist/src/model.js +9 -2
- package/dist/src/mutations.js +1 -1
- package/dist/src/projects.js +3 -3
- package/dist/src/prototype-cli.js +4 -4
- package/dist/src/research.js +1 -1
- package/dist/src/runtime-manager.d.ts +2 -2
- package/dist/src/runtime-manager.js +28 -4
- package/dist/src/sdk-files.js +3 -3
- package/dist/src/sdk.js +1 -1
- package/dist/src/server.d.ts +1 -0
- package/dist/src/server.js +17 -7
- package/dist/src/sevenzip.js +1 -1
- package/dist/src/strace.js +1 -1
- package/dist/src/sync-policy.js +4 -4
- package/dist/src/tool-runtime/identity.d.ts +7 -0
- package/dist/src/tool-runtime/identity.js +35 -0
- package/dist/src/tool-runtime/store.js +3 -0
- package/dist/src/tool-runtime/supervisor.d.ts +8 -0
- package/dist/src/tool-runtime/supervisor.js +58 -10
- package/dist/src/tshark.js +1 -1
- package/dist/src/ui.js +3 -3
- package/dist/src/version-tracking.js +2 -2
- package/dist/src/windbg.js +1 -1
- package/dist/src/work/backup.js +17 -5
- package/dist/src/work/commands.js +51 -14
- package/dist/src/work/model.d.ts +43 -1
- package/dist/src/work/model.js +128 -0
- package/dist/src/work/store.d.ts +34 -3
- package/dist/src/work/store.js +78 -21
- package/dist/src/work/timing.d.ts +9 -0
- package/dist/src/work/timing.js +10 -1
- package/package.json +1 -1
- package/references/agent-setup.md +2 -11
- package/references/debugger.md +1 -1
- package/references/managed-runtime.md +1 -2
- package/references/native/InsightNativeCheckout.java +24 -8
- package/references/recovery.md +2 -34
- package/references/research.md +5 -5
- package/references/setup.md +0 -4
- package/references/work-tracking.md +61 -3
- package/skill-bundle/insight-artifacts/SKILL.md +3 -7
- package/skill-bundle/insight-artifacts/references/recovery.md +2 -34
- package/skill-bundle/insight-binary/SKILL.md +3 -7
- package/skill-bundle/insight-capture/SKILL.md +3 -7
- package/skill-bundle/insight-cli/SKILL.md +4 -8
- package/skill-bundle/insight-cli/references/agent-setup.md +2 -11
- package/skill-bundle/insight-cli/references/managed-runtime.md +1 -2
- package/skill-bundle/insight-cli/references/recovery.md +2 -34
- package/skill-bundle/insight-cli/references/setup.md +0 -4
- package/skill-bundle/insight-die/SKILL.md +3 -7
- package/skill-bundle/insight-dnspy/SKILL.md +3 -7
- package/skill-bundle/insight-dotnet-dump/SKILL.md +3 -7
- package/skill-bundle/insight-dotnet-stack/SKILL.md +3 -7
- package/skill-bundle/insight-dotnet-trace/SKILL.md +3 -7
- package/skill-bundle/insight-frida/SKILL.md +3 -7
- package/skill-bundle/insight-ghidra/SKILL.md +13 -36
- package/skill-bundle/insight-ghidra/references/debugger.md +1 -1
- package/skill-bundle/insight-ghidra/references/managed-runtime.md +1 -2
- package/skill-bundle/insight-ghidra/references/recovery.md +2 -34
- package/skill-bundle/insight-ghidra/references/research.md +5 -5
- package/skill-bundle/insight-ghidra/references/setup.md +0 -4
- package/skill-bundle/insight-ilspy/SKILL.md +3 -7
- package/skill-bundle/insight-interop/SKILL.md +3 -7
- package/skill-bundle/insight-lldb/SKILL.md +3 -7
- package/skill-bundle/insight-llvm/SKILL.md +3 -7
- package/skill-bundle/insight-managed-heap/SKILL.md +3 -7
- package/skill-bundle/insight-managed-metadata/SKILL.md +3 -7
- package/skill-bundle/insight-mitmproxy/SKILL.md +3 -7
- package/skill-bundle/insight-overview/SKILL.md +3 -7
- package/skill-bundle/insight-procmon/SKILL.md +3 -7
- package/skill-bundle/insight-re/SKILL.md +4 -8
- package/skill-bundle/insight-re/references/recovery.md +2 -34
- package/skill-bundle/insight-re/references/work-tracking.md +61 -3
- package/skill-bundle/insight-sevenzip/SKILL.md +3 -7
- package/skill-bundle/insight-strace/SKILL.md +3 -7
- package/skill-bundle/insight-tshark/SKILL.md +3 -7
- package/skill-bundle/insight-windbg/SKILL.md +3 -7
- package/skill-bundle/manifest.json +1 -1
- package/skills/insight-artifacts/SKILL.md +3 -7
- package/skills/insight-artifacts/references/recovery.md +2 -34
- package/skills/insight-binary/SKILL.md +3 -7
- package/skills/insight-capture/SKILL.md +3 -7
- package/skills/insight-die/SKILL.md +3 -7
- package/skills/insight-dnspy/SKILL.md +3 -7
- package/skills/insight-dotnet-dump/SKILL.md +3 -7
- package/skills/insight-dotnet-stack/SKILL.md +3 -7
- package/skills/insight-dotnet-trace/SKILL.md +3 -7
- package/skills/insight-frida/SKILL.md +3 -7
- package/skills/insight-ghidra/SKILL.md +13 -36
- package/skills/insight-ghidra/references/debugger.md +1 -1
- package/skills/insight-ghidra/references/managed-runtime.md +1 -2
- package/skills/insight-ghidra/references/recovery.md +2 -34
- package/skills/insight-ghidra/references/research.md +5 -5
- package/skills/insight-ghidra/references/setup.md +0 -4
- package/skills/insight-ilspy/SKILL.md +3 -7
- package/skills/insight-interop/SKILL.md +3 -7
- package/skills/insight-lldb/SKILL.md +3 -7
- package/skills/insight-llvm/SKILL.md +3 -7
- package/skills/insight-managed-heap/SKILL.md +3 -7
- package/skills/insight-managed-metadata/SKILL.md +3 -7
- package/skills/insight-mitmproxy/SKILL.md +3 -7
- package/skills/insight-overview/SKILL.md +3 -7
- package/skills/insight-procmon/SKILL.md +3 -7
- package/skills/insight-re/SKILL.md +4 -8
- package/skills/insight-re/references/recovery.md +2 -34
- package/skills/insight-re/references/work-tracking.md +61 -3
- package/skills/insight-sevenzip/SKILL.md +3 -7
- package/skills/insight-strace/SKILL.md +3 -7
- package/skills/insight-tshark/SKILL.md +3 -7
- package/skills/insight-windbg/SKILL.md +3 -7
package/.cli-package-build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":1,"artifact":"
|
|
1
|
+
{"version":1,"artifact":"b471fa238b3b427034aa4b28b9d99ce95cb05a493a77482a15c18bb3a8d920ba"}
|
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ less time managing Ghidra processes or writing scripts around missing analysis m
|
|
|
5
5
|
|
|
6
6
|
- Search raw strings and code references, and inspect functions in sparse Ghidra databases.
|
|
7
7
|
- Give each agent an isolated research context, with saved work and explicit merge/refresh.
|
|
8
|
+
- Coordinate several agents reconstructing one program with the `work` ledger.
|
|
8
9
|
- Use structured JSON results and a persistent client for sequences of research calls.
|
|
9
10
|
|
|
10
11
|
## Install
|
|
@@ -47,12 +48,57 @@ Results include scan coverage and a continuation cursor when incomplete. New imp
|
|
|
47
48
|
skip full automatic analysis by default; add `--analysis` to the first `open` to opt in.
|
|
48
49
|
Continue with the [research guide](https://github.com/iXab3r/insight-cli/blob/main/skills/ghidra-coordinator/references/research.md).
|
|
49
50
|
|
|
50
|
-
##
|
|
51
|
+
## Other tools
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
Besides Ghidra, the CLI manages pinned runtimes for ILSpy, dnSpyEx, 7-Zip, LLVM, DiE, LLDB,
|
|
54
|
+
WinDbg, Frida, ProcMon, strace, TShark, mitmproxy and .NET diagnostics (dump, stack, trace,
|
|
55
|
+
heap, metadata). All of them share the same targets, sessions and profile storage.
|
|
56
|
+
`insight-cli tools list` shows what is available; `insight-cli tools show <tool>` describes one
|
|
57
|
+
tool and locates its agent skill (for example `insight-cli skill insight-ilspy`).
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
## Several agents on one reconstruction
|
|
60
|
+
|
|
61
|
+
`insight-cli work` is an opt-in ledger for agents that reconstruct functions of one binary
|
|
62
|
+
together: nonoverlapping leased slices, retained source and contracts, evidence, and review by
|
|
63
|
+
a different worker. Every change takes a request ID, so a lost reply can be retried safely.
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
insight-cli -p RE work create --project client --target TARGET --name Client --request-id create-client --json
|
|
67
|
+
insight-cli -p RE work import --project client --file functions.json --request-id import-1 --json
|
|
68
|
+
insight-cli -p RE work next --project client --worker agent-a --request-id agent-a-next-1 --json
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The [work tracking reference](https://github.com/iXab3r/insight-cli/blob/main/skills/ghidra-coordinator/references/work-tracking.md) has the complete
|
|
72
|
+
workflow and input formats; [Work ledger](https://github.com/iXab3r/insight-cli/blob/main/docs/WORK.md) explains the model.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
git clone https://github.com/iXab3r/insight-cli.git
|
|
78
|
+
cd insight-cli
|
|
79
|
+
npm ci # locked dependencies
|
|
80
|
+
npm run build # TypeScript -> skills/ghidra-coordinator/dist
|
|
81
|
+
npm test # build + offline tests (no Ghidra, no network)
|
|
82
|
+
node skills/ghidra-coordinator/dist/src/bin.js --help
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
[Contributing](https://github.com/iXab3r/insight-cli/blob/main/CONTRIBUTING.md) covers running from source, test rules, packaging and the
|
|
86
|
+
native acceptance suites.
|
|
87
|
+
|
|
88
|
+
| Path | Contents |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| `skills/ghidra-coordinator/` | The CLI package `@eyeauras/insight-cli` (npm workspace) |
|
|
91
|
+
| `…/src/` | TypeScript sources; `work/` and `tool-runtime/` are the Work ledger and shared tool runtime |
|
|
92
|
+
| `…/tests/` | Offline `node:test` suites, compiled to `dist/tests` |
|
|
93
|
+
| `…/SKILL.md`, `…/references/`, `…/skills/` | Agent skill entrypoint, references and per-tool skills shipped in the package |
|
|
94
|
+
| `…/runtime/` | Tool catalog (`toolbox.json`), pinned distributions and native helper binaries |
|
|
95
|
+
| `scripts/` | Build, packaging, release, coverage audit and native acceptance runners |
|
|
96
|
+
| `tests/acceptance/` | Gherkin acceptance (Reqnroll/.NET) for native, business and toolbox gates |
|
|
97
|
+
| `vendor/` | Prepared Factory dependency tarballs with provenance |
|
|
98
|
+
| `docs/` | Design and maintainer documentation |
|
|
99
|
+
| `build/teamcity.sh` | CI entrypoint for verification and npm release |
|
|
100
|
+
|
|
101
|
+
Documentation: [design](https://github.com/iXab3r/insight-cli/blob/main/docs/DESIGN.md), [CLI scenarios](https://github.com/iXab3r/insight-cli/blob/main/docs/CLI-SCENARIOS.md),
|
|
102
|
+
[Work ledger](https://github.com/iXab3r/insight-cli/blob/main/docs/WORK.md), [tool runtime](https://github.com/iXab3r/insight-cli/blob/main/docs/TOOL-RUNTIME.md),
|
|
103
|
+
[adding tools](https://github.com/iXab3r/insight-cli/blob/main/docs/ADDING-TOOLS.md), [Gherkin acceptance](https://github.com/iXab3r/insight-cli/blob/main/docs/ACCEPTANCE-AUTOMATION.md),
|
|
104
|
+
[release CI](https://github.com/iXab3r/insight-cli/blob/main/docs/RELEASE-CI.md).
|
package/SKILL.md
CHANGED
|
@@ -3,14 +3,10 @@ name: insight-cli
|
|
|
3
3
|
description: Choose and prepare reverse-engineering capabilities from the insight-cli toolbox for binary, managed-code and runtime investigations. Use to discover the appropriate tool or its packaged skill before installing native runtimes.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# insight-cli 0.8.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
CLI calls too. An explicit **no command was sent** denial is known undispatched and can be
|
|
11
|
-
retried through that route. Keep HOME, profile and owner state; see
|
|
12
|
-
[host execution permissions](references/agent-execution.md). A lost mutation reply needs
|
|
13
|
-
request/status recovery, never blind retry.
|
|
6
|
+
# insight-cli 0.8.4
|
|
7
|
+
|
|
8
|
+
AppData/IPC access denied: follow [host execution permissions](references/agent-execution.md).
|
|
9
|
+
A lost mutation reply needs request/status recovery, never a blind retry.
|
|
14
10
|
|
|
15
11
|
Read the project's RE instructions and existing findings first. They own tool choices,
|
|
16
12
|
evidence layout, formats and source of truth. These skills fill the remaining gaps.
|
|
@@ -118,7 +118,7 @@ export function administrationCommands(service, unconfiguredStatus) {
|
|
|
118
118
|
fail('invalid', 'Access must be read_only, write or admin.');
|
|
119
119
|
parameters.access = access;
|
|
120
120
|
}
|
|
121
|
-
return changing ? service(c).change(leaf.operation, parameters, o.requestId === undefined ? undefined : id(o.requestId)) : service(c).read(leaf.operation, parameters);
|
|
121
|
+
return changing ? service(c).change(leaf.operation, parameters, o.requestId === undefined ? undefined : id(o.requestId, '--request-id')) : service(c).read(leaf.operation, parameters);
|
|
122
122
|
}, { permission: leaf.gate, options: [...leaf.params.map(option), ...(changing ? [{ flags: '--request-id <id>', description: 'Retrieve this administration outcome after a lost response' }] : [])] });
|
|
123
123
|
if (leaf.names.length === 1)
|
|
124
124
|
children.push(definition);
|
package/dist/src/archive.js
CHANGED
|
@@ -108,7 +108,7 @@ export function archiveCommands(service) {
|
|
|
108
108
|
p.limit = number(o.limit, 100000);
|
|
109
109
|
p.skip_default_named = !o.includeDefaultNamed;
|
|
110
110
|
}
|
|
111
|
-
return service(c).ingest(scope(o), operation, p, o.requestId === undefined ? undefined : id(o.requestId));
|
|
111
|
+
return service(c).ingest(scope(o), operation, p, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
112
112
|
}, { permission: Permission.Update, options: [...selectedOptions,
|
|
113
113
|
...(operation === 'function' ? [{ flags: '--address <address>', description: 'Selected function entry point', required: true }] : [{ flags: '--limit <count>', description: 'Maximum visited functions (0 means all, at most 100000)', defaultValue: 0 }, { flags: '--include-default-named', description: 'Include auto-named functions' }]),
|
|
114
114
|
{ flags: '--version-label <name>', description: 'Archive version label', defaultValue: 'unknown' }, { flags: '--dry-run', description: 'Validate payloads without sending documentation' },
|
package/dist/src/artifacts.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export declare class Artifacts {
|
|
|
13
13
|
private ownedDirectory;
|
|
14
14
|
private syncDirectory;
|
|
15
15
|
verify(value: Artifact): Promise<string>;
|
|
16
|
-
|
|
16
|
+
/** `limit` bounds the file as it is opened, so a file replaced after an earlier size check is never retained. */
|
|
17
|
+
capture(source: string, kind: ArtifactKind, limit?: number): Promise<Artifact>;
|
|
17
18
|
}
|
package/dist/src/artifacts.js
CHANGED
|
@@ -62,7 +62,8 @@ export class Artifacts {
|
|
|
62
62
|
await handle.close();
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
/** `limit` bounds the file as it is opened, so a file replaced after an earlier size check is never retained. */
|
|
66
|
+
async capture(source, kind, limit = maximumBytes) {
|
|
66
67
|
if (!['input', 'snapshot', 'native'].includes(kind))
|
|
67
68
|
fail('artifact', 'Unsupported artifact kind.');
|
|
68
69
|
const directory = await this.ownedDirectory();
|
|
@@ -71,15 +72,15 @@ export class Artifacts {
|
|
|
71
72
|
let output;
|
|
72
73
|
try {
|
|
73
74
|
const info = await input.stat({ bigint: true });
|
|
74
|
-
if (!info.isFile() || info.size < 1n || info.size > BigInt(maximumBytes))
|
|
75
|
-
fail('limit', 'Input must be a nonempty regular file of at most 4 GiB.');
|
|
75
|
+
if (!info.isFile() || info.size < 1n || info.size > BigInt(Math.min(limit, maximumBytes)))
|
|
76
|
+
fail('limit', limit < maximumBytes ? `Input must be a nonempty regular file of at most ${limit} bytes.` : 'Input must be a nonempty regular file of at most 4 GiB.');
|
|
76
77
|
output = await open(temporary, 'wx', 0o600);
|
|
77
78
|
const hash = createHash('sha256');
|
|
78
79
|
let size = 0;
|
|
79
80
|
for await (const chunk of input.createReadStream({ autoClose: false })) {
|
|
80
81
|
size += chunk.length;
|
|
81
|
-
if (size > maximumBytes)
|
|
82
|
-
fail('limit', 'Input exceeds
|
|
82
|
+
if (size > Math.min(limit, maximumBytes))
|
|
83
|
+
fail('limit', 'Input exceeds its size limit.');
|
|
83
84
|
hash.update(chunk);
|
|
84
85
|
await output.writeFile(chunk);
|
|
85
86
|
}
|
package/dist/src/binary.js
CHANGED
|
@@ -20,7 +20,7 @@ export function binaryCommands(workspace) {
|
|
|
20
20
|
const view = mode === 'query' ? text(o.view ?? 'overview', 16) : undefined;
|
|
21
21
|
if (view && !['overview', 'sections', 'libraries', 'imports', 'exports'].includes(view))
|
|
22
22
|
fail('invalid', 'Use overview, sections, libraries, imports or exports.');
|
|
23
|
-
const limit = number(o.limit ?? 50, 500, 1), offset = number(o.offset ?? 0, 1000000), w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target));
|
|
23
|
+
const limit = number(o.limit ?? 50, 500, 1), offset = number(o.offset ?? 0, 1000000), w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target'));
|
|
24
24
|
if (target.input.size > 64 * 1024 ** 2)
|
|
25
25
|
fail('limit', 'Structured binary input exceeds 64 MiB.');
|
|
26
26
|
const input = await w.artifacts.verify(target.input);
|
package/dist/src/capture.js
CHANGED
|
@@ -105,7 +105,7 @@ export function captureCommands(workspace) {
|
|
|
105
105
|
fail('unsupported', 'Process capture is verified on macOS14+ ARM64 thin native executables.');
|
|
106
106
|
if (Boolean(args.input) === Boolean(o.target))
|
|
107
107
|
fail('invalid', 'Supply one native program or --target.');
|
|
108
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), input = await w.artifacts.verify(target.input);
|
|
108
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), input = await w.artifacts.verify(target.input);
|
|
109
109
|
if (target.input.size > 64 * 1024 ** 2)
|
|
110
110
|
fail('limit', 'Owned executable exceeds 64 MiB.');
|
|
111
111
|
const header = (await boundedFile(input, 64 * 1024 ** 2)).subarray(0, 32);
|
|
@@ -126,7 +126,7 @@ export function captureCommands(workspace) {
|
|
|
126
126
|
files.push({ name, sha256: sha(data), bytes: data.length, data });
|
|
127
127
|
}
|
|
128
128
|
const stdin = o.stdinFile ? await boundedFile(resolve(c.cwd, text(o.stdinFile, 4096)), 1024 ** 2) : Buffer.alloc(0);
|
|
129
|
-
if (o.output && !(o.requestId && w.administrationByCaller(id(o.requestId))))
|
|
129
|
+
if (o.output && !(o.requestId && w.administrationByCaller(id(o.requestId, '--request-id'))))
|
|
130
130
|
try {
|
|
131
131
|
await lstat(resolve(c.cwd, text(o.output, 4096)));
|
|
132
132
|
fail('invalid', 'Capture output already exists.');
|
|
@@ -136,7 +136,7 @@ export function captureCommands(workspace) {
|
|
|
136
136
|
throw error;
|
|
137
137
|
}
|
|
138
138
|
const intent = { target: target.id, inputSha256: target.binarySha256, arguments: argv, inputs: files.map(({ data, ...f }) => f), stdin: { sha256: sha(stdin), bytes: stdin.length }, watch: watched, timeoutMs, output: o.output ? resolve(c.cwd, text(o.output, 4096)) : undefined };
|
|
139
|
-
const reservation = w.reserveAdministration('capture.run', intent, o.requestId === undefined ? undefined : id(o.requestId)), request = reservation.request.id;
|
|
139
|
+
const reservation = w.reserveAdministration('capture.run', intent, o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), request = reservation.request.id;
|
|
140
140
|
if (reservation.replay) {
|
|
141
141
|
const previous = await receiptFor(c, w, request);
|
|
142
142
|
if (reservation.request.state === 'applied' && 'kind' in previous) {
|
package/dist/src/cli.js
CHANGED
|
@@ -172,7 +172,7 @@ class Owner {
|
|
|
172
172
|
await (await selected.backend()).quiesce?.();
|
|
173
173
|
// A missing private-worker receipt does not prove an interrupted native helper stopped.
|
|
174
174
|
const helpers = await migrationProcessBlockers(c.appArguments.AppDataDirectory);
|
|
175
|
-
const workers = (await runtimeProcesses(analysisDirectory(c))).filter(p => p.kind !== 'server');
|
|
175
|
+
const workers = (await runtimeProcesses(analysisDirectory(c), c.appArguments.AppDataDirectory)).filter(p => p.kind !== 'server');
|
|
176
176
|
if (helpers.length || workers.length)
|
|
177
177
|
fail('busy', 'Stop or reconcile retained Ghidra workers and native helpers before ' + name + '; no takeover is performed.', { helpers, workers });
|
|
178
178
|
return await action(await selected.backend());
|
|
@@ -441,15 +441,15 @@ export function createDefinition(options = {}) {
|
|
|
441
441
|
const items = owner.selected(c).workspace.targets(number(o.limit, 100, 1), number(o.offset, 2147483647));
|
|
442
442
|
return { items: items.map(targetView), offset: o.offset, limit: o.limit, truncated: items.length === o.limit };
|
|
443
443
|
}, { permission: Permission.ReadOnly, options: paged }),
|
|
444
|
-
command('show <target>', 'Show an input identity', ({ args }, c) => targetView(owner.selected(c).workspace.target(id(args.target))), { permission: Permission.ReadOnly }),
|
|
444
|
+
command('show <target>', 'Show an input identity', ({ args }, c) => targetView(owner.selected(c).workspace.target(id(args.target, 'target'))), { permission: Permission.ReadOnly }),
|
|
445
445
|
]),
|
|
446
446
|
command('sessions', 'Inspect durable sessions', [
|
|
447
447
|
command('list', 'List independent sessions', ({ options: o }, c) => { const items = owner.selected(c).workspace.sessions(number(o.limit, 100, 1), number(o.offset, 2147483647)); return { items, offset: o.offset, limit: o.limit, truncated: items.length === Number(o.limit) }; }, { permission: Permission.ReadOnly, options: paged }),
|
|
448
448
|
command('status <session>', 'Inspect saved work and unresolved outcomes', ({ args, options: o }, c) => {
|
|
449
|
-
const selected = owner.selected(c), session = id(args.session);
|
|
449
|
+
const selected = owner.selected(c), session = id(args.session, 'session');
|
|
450
450
|
selected.workspace.session(session);
|
|
451
451
|
if (o.target)
|
|
452
|
-
return selected.research.status({ session, target: id(o.target) });
|
|
452
|
+
return selected.research.status({ session, target: id(o.target, '--target') });
|
|
453
453
|
const limit = number(o.limit, 100, 1), offset = number(o.offset, 2147483647), contexts = selected.workspace.contexts(session, limit, offset);
|
|
454
454
|
return { session, contexts: contexts.map(context => selected.research.status(context)), limit, offset, truncated: contexts.length === limit };
|
|
455
455
|
}, { permission: Permission.ReadOnly, options: [{ flags: '--target <id>', description: 'Inspect one target context' }, ...paged] }),
|
|
@@ -458,7 +458,7 @@ export function createDefinition(options = {}) {
|
|
|
458
458
|
command('migrate', 'Explicitly migrate retained legacy models; repeat to resume', ({ options: o }, c) => {
|
|
459
459
|
if (Boolean(o.target) === Boolean(o.all))
|
|
460
460
|
fail('invalid', 'Select exactly one --target or --all.');
|
|
461
|
-
return owner.migrate(c, o.target === undefined ? undefined : id(o.target), Boolean(o.dryRun));
|
|
461
|
+
return owner.migrate(c, o.target === undefined ? undefined : id(o.target, '--target'), Boolean(o.dryRun));
|
|
462
462
|
}, { permission: Permission.ReadOnly, options: [{ flags: '--target <id>', description: 'Migrate one immutable target' }, { flags: '--all', description: 'Inspect or migrate every Ghidra target in this profile' }, { flags: '--dry-run', description: 'Inspect without checkout, check-in or context changes' }] }),
|
|
463
463
|
command('gc', 'Reclaim redundant copies: unreferenced snapshots, duplicate exports, stopped detached projects and unchanged checkouts', ({ options: o }, c) => owner.collect(c, Boolean(o.dryRun)), { permission: Permission.ReadOnly, options: [{ flags: '--dry-run', description: 'Report reclaimable and retained storage without changing it' }] }),
|
|
464
464
|
command('progress', 'Read initial-model import/publication progress without starting Ghidra', async ({ options: o }, c) => {
|
|
@@ -481,14 +481,14 @@ export function createDefinition(options = {}) {
|
|
|
481
481
|
}, { permission: Permission.Update, options: [{ flags: '--initial-import-seconds <seconds>', description: 'Initial import/analysis: 1–86400 seconds' },
|
|
482
482
|
{ flags: '--save-seconds <seconds>', description: 'Native save/export: 1–3600 seconds' }] })
|
|
483
483
|
]),
|
|
484
|
-
command('abandon', 'Retain an uncertain legacy detached program attempt and resume its previous saved view', ({ options: o }, c) => owner.selected(c).research.abandon(scope(o), id(o.requestId), Boolean(o.acknowledgeUnknownEffects)), { permission: 'Destructive', options: [...scoped, { flags: '--request-id <id>', description: 'Original unresolved request ID from `insight-cli sessions status <session> --target <target>`', required: true }, { flags: '--acknowledge-unknown-effects', description: 'Acknowledge that the abandoned effect remains unknown; no script is replayed' }] }),
|
|
485
|
-
command('refresh', 'Receive safe shared changes while retaining local conflicts', ({ options: o }, c) => owner.selected(c).research.refresh(scope(o), o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [...scoped, request] }),
|
|
486
|
-
command('merge', 'Publish the complete selected context or retain every conflict; the context stays open at the published version', ({ options: o }, c) => owner.selected(c).research.merge(scope(o), o.requestId === undefined ? undefined : id(o.requestId), Boolean(o.close)), { permission: Permission.Update, options: [...scoped, request, { flags: '--close', description: 'Release the working copy after publishing instead of continuing in it' }] }),
|
|
484
|
+
command('abandon', 'Retain an uncertain legacy detached program attempt and resume its previous saved view', ({ options: o }, c) => owner.selected(c).research.abandon(scope(o), id(o.requestId, '--request-id'), Boolean(o.acknowledgeUnknownEffects)), { permission: 'Destructive', options: [...scoped, { flags: '--request-id <id>', description: 'Original unresolved request ID from `insight-cli sessions status <session> --target <target>`', required: true }, { flags: '--acknowledge-unknown-effects', description: 'Acknowledge that the abandoned effect remains unknown; no script is replayed' }] }),
|
|
485
|
+
command('refresh', 'Receive safe shared changes while retaining local conflicts', ({ options: o }, c) => owner.selected(c).research.refresh(scope(o), o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: Permission.Update, options: [...scoped, request] }),
|
|
486
|
+
command('merge', 'Publish the complete selected context or retain every conflict; the context stays open at the published version', ({ options: o }, c) => owner.selected(c).research.merge(scope(o), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), Boolean(o.close)), { permission: Permission.Update, options: [...scoped, request, { flags: '--close', description: 'Release the working copy after publishing instead of continuing in it' }] }),
|
|
487
487
|
command('open [input]', 'Start independent work or continue a context', async ({ args, options: o }, c) => {
|
|
488
488
|
if (Boolean(args.input) === Boolean(o.target))
|
|
489
489
|
fail('invalid', 'Supply exactly one input path or --target.');
|
|
490
490
|
return owner.openCommand(c, async (selected) => {
|
|
491
|
-
const target = args.input ? (await selected.workspace.importTarget(resolve(c.cwd, text(args.input, 4096)))).id : id(o.target);
|
|
491
|
+
const target = args.input ? (await selected.workspace.importTarget(resolve(c.cwd, text(args.input, 4096)))).id : id(o.target, '--target');
|
|
492
492
|
let previous;
|
|
493
493
|
try {
|
|
494
494
|
previous = selected.workspace.model(target).settings;
|
|
@@ -501,7 +501,8 @@ export function createDefinition(options = {}) {
|
|
|
501
501
|
...(o.language ? { language: text(o.language) } : {}), ...(o.compilerSpec ? { compilerSpec: text(o.compilerSpec) } : {}),
|
|
502
502
|
...(o.imageBase ? { imageBase: text(o.imageBase) } : {}), ...(o.loader ? { loader: text(o.loader, 512) } : {}),
|
|
503
503
|
...(o.loaderOptions !== undefined ? { loaderOptions: object(parseDomainJson(text(o.loaderOptions, 16000))) } : {}) };
|
|
504
|
-
|
|
504
|
+
const session = text(o.session);
|
|
505
|
+
return selected.research.open(target, session === 'new' ? session : id(session, '--session'), settings, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), mode(o.mode));
|
|
505
506
|
});
|
|
506
507
|
}, { permission: Permission.Update, options: [{ flags: '--session <id>', description: 'Use new for independent work, or an existing session', required: true },
|
|
507
508
|
{ flags: '--target <id>', description: 'Continue existing input instead of supplying a file' }, request,
|
|
@@ -526,7 +527,7 @@ export function createDefinition(options = {}) {
|
|
|
526
527
|
const selected = owner.selected(c), who = scope(o), name = text(o.name, 512), fields = structureFields(o.fields);
|
|
527
528
|
if (o.replacePlaceholder) {
|
|
528
529
|
const parameters = { path: name.startsWith('/') ? name : '/' + name, fields, packing: -1, alignment: 0, replace_placeholder: true };
|
|
529
|
-
return selected.research.mutate(who, '/sdk/type-structure', parameters, async () => ({}), o.requestId === undefined ? undefined : id(o.requestId), (backend, snapshot, response) => verifyMutation(backend, snapshot, '/sdk/type-structure', parameters, response));
|
|
530
|
+
return selected.research.mutate(who, '/sdk/type-structure', parameters, async () => ({}), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), (backend, snapshot, response) => verifyMutation(backend, snapshot, '/sdk/type-structure', parameters, response));
|
|
530
531
|
}
|
|
531
532
|
return selected.research.mutate(who, '/create_struct', { name, fields }, async (backend) => {
|
|
532
533
|
const result = object(await backend.call(who, '/get_struct_layout', { struct_name: name }));
|
|
@@ -536,7 +537,7 @@ export function createDefinition(options = {}) {
|
|
|
536
537
|
if (object(result.fields[i]).name !== fields[i].name)
|
|
537
538
|
fail('partial', 'Structure readback changed a field name.');
|
|
538
539
|
return result;
|
|
539
|
-
}, o.requestId === undefined ? undefined : id(o.requestId));
|
|
540
|
+
}, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
540
541
|
}, { permission: Permission.Update, options: [...scoped, { flags: '--name <name>', description: 'New structure name', required: true },
|
|
541
542
|
{ flags: '--fields <json>', description: 'Array of {name,type,offset?}', required: true }, { flags: '--replace-placeholder', description: 'Replace only an existing empty structure, with independently verified saved layout' }, request] }),
|
|
542
543
|
]),
|
|
@@ -550,7 +551,7 @@ export function createDefinition(options = {}) {
|
|
|
550
551
|
fill_byte: o.fillByte === undefined ? 0 : number(o.fillByte, 255), ...(o.bytesHex === undefined ? {} : { bytes_hex: o.bytesHex }), ...(o.bytesBase64 === undefined ? {} : { bytes_base64: o.bytesBase64 }) };
|
|
551
552
|
const expected = blockContent(parameters);
|
|
552
553
|
parameters.size = expected.size;
|
|
553
|
-
return selected.research.mutate(who, '/create_memory_block', parameters, async () => ({}), o.requestId === undefined ? undefined : id(o.requestId), (backend, snapshot, response) => verifyMutation(backend, snapshot, '/create_memory_block', parameters, response));
|
|
554
|
+
return selected.research.mutate(who, '/create_memory_block', parameters, async () => ({}), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), (backend, snapshot, response) => verifyMutation(backend, snapshot, '/create_memory_block', parameters, response));
|
|
554
555
|
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--name <name>', description: 'Memory block name', required: true },
|
|
555
556
|
{ flags: '--size <bytes>', description: 'Positive size up to 16 MiB; defaults to content length' },
|
|
556
557
|
{ flags: '--bytes-hex <hex>', description: 'Initial bytes in hexadecimal; remainder uses fill-byte' },
|
|
@@ -573,7 +574,7 @@ export function createDefinition(options = {}) {
|
|
|
573
574
|
command('set-function-prototype', 'Set a C prototype and optional explicit compiler-supported calling convention', ({ options: o }, c) => {
|
|
574
575
|
const selected = owner.selected(c), who = scope(o), parameters = { function_address: address(o.address), prototype: text(o.prototype, 16000),
|
|
575
576
|
...(o.callingConvention === undefined ? {} : { calling_convention: text(o.callingConvention, 512) }) };
|
|
576
|
-
return selected.research.mutate(who, '/set_function_prototype', parameters, async () => ({}), o.requestId === undefined ? undefined : id(o.requestId), (backend, snapshot, response) => verifyMutation(backend, snapshot, '/set_function_prototype', parameters, response));
|
|
577
|
+
return selected.research.mutate(who, '/set_function_prototype', parameters, async () => ({}), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), (backend, snapshot, response) => verifyMutation(backend, snapshot, '/set_function_prototype', parameters, response));
|
|
577
578
|
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--prototype <signature>', description: 'Complete C prototype', required: true },
|
|
578
579
|
{ flags: '--calling-convention <name>', description: 'Explicit convention supported by the selected compiler specification' }, request] }),
|
|
579
580
|
command('get', 'Read a function and entry comments', ({ options: o }, c) => owner.selected(c).research.function(scope(o), address(o.address)), { permission: Permission.ReadOnly, options: [...scoped, at] }),
|
|
@@ -582,7 +583,7 @@ export function createDefinition(options = {}) {
|
|
|
582
583
|
const name = text(o.name, 512);
|
|
583
584
|
if (name !== name.trim())
|
|
584
585
|
fail('invalid', 'Function name may not have leading or trailing whitespace.');
|
|
585
|
-
return owner.selected(c).research.edit(scope(o), address(o.address), 'function.name', name, o.requestId === undefined ? undefined : id(o.requestId), resolution(o));
|
|
586
|
+
return owner.selected(c).research.edit(scope(o), address(o.address), 'function.name', name, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), resolution(o));
|
|
586
587
|
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--name <name>', description: 'Desired function name', required: true }, request, ...resolveOptions] }),
|
|
587
588
|
]),
|
|
588
589
|
command('comments', 'Read or edit listing comments', [
|
|
@@ -590,7 +591,7 @@ export function createDefinition(options = {}) {
|
|
|
590
591
|
command('set', 'Record a saved private comment or clear it', ({ options: o }, c) => {
|
|
591
592
|
if (Boolean(o.clear) === (o.text !== undefined))
|
|
592
593
|
fail('invalid', 'Supply exactly one --text or --clear.');
|
|
593
|
-
return owner.selected(c).research.edit(scope(o), address(o.address), 'comment.' + commentKind(o.kind), o.clear ? null : scalarText(o.text), o.requestId === undefined ? undefined : id(o.requestId), resolution(o));
|
|
594
|
+
return owner.selected(c).research.edit(scope(o), address(o.address), 'comment.' + commentKind(o.kind), o.clear ? null : scalarText(o.text), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), resolution(o));
|
|
594
595
|
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--kind <kind>', description: 'eol, pre, post, plate or repeatable', required: true },
|
|
595
596
|
{ flags: '--text <text>', description: 'Desired text; empty text clears to null' }, { flags: '--clear', description: 'Clear this comment to null' }, request, ...resolveOptions] }),
|
|
596
597
|
]),
|
package/dist/src/contexts.js
CHANGED
|
@@ -5,10 +5,9 @@ import { ownedDirectory, projectPathWithin, sameDirectory } from './directory-id
|
|
|
5
5
|
import { releaseStoppedContextCredential, launchContextCredential } from './context-credential.js';
|
|
6
6
|
import { recordLifecycle } from './context-diagnostics.js';
|
|
7
7
|
import { ghidraBudget } from './budgets.js';
|
|
8
|
-
import { launchProcess, terminateProcess, processStatus } from './tool-runtime/supervisor.js';
|
|
8
|
+
import { launchProcess, terminateProcess, processStatus, recordedProcessGone, validEnd } from './tool-runtime/supervisor.js';
|
|
9
9
|
import { runTool } from './tool-runtime/run.js';
|
|
10
10
|
import { verifyGhidraProcess } from './ghidra-processes.js';
|
|
11
|
-
import { processIdentity } from './tool-runtime/identity.js';
|
|
12
11
|
import { CliError } from '@eyeauras/cli-factory';
|
|
13
12
|
import { runtimeProcesses } from './runtime-manager.js';
|
|
14
13
|
import { randomUUID, randomBytes, createHash } from 'node:crypto';
|
|
@@ -198,7 +197,7 @@ export class GhidraContexts {
|
|
|
198
197
|
if (operation === 'stop') {
|
|
199
198
|
if (this.c.profile.values.server)
|
|
200
199
|
fail('authorization', 'External server lifecycle is owned by its operator. Use server disconnect.');
|
|
201
|
-
const processes = await runtimeProcesses(dirname(this.workspace.directory));
|
|
200
|
+
const processes = await runtimeProcesses(dirname(this.workspace.directory), this.c.appArguments?.AppDataDirectory);
|
|
202
201
|
if (processes.some(p => p.kind !== 'server'))
|
|
203
202
|
fail('busy', 'Close active Ghidra contexts before stopping their server.');
|
|
204
203
|
}
|
|
@@ -1190,7 +1189,7 @@ export class GhidraContexts {
|
|
|
1190
1189
|
if (pending || context.nativeCheckout)
|
|
1191
1190
|
fail('blocked', 'A native checkout belongs to this context; it is not detached work.');
|
|
1192
1191
|
// A worker whose owner died before its current receipt is still found by its process receipt.
|
|
1193
|
-
if ((await runtimeProcesses(dirname(this.workspace.directory))).some(p => p.kind !== 'server' && (p.sessionContext ?? context.id) === context.id))
|
|
1192
|
+
if ((await runtimeProcesses(dirname(this.workspace.directory), this.c.appArguments?.AppDataDirectory)).some(p => p.kind !== 'server' && (p.sessionContext ?? context.id) === context.id))
|
|
1194
1193
|
return false;
|
|
1195
1194
|
return this.neverStartedOrClosed(context);
|
|
1196
1195
|
}
|
|
@@ -1245,7 +1244,7 @@ export class GhidraContexts {
|
|
|
1245
1244
|
}
|
|
1246
1245
|
// This owner's own idle native services are not foreign helpers; busy ones refuse.
|
|
1247
1246
|
await this.requireIdleServices();
|
|
1248
|
-
const process = await runtimeProcesses(dirname(this.workspace.directory));
|
|
1247
|
+
const process = await runtimeProcesses(dirname(this.workspace.directory), this.c.appArguments?.AppDataDirectory);
|
|
1249
1248
|
if (this.capacity.slots.has(context.id) || process.some(p => p.kind !== 'server') || (await migrationProcessBlockers(this.c.appArguments.AppDataDirectory)).length)
|
|
1250
1249
|
fail('busy', 'Stop or reconcile every Ghidra worker and native helper before giving up a missing checkout.');
|
|
1251
1250
|
return checkout;
|
|
@@ -2785,21 +2784,19 @@ public class ${name} extends GhidraScript {
|
|
|
2785
2784
|
if (!binding.toolProcessId)
|
|
2786
2785
|
return false;
|
|
2787
2786
|
try {
|
|
2788
|
-
const row = await processStatus(this.c.appArguments.AppDataDirectory, binding.toolProcessId);
|
|
2789
2787
|
// Read-only retirement evidence: old locators may no longer exist. Exact
|
|
2790
2788
|
// persisted locator equality is sufficient here; it never authorizes a signal.
|
|
2791
|
-
|
|
2792
|
-
row.pid
|
|
2793
|
-
row.installation
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
if (['exited', 'failed'].includes(row.state) &&
|
|
2789
|
+
const matches = (row) => row.id === binding.toolProcessId && row.tool === 'ghidra' && row.role === binding.kind &&
|
|
2790
|
+
row.pid === binding.pid && row.target === binding.target && row.session === binding.session &&
|
|
2791
|
+
row.installation === binding.runtimeFingerprint && typeof row.identity === 'string' && Boolean(row.identity) && typeof row.metadata?.contextRoot === 'string' &&
|
|
2792
|
+
resolve(row.metadata.contextRoot) === resolve(binding.root);
|
|
2793
|
+
const row = await processStatus(this.c.appArguments.AppDataDirectory, binding.toolProcessId);
|
|
2794
|
+
// A strongly identified receipt with an exactly recorded end, as before.
|
|
2795
|
+
if (matches(row) && ['exited', 'failed'].includes(row.state) && row.strongIdentity === true && validEnd(row.endedAt))
|
|
2798
2796
|
return true;
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
return current?.strong === true && current.birth !== row.identity;
|
|
2797
|
+
// Otherwise proved freshly from the PID's current holder, on the same receipt snapshot that is validated.
|
|
2798
|
+
const gone = await recordedProcessGone(this.c.appArguments.AppDataDirectory, binding.toolProcessId);
|
|
2799
|
+
return gone !== undefined && matches(gone);
|
|
2803
2800
|
}
|
|
2804
2801
|
catch {
|
|
2805
2802
|
return false;
|
package/dist/src/cross.js
CHANGED
|
@@ -34,7 +34,7 @@ export function crossCommands(research) {
|
|
|
34
34
|
const documentation = groups.get('documentation');
|
|
35
35
|
documentation.push(command('transfer', 'Copy documentation into a saved private destination; publish with explicit merge', ({ options: o }, c) => {
|
|
36
36
|
const selected = scope(o), source = { session: o.sourceSession === undefined ? selected.session : id(o.sourceSession), target: id(o.sourceTarget) };
|
|
37
|
-
return research(c).transfer(selected, source, Boolean(o.dryRun), o.requestId === undefined ? undefined : id(o.requestId));
|
|
37
|
+
return research(c).transfer(selected, source, Boolean(o.dryRun), o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
38
38
|
}, { permission: 'Destructive', options: [...selectedOptions, { flags: '--source-target <id>', description: 'Documentation source target', required: true },
|
|
39
39
|
{ flags: '--source-session <id>', description: 'Source context session (defaults to --session)' },
|
|
40
40
|
{ flags: '--dry-run', description: 'Preview transfer counts without applying documentation' },
|
package/dist/src/debugger.js
CHANGED
|
@@ -271,7 +271,7 @@ export function debuggerCommands(service) {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
const selected = scope(o), selectedTrace = o.trace === undefined ? undefined : id(o.trace);
|
|
274
|
-
return changing ? service(c).change(selected, operation, p, o.requestId === undefined ? undefined : id(o.requestId), selectedTrace) : service(c).read(selected, operation, p, selectedTrace);
|
|
274
|
+
return changing ? service(c).change(selected, operation, p, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'), selectedTrace) : service(c).read(selected, operation, p, selectedTrace);
|
|
275
275
|
}, { permission: operation === 'remove_breakpoint' || liveWrites.has(operation) ? 'Destructive' : changing ? Permission.Update : Permission.ReadOnly, options }));
|
|
276
276
|
}
|
|
277
277
|
return [command('debugger', 'Debug the selected immutable target in an owned GUI', leaves)];
|
package/dist/src/die.js
CHANGED
|
@@ -103,7 +103,7 @@ export function dieCommands(workspace) {
|
|
|
103
103
|
if (Boolean(args.input) === Boolean(o.target))
|
|
104
104
|
fail('invalid', 'Supply exactly one input path or --target.');
|
|
105
105
|
const limit = number(o.limit, 400, 1), offset = number(o.offset, 1000000, 0), timeoutMs = number(o.timeoutSeconds, 600, 1) * 1000;
|
|
106
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), input = await w.artifacts.verify(target.input);
|
|
106
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), input = await w.artifacts.verify(target.input);
|
|
107
107
|
return dieInstaller(c).use(async (selected) => {
|
|
108
108
|
const database = join(contents(selected.executable), 'Resources/db'), calls = [];
|
|
109
109
|
for (const mode of ['info', 'scan']) {
|
package/dist/src/dnspy.js
CHANGED
|
@@ -71,7 +71,7 @@ export function dnspyCommands(workspace) {
|
|
|
71
71
|
fail('invalid', 'Supply exactly one input path or --target.');
|
|
72
72
|
if (mode === 'edit-constant' && !o.output)
|
|
73
73
|
fail('invalid', 'A new --output assembly path is required.');
|
|
74
|
-
const limit = number(o.limit ?? 32, 64, 1), offset = number(o.offset ?? 0, 64), plan = dnspyPlan(o, mode), w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), source = await w.artifacts.verify(target.input), name = basename(args.input ? text(args.input, 4096) : target.name ?? 'input.exe');
|
|
74
|
+
const limit = number(o.limit ?? 32, 64, 1), offset = number(o.offset ?? 0, 64), plan = dnspyPlan(o, mode), w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), source = await w.artifacts.verify(target.input), name = basename(args.input ? text(args.input, 4096) : target.name ?? 'input.exe');
|
|
75
75
|
if ((!nativeFilename(name) || !/\.(?:exe|dll)$/i.test(name)))
|
|
76
76
|
fail('invalid', 'Input must have an ordinary .exe or .dll filename.');
|
|
77
77
|
const directory = join(c.appArguments.AppDataDirectory, 'runtime/dnspy/queries', randomUUID()), inputDirectory = join(directory, 'input'), extension = join(directory, 'extension');
|
|
@@ -60,7 +60,7 @@ export function diagnosticsCommands(workspace) {
|
|
|
60
60
|
return { ...base, content: lines.slice(offset, offset + limit).join('\n'), offset, limit, totalLines: lines.length, truncated: offset + limit < lines.length };
|
|
61
61
|
};
|
|
62
62
|
const input = async (args, o, c) => { if (Boolean(args.input) === Boolean(o.target))
|
|
63
|
-
fail('invalid', 'Supply exactly one input file or --target.'); const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)); return { w, target, path: await w.artifacts.verify(target.input) }; };
|
|
63
|
+
fail('invalid', 'Supply exactly one input file or --target.'); const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')); return { w, target, path: await w.artifacts.verify(target.input) }; };
|
|
64
64
|
const staged = async (c) => { const directory = join(c.appArguments.AppDataDirectory, 'runtime/exports', randomUUID()); await mkdir(directory, { recursive: true, mode: 0o700 }); return directory; };
|
|
65
65
|
const publish = async (path, o, c) => { const info = await stat(path); if (!info.isFile() || info.size < 1 || info.size > 4 * 1024 ** 3)
|
|
66
66
|
fail('limit', 'Capture/export must be a nonempty regular file below four GiB.'); const w = workspace(c), target = await w.importTarget(path), output = resolve(c.cwd, text(o.output, 4096)); await mkdir(dirname(output), { recursive: true, mode: 0o700 }); await copyFile(path, output, constants.COPYFILE_EXCL); return { output, bytes: info.size, target: target.id, inputSha256: target.binarySha256 }; };
|
package/dist/src/ilspy.js
CHANGED
|
@@ -66,7 +66,7 @@ export function ilspyCommands(workspace) {
|
|
|
66
66
|
const timeout = Number(o.timeoutSeconds);
|
|
67
67
|
if (!Number.isSafeInteger(timeout) || timeout < 1 || timeout > 1800)
|
|
68
68
|
fail('invalid', 'timeout-seconds must be from 1 to 1800.');
|
|
69
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), session = o.session === undefined ? undefined : w.session(id(o.session)).id, input = await w.artifacts.verify(target.input);
|
|
69
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), session = o.session === undefined ? undefined : w.session(id(o.session, '--session')).id, input = await w.artifacts.verify(target.input);
|
|
70
70
|
const directory = operation === 'project' || operation === 'resource';
|
|
71
71
|
if (directory && !o.output)
|
|
72
72
|
fail('invalid', 'This operation requires --output DIRECTORY.');
|
package/dist/src/lifecycle.js
CHANGED
|
@@ -297,13 +297,13 @@ export class Lifecycle {
|
|
|
297
297
|
}
|
|
298
298
|
export function lifecycleCommands(service, runtimeStatus) {
|
|
299
299
|
return [command('changes', 'Manage unpublished edits in the selected context', [
|
|
300
|
-
command('discard', 'Retain native keep data, discard private edits and check out the current server version', ({ options: o }, c) => service(c).discard(scope(o), o.requestId === undefined ? undefined : id(o.requestId)), { permission: 'Destructive', options: [...selectedOptions, { flags: '--request-id <id>', description: 'Retrieve the same local discard result' }] }),
|
|
300
|
+
command('discard', 'Retain native keep data, discard private edits and check out the current server version', ({ options: o }, c) => service(c).discard(scope(o), o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: 'Destructive', options: [...selectedOptions, { flags: '--request-id <id>', description: 'Retrieve the same local discard result' }] }),
|
|
301
301
|
command('recover-unsaved', 'Restore and save the unsaved changes an interrupted Ghidra session left in the working copy', ({ options: o }, c) => service(c).unsaved(scope(o), true), { permission: Permission.Update, options: selectedOptions }),
|
|
302
302
|
command('discard-unsaved', 'Drop the unsaved changes an interrupted Ghidra session left in the working copy; saved work is kept', ({ options: o }, c) => service(c).unsaved(scope(o), false), { permission: 'Destructive', options: selectedOptions }),
|
|
303
|
-
command('discard-legacy', 'Give up detached work of an older engine; gc then reclaims it and the next open starts a native checkout', ({ options: o }, c) => service(c).discardLegacy(scope(o), Boolean(o.acknowledgeLostWork), o.requestId === undefined ? undefined : id(o.requestId)), { permission: 'Destructive', options: [...selectedOptions, { flags: '--acknowledge-lost-work', description: 'Accept that unpublished edits and unknown outcomes of this context are dropped' }, { flags: '--request-id <id>', description: 'Retrieve the same discard result' }] }),
|
|
304
|
-
command('discard-missing', 'Give up a native checkout whose project directory no longer exists and end its server checkout; the next open starts a new one', ({ options: o }, c) => service(c).discardMissing(scope(o), Boolean(o.acknowledgeLostWork), o.requestId === undefined ? undefined : id(o.requestId)), { permission: 'Destructive', options: [...selectedOptions, { flags: '--acknowledge-lost-work', description: 'Accept that unpublished edits and unknown outcomes of this context are lost' }, { flags: '--request-id <id>', description: 'Retrieve the same discard result' }] })
|
|
303
|
+
command('discard-legacy', 'Give up detached work of an older engine; gc then reclaims it and the next open starts a native checkout', ({ options: o }, c) => service(c).discardLegacy(scope(o), Boolean(o.acknowledgeLostWork), o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: 'Destructive', options: [...selectedOptions, { flags: '--acknowledge-lost-work', description: 'Accept that unpublished edits and unknown outcomes of this context are dropped' }, { flags: '--request-id <id>', description: 'Retrieve the same discard result' }] }),
|
|
304
|
+
command('discard-missing', 'Give up a native checkout whose project directory no longer exists and end its server checkout; the next open starts a new one', ({ options: o }, c) => service(c).discardMissing(scope(o), Boolean(o.acknowledgeLostWork), o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: 'Destructive', options: [...selectedOptions, { flags: '--acknowledge-lost-work', description: 'Accept that unpublished edits and unknown outcomes of this context are lost' }, { flags: '--request-id <id>', description: 'Retrieve the same discard result' }] })
|
|
305
305
|
]),
|
|
306
|
-
command('save-all', 'Save every Ghidra context in the explicit session; outcomes are per context', ({ options: o }, c) => service(c).saveAll(id(o.session), o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [{ flags: '--session <id>', description: 'Explicit session whose contexts are saved', required: true }, { flags: '--request-id <id>', description: 'Retrieve the recorded session save outcomes' }] }),
|
|
306
|
+
command('save-all', 'Save every Ghidra context in the explicit session; outcomes are per context', ({ options: o }, c) => service(c).saveAll(id(o.session, '--session'), o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: Permission.Update, options: [{ flags: '--session <id>', description: 'Explicit session whose contexts are saved', required: true }, { flags: '--request-id <id>', description: 'Retrieve the recorded session save outcomes' }] }),
|
|
307
307
|
command('status', 'Inspect the installed runtime, or verify a selected context', ({ options: o }, c) => {
|
|
308
308
|
if (o.session === undefined && o.target === undefined && runtimeStatus)
|
|
309
309
|
return runtimeStatus(c);
|
|
@@ -311,5 +311,5 @@ export function lifecycleCommands(service, runtimeStatus) {
|
|
|
311
311
|
fail('invalid', 'Context status requires both --session and --target.');
|
|
312
312
|
return service(c).health(scope(o));
|
|
313
313
|
}, { permission: Permission.ReadOnly, options: selectedOptions.map(option => ({ ...option, required: false })) }),
|
|
314
|
-
...['save', 'close'].map(name => command(name, name === 'save' ? 'Save private work without publication' : 'Save and release the owned context; reopen retains local work', ({ options: o }, c) => service(c).change(scope(o), name, o.requestId === undefined ? undefined : id(o.requestId)), { permission: Permission.Update, options: [...selectedOptions, { flags: '--request-id <id>', description: 'Retrieve the lifecycle outcome after a lost response' }] }))];
|
|
314
|
+
...['save', 'close'].map(name => command(name, name === 'save' ? 'Save private work without publication' : 'Save and release the owned context; reopen retains local work', ({ options: o }, c) => service(c).change(scope(o), name, o.requestId === undefined ? undefined : id(o.requestId, '--request-id')), { permission: Permission.Update, options: [...selectedOptions, { flags: '--request-id <id>', description: 'Retrieve the lifecycle outcome after a lost response' }] }))];
|
|
315
315
|
}
|
package/dist/src/lldb.js
CHANGED
|
@@ -55,7 +55,7 @@ export function lldbCommands(workspace) {
|
|
|
55
55
|
if (Boolean(args.input) === Boolean(o.target))
|
|
56
56
|
fail('invalid', 'Supply exactly one input path or --target.');
|
|
57
57
|
const commands = lldbPlan(o), limit = number(o.limit ?? 200, 1000, 1), offset = number(o.offset ?? 0, 1000000), timeoutMs = number(o.timeoutSeconds ?? 30, 600, 1) * 1000;
|
|
58
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), input = await w.artifacts.verify(target.input), header = Buffer.alloc(32), handle = await open(input, 'r');
|
|
58
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), input = await w.artifacts.verify(target.input), header = Buffer.alloc(32), handle = await open(input, 'r');
|
|
59
59
|
try {
|
|
60
60
|
await handle.read(header, 0, 32, 0);
|
|
61
61
|
}
|
package/dist/src/llvm.js
CHANGED
|
@@ -62,7 +62,7 @@ export function llvmCommands(workspace) {
|
|
|
62
62
|
const operation = (name, options = []) => command(name + ' [input]', 'Native ' + name + ' through pinned LLVM utilities', async ({ args, options: o }, c) => {
|
|
63
63
|
if (Boolean(args.input) === Boolean(o.target))
|
|
64
64
|
fail('invalid', 'Supply exactly one input path or --target.');
|
|
65
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), input = await w.artifacts.verify(target.input);
|
|
65
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), input = await w.artifacts.verify(target.input);
|
|
66
66
|
const kind = await format(input), timeoutMs = number(o.timeoutSeconds, 600, 1) * 1000, limit = number(o.limit, 400, 1), offset = number(o.offset, 10000000, 0);
|
|
67
67
|
const calls = [];
|
|
68
68
|
if (name === 'headers' || name === 'sections')
|
package/dist/src/managed-heap.js
CHANGED
|
@@ -25,7 +25,7 @@ export function managedHeapCommand(workspace, installer) {
|
|
|
25
25
|
if (o.thread !== undefined && view !== 'stacks')
|
|
26
26
|
fail('invalid', '--thread selects an OS thread in stacks view.');
|
|
27
27
|
const limit = number(o.limit ?? 50, 500, 1), offset = number(o.offset ?? 0, 1000000), maxObjects = number(o.maxObjects ?? 1000000, 1000000, 1), runtime = number(o.runtimeIndex ?? 0, 15);
|
|
28
|
-
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target)), input = await w.artifacts.verify(target.input);
|
|
28
|
+
const w = workspace(c), target = args.input ? await w.importTarget(resolve(c.cwd, text(args.input, 4096))) : w.target(id(o.target, '--target')), input = await w.artifacts.verify(target.input);
|
|
29
29
|
if (target.input.size > 4 * 1024 ** 3)
|
|
30
30
|
fail('limit', 'Dump input exceeds four GiB.');
|
|
31
31
|
return installer(c).use(async (selected) => {
|
|
@@ -13,7 +13,7 @@ const helper = fileURLToPath(new URL('../../runtime/managed/insight-managed/Insi
|
|
|
13
13
|
export function metadataToken(value) { const token = text(value, 16); if (!/^0x06[0-9a-fA-F]{6}$/.test(token) || Number(token) === 0x06000000)
|
|
14
14
|
fail('invalid', 'Select a nonzero MethodDef token (0x060000NN) from this exact managed target.'); return Number(token); }
|
|
15
15
|
async function input(c, w, path, target) { if (Boolean(path) === Boolean(target))
|
|
16
|
-
fail('invalid', 'Supply one managed input path or --target.'); const value = path ? await w.importTarget(resolve(c.cwd, text(path, 4096))) : w.target(id(target)); if (value.input.size > 64 * 1024 ** 2)
|
|
16
|
+
fail('invalid', 'Supply one managed input path or --target.'); const value = path ? await w.importTarget(resolve(c.cwd, text(path, 4096))) : w.target(id(target, '--target')); if (value.input.size > 64 * 1024 ** 2)
|
|
17
17
|
fail('limit', 'Static managed input exceeds 64 MiB.'); return { path: await w.artifacts.verify(value.input), target: value.id, sha256: value.binarySha256 }; }
|
|
18
18
|
export async function runManagedMetadata(c, selected, plan, externalHost) {
|
|
19
19
|
let launch;
|
package/dist/src/mitmproxy.js
CHANGED
|
@@ -135,7 +135,7 @@ async function captureInput(c, w, path, targetId) { if (Boolean(path) === Boolea
|
|
|
135
135
|
fail('binding', 'Empty archive changed while being captured.');
|
|
136
136
|
return { path: copy, sha256: await fileSha256(copy), target: undefined };
|
|
137
137
|
}
|
|
138
|
-
} const target = path ? await w.importTarget(resolve(c.cwd, text(path, 4096))) : w.target(id(targetId)); if (target.input.size > 64 * 1024 ** 2)
|
|
138
|
+
} const target = path ? await w.importTarget(resolve(c.cwd, text(path, 4096))) : w.target(id(targetId, '--target')); if (target.input.size > 64 * 1024 ** 2)
|
|
139
139
|
fail('limit', 'Native flow input exceeds 64 MiB.'); return { path: await w.artifacts.verify(target.input), target: target.id, sha256: target.binarySha256 }; }
|
|
140
140
|
async function ordinary(c, path, value) { const output = resolve(c.cwd, text(path, 4096)), content = JSON.stringify(value, null, 2) + '\n'; await mkdir(dirname(output), { recursive: true, mode: 0o700 }); await writeFile(output, content, { flag: 'wx', mode: 0o600 }); return { output, bytes: Buffer.byteLength(content) }; }
|
|
141
141
|
export function mitmproxyCommands(workspace) {
|
package/dist/src/model.d.ts
CHANGED
|
@@ -67,7 +67,12 @@ export declare const digest: (value: unknown) => string;
|
|
|
67
67
|
export declare function fail(code: string, message: string, result?: unknown): never;
|
|
68
68
|
export declare function object(value: unknown): Record<string, unknown>;
|
|
69
69
|
export declare function text(value: unknown, max?: number): string;
|
|
70
|
-
|
|
70
|
+
/**
|
|
71
|
+
* A validated identifier. `option` names the command-line option it came from, so a refusal says which value was
|
|
72
|
+
* wrong and shows it: a caller's script that passes the wrong variable sees what it actually sent. The value appears only
|
|
73
|
+
* in the message, which Factory redacts; the structured result names the option alone.
|
|
74
|
+
*/
|
|
75
|
+
export declare function id(value: unknown, option?: string): string;
|
|
71
76
|
export declare function version(value: unknown): number;
|
|
72
77
|
export declare function identity(value: unknown): Identity;
|
|
73
78
|
export declare function assertIdentity(actual: Identity, expected: Identity): void;
|