@eyeauras/insight-cli 0.8.4 → 0.9.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/README.md +16 -23
- package/SKILL.md +6 -44
- package/dist/src/activity-audit.d.ts +33 -46
- package/dist/src/activity-audit.js +120 -195
- package/dist/src/analysis-default.d.ts +10 -2
- package/dist/src/analysis-default.js +62 -47
- package/dist/src/analysis-storage.d.ts +13 -13
- package/dist/src/analysis-storage.js +127 -258
- package/dist/src/artifacts.d.ts +5 -1
- package/dist/src/artifacts.js +31 -46
- package/dist/src/audit-commands.d.ts +6 -1
- package/dist/src/audit-commands.js +9 -2
- package/dist/src/audit-retention.d.ts +5 -23
- package/dist/src/audit-retention.js +37 -150
- package/dist/src/binary.js +4 -13
- package/dist/src/budgets.d.ts +2 -2
- package/dist/src/budgets.js +7 -9
- package/dist/src/capture.js +17 -30
- package/dist/src/cli.d.ts +9 -4
- package/dist/src/cli.js +288 -473
- package/dist/src/code-references.d.ts +2 -13
- package/dist/src/code-references.js +7 -99
- package/dist/src/context-diagnostics.d.ts +1 -23
- package/dist/src/context-diagnostics.js +1 -83
- package/dist/src/core/coordinator.d.ts +298 -0
- package/dist/src/core/coordinator.js +591 -0
- package/dist/src/core/layout.d.ts +51 -0
- package/dist/src/core/layout.js +55 -0
- package/dist/src/core/legacy-import.d.ts +55 -0
- package/dist/src/core/legacy-import.js +193 -0
- package/dist/src/cross-results.d.ts +3 -3
- package/dist/src/cross-results.js +4 -42
- package/dist/src/cross.js +2 -3
- package/dist/src/debugger-results.d.ts +1 -6
- package/dist/src/debugger-results.js +21 -153
- package/dist/src/debugger.d.ts +21 -11
- package/dist/src/debugger.js +106 -168
- package/dist/src/decode-results.d.ts +2 -1
- package/dist/src/decode-results.js +4 -20
- package/dist/src/diagnostic-error.d.ts +1 -1
- package/dist/src/diagnostic-error.js +4 -23
- package/dist/src/die.js +1 -23
- package/dist/src/dnspy-runtime.js +5 -12
- package/dist/src/dnspy.js +13 -28
- package/dist/src/dotnet-diagnostics.js +1 -1
- package/dist/src/extensions.d.ts +2 -3
- package/dist/src/extensions.js +14 -91
- package/dist/src/frida-worker.js +0 -20
- package/dist/src/frida.js +3 -26
- package/dist/src/function-boundaries.d.ts +2 -2
- package/dist/src/function-boundaries.js +9 -61
- package/dist/src/function-entries.d.ts +2 -2
- package/dist/src/function-entries.js +6 -36
- package/dist/src/function-inspection.d.ts +2 -2
- package/dist/src/function-inspection.js +17 -33
- package/dist/src/function-results.d.ts +1 -3
- package/dist/src/function-results.js +2 -13
- package/dist/src/hub/admin.d.ts +101 -0
- package/dist/src/hub/admin.js +314 -0
- package/dist/src/hub/autostart.d.ts +111 -0
- package/dist/src/hub/autostart.js +207 -0
- package/dist/src/hub/bundle.d.ts +33 -0
- package/dist/src/hub/bundle.js +25 -0
- package/dist/src/hub/client.d.ts +90 -0
- package/dist/src/hub/client.js +256 -0
- package/dist/src/hub/commands.d.ts +13 -0
- package/dist/src/hub/commands.js +280 -0
- package/dist/src/hub/contract.d.ts +87 -0
- package/dist/src/hub/contract.js +3 -0
- package/dist/src/hub/extensions.d.ts +41 -0
- package/dist/src/hub/extensions.js +3 -0
- package/dist/src/hub/ghidra.d.ts +70 -0
- package/dist/src/hub/ghidra.js +197 -0
- package/dist/src/hub/index.d.ts +6 -0
- package/dist/src/hub/index.js +7 -0
- package/dist/src/{work/store.d.ts → hub/ledger-store.d.ts} +57 -94
- package/dist/src/hub/ledger-store.js +919 -0
- package/dist/src/hub/ledger.d.ts +4 -0
- package/dist/src/hub/ledger.js +173 -0
- package/dist/src/hub/lock.d.ts +7 -0
- package/dist/src/hub/lock.js +53 -0
- package/dist/src/hub/repository.d.ts +45 -0
- package/dist/src/hub/repository.js +130 -0
- package/dist/src/hub/server.d.ts +86 -0
- package/dist/src/hub/server.js +414 -0
- package/dist/src/hub/settings.d.ts +36 -0
- package/dist/src/hub/settings.js +112 -0
- package/dist/src/hub/storage.d.ts +13 -0
- package/dist/src/hub/storage.js +46 -0
- package/dist/src/hub/store.d.ts +75 -0
- package/dist/src/hub/store.js +188 -0
- package/dist/src/ilspy.js +1 -1
- package/dist/src/internal-timing.d.ts +2 -9
- package/dist/src/internal-timing.js +2 -95
- package/dist/src/lldb.js +3 -15
- package/dist/src/llvm.js +0 -9
- package/dist/src/managed-heap.js +3 -7
- package/dist/src/managed-metadata.js +2 -5
- package/dist/src/memory-inputs.d.ts +1 -4
- package/dist/src/memory-inputs.js +10 -40
- package/dist/src/mitmproxy.d.ts +35 -4
- package/dist/src/mitmproxy.js +59 -40
- package/dist/src/model.d.ts +0 -73
- package/dist/src/model.js +0 -45
- package/dist/src/mutations.d.ts +1 -1
- package/dist/src/mutations.js +5 -10
- package/dist/src/native/contract.d.ts +130 -0
- package/dist/src/native/ghidra.d.ts +58 -0
- package/dist/src/native/ghidra.js +77 -0
- package/dist/src/native/host.d.ts +71 -0
- package/dist/src/native/host.js +265 -0
- package/dist/src/native/index.d.ts +13 -0
- package/dist/src/native/index.js +19 -0
- package/dist/src/native/jvm.d.ts +54 -0
- package/dist/src/native/jvm.js +47 -0
- package/dist/src/native/worker.d.ts +70 -0
- package/dist/src/native/worker.js +240 -0
- package/dist/src/native-inputs.d.ts +9 -14
- package/dist/src/native-inputs.js +22 -110
- package/dist/src/native-merge-patches.d.ts +2 -2
- package/dist/src/native-merge-patches.js +14 -14
- package/dist/src/persistent-client.js +53 -25
- package/dist/src/procmon.js +17 -31
- package/dist/src/program-files.d.ts +42 -0
- package/dist/src/program-files.js +148 -0
- package/dist/src/queries.js +2 -15
- package/dist/src/query-policy.d.ts +0 -2
- package/dist/src/query-policy.js +1 -14
- package/dist/src/research.d.ts +59 -238
- package/dist/src/research.js +212 -906
- package/dist/src/runtime-identity.d.ts +8 -0
- package/dist/src/runtime-identity.js +26 -0
- package/dist/src/runtime-manager.d.ts +1 -11
- package/dist/src/runtime-manager.js +10 -145
- package/dist/src/runtime-selection.d.ts +1 -1
- package/dist/src/runtime-selection.js +5 -37
- package/dist/src/saved-materials.js +8 -51
- package/dist/src/scripts.d.ts +1 -1
- package/dist/src/scripts.js +15 -15
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk.js +8 -8
- package/dist/src/sevenzip.js +1 -3
- package/dist/src/strace.js +0 -3
- package/dist/src/string-anchors.d.ts +2 -3
- package/dist/src/string-anchors.js +8 -101
- package/dist/src/text-window.d.ts +5 -4
- package/dist/src/text-window.js +4 -4
- package/dist/src/tool-runtime/archives.d.ts +1 -1
- package/dist/src/tool-runtime/archives.js +11 -20
- package/dist/src/tool-runtime/catalog.js +2 -5
- package/dist/src/tool-runtime/commands.js +1 -3
- package/dist/src/tool-runtime/deadline.js +2 -7
- package/dist/src/tool-runtime/definition.js +1 -31
- package/dist/src/tool-runtime/identity.js +6 -87
- package/dist/src/tool-runtime/installer.d.ts +2 -6
- package/dist/src/tool-runtime/installer.js +14 -76
- package/dist/src/tool-runtime/java-arguments.js +4 -10
- package/dist/src/tool-runtime/launch-worker.js +2 -8
- package/dist/src/tool-runtime/run.d.ts +2 -0
- package/dist/src/tool-runtime/run.js +20 -8
- package/dist/src/tool-runtime/store.d.ts +3 -3
- package/dist/src/tool-runtime/store.js +21 -83
- package/dist/src/tool-runtime/supervisor.d.ts +6 -11
- package/dist/src/tool-runtime/supervisor.js +155 -214
- package/dist/src/tool-runtime/windows-helper.d.ts +5 -0
- package/dist/src/tool-runtime/windows-helper.js +13 -0
- package/dist/src/tool-runtime/windows-job.d.ts +5 -5
- package/dist/src/tool-runtime/windows-job.js +13 -31
- package/dist/src/tshark.js +14 -27
- package/dist/src/ui-results.d.ts +3 -2
- package/dist/src/ui-results.js +16 -53
- package/dist/src/ui.d.ts +12 -13
- package/dist/src/ui.js +32 -70
- package/dist/src/version-tracking.d.ts +25 -39
- package/dist/src/version-tracking.js +70 -174
- package/dist/src/windbg.d.ts +1 -1
- package/dist/src/windbg.js +2 -8
- package/dist/src/work/client.d.ts +63 -0
- package/dist/src/work/client.js +163 -0
- package/dist/src/work/commands.d.ts +3 -1
- package/dist/src/work/commands.js +158 -184
- package/dist/src/work/dashboard.d.ts +2 -2
- package/dist/src/work/dashboard.js +7 -8
- package/dist/src/work/legacy.d.ts +8 -0
- package/dist/src/work/legacy.js +70 -0
- package/dist/src/work/model.d.ts +0 -3
- package/dist/src/work/model.js +0 -10
- package/dist/src/work/timing.d.ts +3 -3
- package/dist/src/work/timing.js +21 -25
- package/dist/src/workspace.d.ts +4 -250
- package/dist/src/workspace.js +11 -699
- package/node_modules/@eyeauras/cli-factory/README.md +6 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.js +76 -28
- package/node_modules/@eyeauras/cli-factory/dist/src/cli.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/command.js +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/command.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.js +18 -6
- package/node_modules/@eyeauras/cli-factory/dist/src/errors.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts +44 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/{profile-file.js → file-publication.js} +41 -113
- package/node_modules/@eyeauras/cli-factory/dist/src/file-publication.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts +5 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.js +17 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/help.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts +9 -4
- package/node_modules/@eyeauras/cli-factory/dist/src/index.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/index.js +5 -2
- package/node_modules/@eyeauras/cli-factory/dist/src/index.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js +11 -18
- package/node_modules/@eyeauras/cli-factory/dist/src/json-rpc.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts +10 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js +69 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output-write.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts +3 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/output.js +74 -14
- package/node_modules/@eyeauras/cli-factory/dist/src/output.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts +3 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js +9 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/pagination.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js +3 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/permissions.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts +16 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.d.ts.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js +83 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/stream-result.js.map +1 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts +5 -0
- package/node_modules/@eyeauras/cli-factory/dist/src/types.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts +49 -7
- package/node_modules/@eyeauras/cli-factory/dist/src/view.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/view.js +83 -6
- package/node_modules/@eyeauras/cli-factory/dist/src/view.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory/package.json +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/cli-host.proto +19 -19
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts +7 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js +9 -4
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/build.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js +5 -4
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/host.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts +11 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.d.ts.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js +85 -57
- package/node_modules/@eyeauras/cli-factory-ipc/dist/src/package-build.js.map +1 -1
- package/node_modules/@eyeauras/cli-factory-ipc/package.json +2 -2
- package/package.json +4 -5
- package/references/native/InsightAnalyzerOptions.java +10 -0
- package/references/native/InsightAnchorScan.java +1 -11
- package/references/native/InsightCodeReferences.java +2 -3
- package/references/native/InsightCopyType.java +24 -0
- package/references/native/InsightFunctionBoundaries.java +0 -1
- package/references/native/InsightFunctionDatabases.java +20 -16
- package/references/native/InsightHelperCall.java +17 -0
- package/references/native/InsightHubServer.java +214 -0
- package/references/native/InsightNativeHost.java +112 -0
- package/references/native/InsightPlugins.java +0 -1
- package/references/native/InsightPythonWheels.java +3 -2
- package/references/native/InsightResearchQueries.java +3 -4
- package/references/native/InsightResearchView.java +4 -10
- package/references/native/InsightSdkFiles.java +7 -15
- package/references/native/InsightSdkScript.java +1 -4
- package/references/native/InsightSdkTools.java +36 -97
- package/references/native/InsightSdkTypes.java +13 -43
- package/references/native/InsightStringAnchors.java +1 -3
- package/references/native/InsightTraceState.java +13 -96
- package/references/native/InsightTraceTools.java +3 -5
- package/references/native/InsightVersionTracking.java +0 -6
- package/references/native/{HeadlessProgramMergeManager.java → InsightWcMerge.java} +17 -24
- package/references/native/InsightWcOps.java +449 -0
- package/references/native/InsightWcWorker.java +142 -0
- package/references/native/NATIVE-MERGE-NOTICE.txt +4 -8
- package/runtime/GhidraMCP-7.0.0.jar +0 -0
- package/runtime/managed/insight-heap/README.md +3 -3
- package/runtime/managed/insight-managed/README.md +3 -3
- package/runtime/native/binary/README.md +5 -4
- package/runtime/native/windows/DirectoryAlias.cs +24 -0
- package/runtime/native/windows/Insight.Windows.csproj +27 -0
- package/runtime/native/windows/Native.cs +36 -0
- package/runtime/native/windows/OwnedJob.cs +86 -0
- package/runtime/native/windows/Program.cs +50 -0
- package/runtime/native/windows/RegistryRedirect.cs +42 -0
- package/runtime/native/windows/insight-windows-x64.exe +0 -0
- package/runtime/native/windows/packages.lock.json +35 -0
- package/runtime/native/windows/provenance.json +17 -0
- package/runtime/research-view.provenance.json +6 -7
- package/runtime/toolbox.json +33 -114
- package/skill-bundle/insight-artifacts/SKILL.md +5 -19
- package/skill-bundle/insight-binary/SKILL.md +5 -35
- package/skill-bundle/insight-capture/SKILL.md +5 -45
- package/skill-bundle/insight-cli/SKILL.md +6 -44
- package/skill-bundle/insight-die/SKILL.md +5 -38
- package/skill-bundle/insight-dnspy/SKILL.md +5 -54
- package/skill-bundle/insight-dotnet-dump/SKILL.md +5 -35
- package/skill-bundle/insight-dotnet-stack/SKILL.md +5 -28
- package/skill-bundle/insight-dotnet-trace/SKILL.md +5 -34
- package/skill-bundle/insight-frida/SKILL.md +5 -56
- package/skill-bundle/insight-ghidra/SKILL.md +14 -113
- package/skill-bundle/insight-ilspy/SKILL.md +5 -34
- package/skill-bundle/insight-interop/SKILL.md +5 -43
- package/skill-bundle/insight-lldb/SKILL.md +5 -43
- package/skill-bundle/insight-llvm/SKILL.md +5 -45
- package/skill-bundle/insight-managed-heap/SKILL.md +5 -32
- package/skill-bundle/insight-managed-metadata/SKILL.md +5 -41
- package/skill-bundle/insight-mitmproxy/SKILL.md +5 -51
- package/skill-bundle/insight-overview/SKILL.md +5 -68
- package/skill-bundle/insight-procmon/SKILL.md +5 -38
- package/skill-bundle/insight-re/SKILL.md +10 -127
- package/skill-bundle/insight-sevenzip/SKILL.md +5 -31
- package/skill-bundle/insight-strace/SKILL.md +5 -35
- package/skill-bundle/insight-tshark/SKILL.md +5 -38
- package/skill-bundle/insight-windbg/SKILL.md +5 -35
- package/skill-bundle/manifest.json +1 -1
- package/skills/insight-artifacts/SKILL.md +5 -19
- package/skills/insight-binary/SKILL.md +5 -35
- package/skills/insight-capture/SKILL.md +5 -45
- package/skills/insight-die/SKILL.md +5 -38
- package/skills/insight-dnspy/SKILL.md +5 -54
- package/skills/insight-dotnet-dump/SKILL.md +5 -35
- package/skills/insight-dotnet-stack/SKILL.md +5 -28
- package/skills/insight-dotnet-trace/SKILL.md +5 -34
- package/skills/insight-frida/SKILL.md +5 -56
- package/skills/insight-ghidra/SKILL.md +14 -113
- package/skills/insight-ilspy/SKILL.md +5 -34
- package/skills/insight-interop/SKILL.md +5 -43
- package/skills/insight-lldb/SKILL.md +5 -43
- package/skills/insight-llvm/SKILL.md +5 -45
- package/skills/insight-managed-heap/SKILL.md +5 -32
- package/skills/insight-managed-metadata/SKILL.md +5 -41
- package/skills/insight-mitmproxy/SKILL.md +5 -51
- package/skills/insight-overview/SKILL.md +5 -68
- package/skills/insight-procmon/SKILL.md +5 -38
- package/skills/insight-re/SKILL.md +10 -127
- package/skills/insight-sevenzip/SKILL.md +5 -31
- package/skills/insight-strace/SKILL.md +5 -35
- package/skills/insight-tshark/SKILL.md +5 -38
- package/skills/insight-windbg/SKILL.md +5 -35
- package/dist/src/administration-results.d.ts +0 -1
- package/dist/src/administration-results.js +0 -84
- package/dist/src/administration.d.ts +0 -14
- package/dist/src/administration.js +0 -134
- package/dist/src/archive-contract.d.ts +0 -6
- package/dist/src/archive-contract.js +0 -108
- package/dist/src/archive.d.ts +0 -12
- package/dist/src/archive.js +0 -116
- package/dist/src/comment-effects.d.ts +0 -3
- package/dist/src/comment-effects.js +0 -55
- package/dist/src/context-credential.d.ts +0 -18
- package/dist/src/context-credential.js +0 -44
- package/dist/src/contexts.d.ts +0 -387
- package/dist/src/contexts.js +0 -2805
- package/dist/src/coordinator.d.ts +0 -41
- package/dist/src/coordinator.js +0 -160
- package/dist/src/cross-peer.d.ts +0 -20
- package/dist/src/cross-peer.js +0 -53
- package/dist/src/data-effects.d.ts +0 -3
- package/dist/src/data-effects.js +0 -103
- package/dist/src/debugger-caller.d.ts +0 -17
- package/dist/src/debugger-caller.js +0 -129
- package/dist/src/debugger-launch.d.ts +0 -2
- package/dist/src/debugger-launch.js +0 -17
- package/dist/src/debugger-supervisor.js +0 -179
- package/dist/src/directory-identity.d.ts +0 -6
- package/dist/src/directory-identity.js +0 -45
- package/dist/src/documentation-effects.d.ts +0 -5
- package/dist/src/documentation-effects.js +0 -56
- package/dist/src/function-effects.d.ts +0 -4
- package/dist/src/function-effects.js +0 -112
- package/dist/src/ghidra-processes.d.ts +0 -6
- package/dist/src/ghidra-processes.js +0 -138
- package/dist/src/ghidra.d.ts +0 -50
- package/dist/src/ghidra.js +0 -468
- package/dist/src/initial-model.d.ts +0 -7
- package/dist/src/initial-model.js +0 -115
- package/dist/src/initial-progress.d.ts +0 -4
- package/dist/src/initial-progress.js +0 -74
- package/dist/src/inline-script.d.ts +0 -15
- package/dist/src/inline-script.js +0 -61
- package/dist/src/legacy-migration.d.ts +0 -37
- package/dist/src/legacy-migration.js +0 -238
- package/dist/src/lifecycle.d.ts +0 -77
- package/dist/src/lifecycle.js +0 -315
- package/dist/src/merge.d.ts +0 -29
- package/dist/src/merge.js +0 -66
- package/dist/src/mutation-effects.d.ts +0 -4
- package/dist/src/mutation-effects.js +0 -321
- package/dist/src/native-queries.d.ts +0 -2
- package/dist/src/native-queries.js +0 -24
- package/dist/src/native-service.d.ts +0 -40
- package/dist/src/native-service.js +0 -406
- package/dist/src/projects.d.ts +0 -31
- package/dist/src/projects.js +0 -302
- package/dist/src/prototype-cli.d.ts +0 -8
- package/dist/src/prototype-cli.js +0 -155
- package/dist/src/query-results.d.ts +0 -2
- package/dist/src/query-results.js +0 -224
- package/dist/src/research-view.d.ts +0 -6
- package/dist/src/research-view.js +0 -9
- package/dist/src/sdk-files.d.ts +0 -29
- package/dist/src/sdk-files.js +0 -249
- package/dist/src/server.d.ts +0 -102
- package/dist/src/server.js +0 -663
- package/dist/src/storage-gc.d.ts +0 -23
- package/dist/src/storage-gc.js +0 -600
- package/dist/src/store.d.ts +0 -33
- package/dist/src/store.js +0 -178
- package/dist/src/sync-policy.d.ts +0 -22
- package/dist/src/sync-policy.js +0 -129
- package/dist/src/timed-backend.d.ts +0 -3
- package/dist/src/timed-backend.js +0 -24
- package/dist/src/timing-report.d.ts +0 -32
- package/dist/src/timing-report.js +0 -74
- package/dist/src/tool-runtime/native-process-proof.d.ts +0 -2
- package/dist/src/tool-runtime/native-process-proof.js +0 -26
- package/dist/src/transport.d.ts +0 -60
- package/dist/src/transport.js +0 -223
- package/dist/src/unresolved-guidance.d.ts +0 -46
- package/dist/src/unresolved-guidance.js +0 -55
- package/dist/src/work/backup.d.ts +0 -66
- package/dist/src/work/backup.js +0 -446
- package/dist/src/work/store.js +0 -1107
- package/dist/src/worker-lease.d.ts +0 -17
- package/dist/src/worker-lease.js +0 -50
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts +0 -37
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.d.ts.map +0 -1
- package/node_modules/@eyeauras/cli-factory/dist/src/profile-file.js.map +0 -1
- package/references/InsightRepositoryProbe.java +0 -55
- package/references/administration.md +0 -34
- package/references/agent-execution.md +0 -36
- package/references/agent-setup.md +0 -60
- package/references/archive.md +0 -32
- package/references/artifacts.md +0 -52
- package/references/debugger.md +0 -64
- package/references/extensions-and-sync.md +0 -125
- package/references/ilspy.md +0 -33
- package/references/managed-runtime.md +0 -162
- package/references/native/InsightArchivePayloads.java +0 -36
- package/references/native/InsightBlockTransfer.java +0 -57
- package/references/native/InsightGuiMain.java +0 -33
- package/references/native/InsightHeadlessMain.java +0 -18
- package/references/native/InsightImportProgress.java +0 -60
- package/references/native/InsightInitialImport.java +0 -48
- package/references/native/InsightInitialJournal.java +0 -57
- package/references/native/InsightInitialPublication.java +0 -142
- package/references/native/InsightInitialRecovery.java +0 -131
- package/references/native/InsightInlineExecutor.java +0 -143
- package/references/native/InsightInlineScript.java +0 -14
- package/references/native/InsightNativeCheckout.java +0 -487
- package/references/native/InsightNativeFingerprint.java +0 -80
- package/references/native/InsightNativeMigration.java +0 -155
- package/references/native/InsightNativeRead.java +0 -80
- package/references/native/InsightNativeReceipt.java +0 -31
- package/references/native/InsightNativeService.java +0 -43
- package/references/native/InsightNativeView.java +0 -40
- package/references/native/InsightOfflineAuthenticator.java +0 -20
- package/references/native/InsightOwnedScripts.java +0 -170
- package/references/native/InsightProjectFiles.java +0 -92
- package/references/native/InsightPublicationRecovery.java +0 -63
- package/references/native/InsightServerAdministration.java +0 -82
- package/references/native/InsightServerInit.java +0 -62
- package/references/native/InsightServerMain.java +0 -43
- package/references/native/InsightServerProbe.java +0 -29
- package/references/native/InsightSnapshotFields.java +0 -74
- package/references/native/InsightSnapshotInspect.java +0 -191
- package/references/native/InsightSnapshotPublisher.java +0 -123
- package/references/native/InsightStopDebugger.java +0 -20
- package/references/native/InsightTraceInspect.java +0 -24
- package/references/native/InsightWorkerLease.java +0 -132
- package/references/native-workflows.md +0 -124
- package/references/persistent-client.mjs +0 -147
- package/references/persistent.md +0 -90
- package/references/query-semantics.md +0 -109
- package/references/recovery.md +0 -235
- package/references/research.md +0 -296
- package/references/setup.md +0 -135
- package/references/sparse-navigation.md +0 -173
- package/references/storage.md +0 -139
- package/references/work-tracking.md +0 -261
- package/runtime/native/file-version.ps1 +0 -7
- package/runtime/native/mitmproxy/bridge.py +0 -180
- package/runtime/native/windows-job/DirectoryAlias.cs +0 -24
- package/runtime/native/windows-job/Insight.WindowsJob.csproj +0 -1
- package/runtime/native/windows-job/Insight.WindowsJob.dll +0 -0
- package/runtime/native/windows-job/OwnedJob.cs +0 -79
- package/runtime/native/windows-job/RegistryRedirect.cs +0 -45
- package/runtime/native/windows-job/packages.lock.json +0 -21
- package/runtime/native/windows-job/provenance.json +0 -16
- package/runtime/native/windows-job/windows-job.ps1 +0 -8
- package/skill-bundle/insight-artifacts/references/agent-execution.md +0 -36
- package/skill-bundle/insight-artifacts/references/artifacts.md +0 -52
- package/skill-bundle/insight-artifacts/references/recovery.md +0 -235
- package/skill-bundle/insight-artifacts/references/storage.md +0 -139
- package/skill-bundle/insight-binary/references/agent-execution.md +0 -36
- package/skill-bundle/insight-capture/references/agent-execution.md +0 -36
- package/skill-bundle/insight-cli/references/agent-execution.md +0 -36
- package/skill-bundle/insight-cli/references/agent-setup.md +0 -60
- package/skill-bundle/insight-cli/references/archive.md +0 -32
- package/skill-bundle/insight-cli/references/managed-runtime.md +0 -162
- package/skill-bundle/insight-cli/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-cli/references/persistent.md +0 -90
- package/skill-bundle/insight-cli/references/recovery.md +0 -235
- package/skill-bundle/insight-cli/references/setup.md +0 -135
- package/skill-bundle/insight-cli/references/storage.md +0 -139
- package/skill-bundle/insight-die/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dnspy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-dump/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-stack/references/agent-execution.md +0 -36
- package/skill-bundle/insight-dotnet-trace/references/agent-execution.md +0 -36
- package/skill-bundle/insight-frida/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ghidra/references/administration.md +0 -34
- package/skill-bundle/insight-ghidra/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ghidra/references/archive.md +0 -32
- package/skill-bundle/insight-ghidra/references/artifacts.md +0 -52
- package/skill-bundle/insight-ghidra/references/debugger.md +0 -64
- package/skill-bundle/insight-ghidra/references/extensions-and-sync.md +0 -125
- package/skill-bundle/insight-ghidra/references/managed-runtime.md +0 -162
- package/skill-bundle/insight-ghidra/references/native-workflows.md +0 -124
- package/skill-bundle/insight-ghidra/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-ghidra/references/persistent.md +0 -90
- package/skill-bundle/insight-ghidra/references/query-semantics.md +0 -109
- package/skill-bundle/insight-ghidra/references/recovery.md +0 -235
- package/skill-bundle/insight-ghidra/references/research.md +0 -296
- package/skill-bundle/insight-ghidra/references/setup.md +0 -135
- package/skill-bundle/insight-ghidra/references/sparse-navigation.md +0 -173
- package/skill-bundle/insight-ghidra/references/storage.md +0 -139
- package/skill-bundle/insight-ilspy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-ilspy/references/ilspy.md +0 -33
- package/skill-bundle/insight-interop/references/agent-execution.md +0 -36
- package/skill-bundle/insight-lldb/references/agent-execution.md +0 -36
- package/skill-bundle/insight-llvm/references/agent-execution.md +0 -36
- package/skill-bundle/insight-managed-heap/references/agent-execution.md +0 -36
- package/skill-bundle/insight-managed-metadata/references/agent-execution.md +0 -36
- package/skill-bundle/insight-mitmproxy/references/agent-execution.md +0 -36
- package/skill-bundle/insight-overview/references/agent-execution.md +0 -36
- package/skill-bundle/insight-procmon/references/agent-execution.md +0 -36
- package/skill-bundle/insight-re/references/agent-execution.md +0 -36
- package/skill-bundle/insight-re/references/artifacts.md +0 -52
- package/skill-bundle/insight-re/references/persistent-client.mjs +0 -147
- package/skill-bundle/insight-re/references/persistent.md +0 -90
- package/skill-bundle/insight-re/references/recovery.md +0 -235
- package/skill-bundle/insight-re/references/storage.md +0 -139
- package/skill-bundle/insight-re/references/work-tracking.md +0 -261
- package/skill-bundle/insight-sevenzip/references/agent-execution.md +0 -36
- package/skill-bundle/insight-strace/references/agent-execution.md +0 -36
- package/skill-bundle/insight-tshark/references/agent-execution.md +0 -36
- package/skill-bundle/insight-windbg/references/agent-execution.md +0 -36
- package/skills/insight-artifacts/references/agent-execution.md +0 -36
- package/skills/insight-artifacts/references/artifacts.md +0 -52
- package/skills/insight-artifacts/references/recovery.md +0 -235
- package/skills/insight-artifacts/references/storage.md +0 -139
- package/skills/insight-binary/references/agent-execution.md +0 -36
- package/skills/insight-capture/references/agent-execution.md +0 -36
- package/skills/insight-die/references/agent-execution.md +0 -36
- package/skills/insight-dnspy/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-dump/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-stack/references/agent-execution.md +0 -36
- package/skills/insight-dotnet-trace/references/agent-execution.md +0 -36
- package/skills/insight-frida/references/agent-execution.md +0 -36
- package/skills/insight-ghidra/references/administration.md +0 -34
- package/skills/insight-ghidra/references/agent-execution.md +0 -36
- package/skills/insight-ghidra/references/archive.md +0 -32
- package/skills/insight-ghidra/references/artifacts.md +0 -52
- package/skills/insight-ghidra/references/debugger.md +0 -64
- package/skills/insight-ghidra/references/extensions-and-sync.md +0 -125
- package/skills/insight-ghidra/references/managed-runtime.md +0 -162
- package/skills/insight-ghidra/references/native-workflows.md +0 -124
- package/skills/insight-ghidra/references/persistent-client.mjs +0 -147
- package/skills/insight-ghidra/references/persistent.md +0 -90
- package/skills/insight-ghidra/references/query-semantics.md +0 -109
- package/skills/insight-ghidra/references/recovery.md +0 -235
- package/skills/insight-ghidra/references/research.md +0 -296
- package/skills/insight-ghidra/references/setup.md +0 -135
- package/skills/insight-ghidra/references/sparse-navigation.md +0 -173
- package/skills/insight-ghidra/references/storage.md +0 -139
- package/skills/insight-ilspy/references/agent-execution.md +0 -36
- package/skills/insight-ilspy/references/ilspy.md +0 -33
- package/skills/insight-interop/references/agent-execution.md +0 -36
- package/skills/insight-lldb/references/agent-execution.md +0 -36
- package/skills/insight-llvm/references/agent-execution.md +0 -36
- package/skills/insight-managed-heap/references/agent-execution.md +0 -36
- package/skills/insight-managed-metadata/references/agent-execution.md +0 -36
- package/skills/insight-mitmproxy/references/agent-execution.md +0 -36
- package/skills/insight-overview/references/agent-execution.md +0 -36
- package/skills/insight-procmon/references/agent-execution.md +0 -36
- package/skills/insight-re/references/agent-execution.md +0 -36
- package/skills/insight-re/references/artifacts.md +0 -52
- package/skills/insight-re/references/persistent-client.mjs +0 -147
- package/skills/insight-re/references/persistent.md +0 -90
- package/skills/insight-re/references/recovery.md +0 -235
- package/skills/insight-re/references/storage.md +0 -139
- package/skills/insight-re/references/work-tracking.md +0 -261
- package/skills/insight-sevenzip/references/agent-execution.md +0 -36
- package/skills/insight-strace/references/agent-execution.md +0 -36
- package/skills/insight-tshark/references/agent-execution.md +0 -36
- package/skills/insight-windbg/references/agent-execution.md +0 -36
- /package/dist/src/{debugger-supervisor.d.ts → native/contract.js} +0 -0
- /package/runtime/native/{windows-job → windows}/NuGet.Config +0 -0
package/dist/src/cli.js
CHANGED
|
@@ -4,7 +4,6 @@ import { captureCommands } from './capture.js';
|
|
|
4
4
|
import { binaryCommands } from './binary.js';
|
|
5
5
|
import { skillCommand, toolboxCommands } from './toolbox.js';
|
|
6
6
|
import { listProcesses } from './tool-runtime/supervisor.js';
|
|
7
|
-
import { migrationProcessBlockers } from './legacy-migration.js';
|
|
8
7
|
import { diagnosticsCommands } from './dotnet-diagnostics.js';
|
|
9
8
|
import { fridaCommands } from './frida.js';
|
|
10
9
|
import { mitmproxyCommands } from './mitmproxy.js';
|
|
@@ -19,237 +18,129 @@ import { llvmCommands } from './llvm.js';
|
|
|
19
18
|
import { sevenzipCommands } from './sevenzip.js';
|
|
20
19
|
import { ilspyCommands } from './ilspy.js';
|
|
21
20
|
import { toolProcessCommands } from './tool-runtime/commands.js';
|
|
22
|
-
import { ghidraProcessHooks } from './ghidra-processes.js';
|
|
23
21
|
import { withToolLock, toolProfileBusy } from './tool-runtime/store.js';
|
|
24
|
-
import { command, createCli, Permission,
|
|
22
|
+
import { command, createCli, Permission, ProfileStore } from '@eyeauras/cli-factory';
|
|
25
23
|
import { join, resolve } from 'node:path';
|
|
26
|
-
import { readFile, readdir } from 'node:fs/promises';
|
|
27
|
-
import { existsSync } from 'node:fs';
|
|
28
24
|
import { Workspace } from './workspace.js';
|
|
29
|
-
import { GhidraContexts } from './contexts.js';
|
|
30
|
-
import { nativeInputs } from './native-inputs.js';
|
|
31
25
|
import { Research, scope, address, commentKind, scalarText, number } from './research.js';
|
|
32
|
-
import { fail, id, text,
|
|
26
|
+
import { fail, id, text, object } from './model.js';
|
|
33
27
|
import { queryCommands, extendQueries } from './queries.js';
|
|
34
28
|
import { decodedInstructions } from './decode-results.js';
|
|
35
29
|
import { mutationCommands } from './mutations.js';
|
|
36
30
|
import { crossCommands } from './cross.js';
|
|
37
|
-
import { Administration, administrationCommands } from './administration.js';
|
|
38
|
-
import { Lifecycle, lifecycleCommands } from './lifecycle.js';
|
|
39
31
|
import { utilityCommands } from './utility.js';
|
|
40
|
-
import { Projects, projectCommands } from './projects.js';
|
|
41
|
-
import { UserInterface, uiCommands, pluginCommands } from './ui.js';
|
|
42
|
-
import { Debugger, debuggerCommands } from './debugger.js';
|
|
43
|
-
import { Archive, archiveCommands } from './archive.js';
|
|
44
32
|
import { blockContent } from './memory-inputs.js';
|
|
45
|
-
import { verifyMutation } from './mutation-effects.js';
|
|
46
33
|
import { sdkCommands } from './sdk.js';
|
|
47
|
-
import {
|
|
48
|
-
import { parseDomainJson } from './json.js';
|
|
49
|
-
import { VersionTracking, trackingCommands } from './version-tracking.js';
|
|
50
|
-
import { Extensions, extensionCommands, extensionState, extensionInventoryCommands, managedExtensions } from './extensions.js';
|
|
51
|
-
import { Synchronization, synchronizationCommands } from './sync-policy.js';
|
|
34
|
+
import { Extensions, extensionCommands } from './extensions.js';
|
|
52
35
|
import { artifactsCommands } from './saved-materials.js';
|
|
53
|
-
import { RuntimeManager, runtimeCommands
|
|
36
|
+
import { RuntimeManager, runtimeCommands } from './runtime-manager.js';
|
|
54
37
|
import { packageVersion } from './package-version.js';
|
|
55
|
-
import { runtimeSelection } from './runtime-selection.js';
|
|
56
38
|
import { AnalysisStorage, analysisDirectory } from './analysis-storage.js';
|
|
39
|
+
import { cacheBase } from './analysis-default.js';
|
|
57
40
|
import { codeReferenceCommands } from './code-references.js';
|
|
58
41
|
import { stringAnchorCommands } from './string-anchors.js';
|
|
59
42
|
import { contextDiagnosticCommands } from './context-diagnostics.js';
|
|
60
|
-
import { traceCommand } from './internal-timing.js';
|
|
61
|
-
import { withWorkerLeases } from './worker-lease.js';
|
|
62
43
|
import { ActivityAudit } from './audit-commands.js';
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
|
|
44
|
+
import { Coordinator } from './core/coordinator.js';
|
|
45
|
+
import { connectHub, hubCommands } from './hub/index.js';
|
|
46
|
+
import { createNativeGhidra } from './native/index.js';
|
|
47
|
+
import { OPERATION_MINUTES } from './native/host.js';
|
|
48
|
+
import { Debugger, debuggerCommands } from './debugger.js';
|
|
49
|
+
import { ProgramFiles, programFileCommands } from './program-files.js';
|
|
50
|
+
import { UserInterface, uiCommands } from './ui.js';
|
|
51
|
+
import { VersionTracking, trackingCommands } from './version-tracking.js';
|
|
52
|
+
import { parseDomainJson } from './json.js';
|
|
66
53
|
class Owner {
|
|
67
54
|
options;
|
|
68
55
|
storage;
|
|
69
56
|
profiles = new Map();
|
|
70
|
-
runtimeChanging = new Set();
|
|
71
|
-
openSequence = 0;
|
|
72
|
-
async runtime(c, action, quiescent = true) {
|
|
73
|
-
const directory = c.appArguments.AppDataDirectory;
|
|
74
|
-
if (this.runtimeChanging.has(directory))
|
|
75
|
-
fail('busy', 'Another runtime operation is in progress.');
|
|
76
|
-
const current = this.profiles.get(directory);
|
|
77
|
-
if (quiescent && current?.tasks.size)
|
|
78
|
-
fail('busy', 'Research operations are in progress; finish them before managing the runtime.');
|
|
79
|
-
this.runtimeChanging.add(directory);
|
|
80
|
-
try {
|
|
81
|
-
if (!quiescent)
|
|
82
|
-
return await action();
|
|
83
|
-
if (current)
|
|
84
|
-
await (await current.backend)?.quiesce?.();
|
|
85
|
-
const processes = await runtimeProcesses(directory);
|
|
86
|
-
if (processes.length)
|
|
87
|
-
fail('busy', 'Close Ghidra contexts and stop the owned server before changing or checking the runtime.', { processes });
|
|
88
|
-
if (current) {
|
|
89
|
-
await (await current.backend)?.dispose();
|
|
90
|
-
current.workspace.close();
|
|
91
|
-
this.profiles.delete(directory);
|
|
92
|
-
}
|
|
93
|
-
return await withToolLock(directory, 'ghidra', action, c.signal);
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
this.runtimeChanging.delete(directory);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
57
|
constructor(options) {
|
|
100
58
|
this.options = options;
|
|
101
59
|
}
|
|
102
|
-
|
|
60
|
+
/** One coordinator per profile; it keeps the profile's context workers for the life of the IPC owner. */
|
|
61
|
+
profile(c) {
|
|
103
62
|
const directory = c.appArguments.AppDataDirectory;
|
|
104
|
-
if (this.runtimeChanging.has(directory))
|
|
105
|
-
fail('busy', 'Runtime preparation is in progress.');
|
|
106
|
-
const root = analysisDirectory(c);
|
|
107
|
-
const configuration = digest({ analysisDirectory: root, runtime: runtimeSelection(directory, root), profile: Object.fromEntries(bindingFields.map(key => [key, c.profile.values[key]])), extensions: extensionState(join(root, 'workspace')).modules.filter(m => m.enabled).map(m => [m.name, m.sha256]) });
|
|
108
63
|
let profile = this.profiles.get(directory);
|
|
109
64
|
if (!profile) {
|
|
110
|
-
|
|
65
|
+
const holder = {};
|
|
66
|
+
const native = () => holder.native ??= (this.options.native ?? createNativeGhidra)(holder.context).catch(error => { holder.native = undefined; throw error; });
|
|
67
|
+
const core = new Coordinator({ hub: () => (this.options.hub ?? connectHub)(holder.context), native, analysis: analysisDirectory(c), cacheBase: cacheBase(c),
|
|
68
|
+
project: typeof c.profile.values.project === 'string' && c.profile.values.project ? c.profile.values.project : c.profile.name,
|
|
69
|
+
idleMinutes: c.profile.values.contextIdleMinutes === undefined ? 15 : number(c.profile.values.contextIdleMinutes, 1440, 1) });
|
|
70
|
+
profile = Object.assign(holder, { core, research: new Research(core), context: c });
|
|
111
71
|
this.profiles.set(directory, profile);
|
|
112
72
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const selected = profile;
|
|
116
|
-
const backend = async () => {
|
|
117
|
-
if (!selected.backend)
|
|
118
|
-
selected.backend = Promise.resolve(this.options.backend ?
|
|
119
|
-
this.options.backend(selected.workspace, c) : nativeInputs(c.profile.values, selected.workspace.directory, c).then(inputs => new GhidraContexts(selected.workspace, inputs, c)))
|
|
120
|
-
.catch(error => { selected.backend = undefined; throw error; });
|
|
121
|
-
const result = await selected.backend;
|
|
122
|
-
if (result instanceof GhidraContexts)
|
|
123
|
-
await managedExtensions(selected.workspace.directory);
|
|
124
|
-
return timedBackend(result instanceof GhidraContexts ? result.fork(c) : result);
|
|
125
|
-
};
|
|
126
|
-
const research = new Research(profile.workspace, backend, profile.tasks);
|
|
127
|
-
return { workspace: profile.workspace, research, synchronization: new Synchronization(profile.workspace, research, async () => {
|
|
128
|
-
const store = this.options.runtime?.profileStore ?? new ProfileStore({ applicationId: c.appArguments.AppName, appArguments: c.appArguments });
|
|
129
|
-
if (!(await store.getPermissions(c.profile.name))?.includes(Permission.Update))
|
|
130
|
-
throw new CliError('Automatic synchronization requires the current Factory Update permission.', { code: 'permission.denied', next: [['permissions', 'grant', 'Update']] });
|
|
131
|
-
}), administration: new Administration(profile.workspace, backend, profile.tasks), lifecycle: new Lifecycle(profile.workspace, research, backend), projects: new Projects(profile.workspace, backend, research, profile.tasks), sdkFiles: new SdkFiles(profile.workspace, research, backend), tracking: new VersionTracking(profile.workspace, research, backend, profile.tasks), ui: new UserInterface(profile.workspace, research, backend), debugger: new Debugger(profile.workspace, research, backend), archive: new Archive(profile.workspace, research, backend, c), backend };
|
|
132
|
-
}
|
|
133
|
-
async openCommand(c, action) {
|
|
134
|
-
const selected = this.selected(c), tasks = this.profiles.get(c.appArguments.AppDataDirectory).tasks;
|
|
135
|
-
// Register before the first await, including import before a context/task exists.
|
|
136
|
-
const key = 'open-command:' + ++this.openSequence, task = Promise.resolve().then(() => action(selected));
|
|
137
|
-
tasks.set(key, task);
|
|
138
|
-
try {
|
|
139
|
-
return await task;
|
|
140
|
-
}
|
|
141
|
-
finally {
|
|
142
|
-
tasks.delete(key);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
migrate(c, target, dryRun) {
|
|
146
|
-
return this.maintain(c, 'migration', dryRun, async (backend) => {
|
|
147
|
-
if (!backend.migrate)
|
|
148
|
-
fail('unsupported', 'The selected backend cannot migrate native Ghidra models.');
|
|
149
|
-
return backend.migrate(target, dryRun);
|
|
150
|
-
});
|
|
73
|
+
profile.context = c;
|
|
74
|
+
return profile;
|
|
151
75
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
async
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
const selected = this.selected(c), profile = this.profiles.get(c.appArguments.AppDataDirectory);
|
|
167
|
-
if (profile.tasks.size)
|
|
168
|
-
fail('busy', 'Finish research operations before ' + name + '.');
|
|
169
|
-
this.runtimeChanging.add(c.appArguments.AppDataDirectory);
|
|
170
|
-
try {
|
|
171
|
-
// Idle services and idle warm workers hold saved work only; held ones keep the refusal below.
|
|
172
|
-
await (await selected.backend()).quiesce?.();
|
|
173
|
-
// A missing private-worker receipt does not prove an interrupted native helper stopped.
|
|
174
|
-
const helpers = await migrationProcessBlockers(c.appArguments.AppDataDirectory);
|
|
175
|
-
const workers = (await runtimeProcesses(analysisDirectory(c), c.appArguments.AppDataDirectory)).filter(p => p.kind !== 'server');
|
|
176
|
-
if (helpers.length || workers.length)
|
|
177
|
-
fail('busy', 'Stop or reconcile retained Ghidra workers and native helpers before ' + name + '; no takeover is performed.', { helpers, workers });
|
|
178
|
-
return await action(await selected.backend());
|
|
179
|
-
}
|
|
180
|
-
finally {
|
|
181
|
-
this.runtimeChanging.delete(c.appArguments.AppDataDirectory);
|
|
76
|
+
core(c) { return this.profile(c).core; }
|
|
77
|
+
research(c) { return this.profile(c).research; }
|
|
78
|
+
files(c) { return new ProgramFiles(this.core(c)); }
|
|
79
|
+
ui(c) { return new UserInterface(this.core(c)); }
|
|
80
|
+
tracking(c) { return new VersionTracking(this.core(c)); }
|
|
81
|
+
debugger(c) { return new Debugger(this.core(c), c.profile.values); }
|
|
82
|
+
/** Local target and artifact store of the non-Ghidra tools and the Work ledger. */
|
|
83
|
+
workspace(c) { const profile = this.profile(c); return profile.workspace ??= new Workspace(join(analysisDirectory(c), 'workspace'), c.profile.name); }
|
|
84
|
+
async runtime(c, action, quiescent = true) {
|
|
85
|
+
if (quiescent) {
|
|
86
|
+
const open = (await this.core(c).contexts()).filter(r => r.worker === 'running');
|
|
87
|
+
if (open.length)
|
|
88
|
+
fail('busy', 'Close running Ghidra contexts before changing the runtime.', { contexts: open.map(r => ({ session: r.session, target: r.target })) });
|
|
182
89
|
}
|
|
90
|
+
const profile = this.profiles.get(c.appArguments.AppDataDirectory);
|
|
91
|
+
if (profile)
|
|
92
|
+
await this.closeNative(profile);
|
|
93
|
+
return withToolLock(c.appArguments.AppDataDirectory, 'ghidra', action, c.signal);
|
|
183
94
|
}
|
|
184
95
|
async invalidateProfile(app) {
|
|
185
96
|
const directory = app.AppDataDirectory, profile = this.profiles.get(directory);
|
|
186
97
|
if (this.storage?.busy(directory))
|
|
187
98
|
fail('busy', 'Storage migration is in progress.');
|
|
188
|
-
if (this.runtimeChanging.has(directory))
|
|
189
|
-
fail('busy', 'Runtime preparation is in progress; finish it before changing or deleting the profile.');
|
|
190
|
-
// Idle services and idle warm workers of this owner hold no work; held ones keep the refusals below.
|
|
191
|
-
if (profile && !profile.tasks.size)
|
|
192
|
-
await (await profile.backend)?.quiesce?.();
|
|
193
99
|
if (toolProfileBusy(directory))
|
|
194
100
|
fail('busy', 'A tool operation is active.');
|
|
195
|
-
if ((await listProcesses(directory
|
|
101
|
+
if ((await listProcesses(directory, { active: true })).length)
|
|
196
102
|
fail('busy', 'The profile has active or unverified tool processes.');
|
|
197
|
-
const materials = await readdir(join(directory, 'materials')).catch(error => { if (error.code === 'ENOENT')
|
|
198
|
-
return []; throw error; });
|
|
199
|
-
if (existsSync(join(directory, 'storage', 'migration.json')) || existsSync(join(directory, 'workspace', 'workspace.sqlite')) || materials.length)
|
|
200
|
-
fail('blocked', 'Profile has retained research data; preserve its workspace and materials before deleting or reconfiguring it.');
|
|
201
103
|
if (profile) {
|
|
202
|
-
await
|
|
203
|
-
|
|
104
|
+
await profile.core.dispose();
|
|
105
|
+
await this.closeNative(profile);
|
|
106
|
+
profile.workspace?.close();
|
|
204
107
|
this.profiles.delete(directory);
|
|
205
108
|
}
|
|
206
109
|
}
|
|
207
|
-
/** Idle services and idle warm workers of an otherwise idle profile owner hold no work and may stop. */
|
|
208
|
-
async quiesceProfile(c) { const profile = this.profiles.get(c.appArguments.AppDataDirectory); if (profile && !profile.tasks.size)
|
|
209
|
-
await (await profile.backend)?.quiesce?.(); }
|
|
210
110
|
async releaseStorage(c) {
|
|
211
|
-
const
|
|
111
|
+
const profile = this.profiles.get(c.appArguments.AppDataDirectory);
|
|
212
112
|
if (!profile)
|
|
213
113
|
return;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
114
|
+
await profile.core.dispose();
|
|
115
|
+
await this.closeNative(profile);
|
|
116
|
+
profile.workspace?.close();
|
|
117
|
+
this.profiles.delete(c.appArguments.AppDataDirectory);
|
|
118
|
+
}
|
|
119
|
+
/** Ends the profile's native host (its running operations finish first); the next native call starts a new one. */
|
|
120
|
+
async closeNative(profile) {
|
|
121
|
+
const pending = profile.native;
|
|
122
|
+
profile.native = undefined;
|
|
123
|
+
if (pending)
|
|
124
|
+
await pending.then(n => n.native.close?.(), () => { });
|
|
219
125
|
}
|
|
220
126
|
async dispose() {
|
|
221
127
|
for (const profile of this.profiles.values()) {
|
|
222
|
-
await Promise.allSettled([...profile.tasks.values()]);
|
|
223
128
|
try {
|
|
224
|
-
await
|
|
129
|
+
await profile.core.dispose();
|
|
130
|
+
await this.closeNative(profile);
|
|
225
131
|
}
|
|
226
132
|
finally {
|
|
227
|
-
profile.workspace
|
|
133
|
+
profile.workspace?.close();
|
|
228
134
|
}
|
|
229
135
|
}
|
|
230
136
|
this.profiles.clear();
|
|
231
137
|
}
|
|
232
138
|
}
|
|
233
139
|
const scoped = [
|
|
234
|
-
{ flags: '--session <id>', description: 'Select the
|
|
235
|
-
{ flags: '--target <id>', description: 'Select the
|
|
140
|
+
{ flags: '--session <id>', description: 'Select the research session', required: true },
|
|
141
|
+
{ flags: '--target <id>', description: 'Select the hub target', required: true },
|
|
236
142
|
];
|
|
237
143
|
const at = { flags: '--address <address>', description: 'Explicit hexadecimal address or space:address', required: true };
|
|
238
|
-
const request = { flags: '--request-id <id>', description: 'Retrieve the same changing intent after a lost response' };
|
|
239
|
-
const resolveOptions = [{ flags: '--resolve-conflict', description: 'Legacy scalar resolution only; native conflicts require Ghidra decisions' },
|
|
240
|
-
{ flags: '--expect-shared <value>', description: 'Shared value used for this resolution' },
|
|
241
|
-
{ flags: '--expect-shared-null', description: 'Expect the shared comment to be absent' }];
|
|
242
|
-
function resolution(options) {
|
|
243
|
-
const expected = options.expectShared !== undefined, absent = Boolean(options.expectSharedNull);
|
|
244
|
-
if (!options.resolveConflict) {
|
|
245
|
-
if (expected || absent)
|
|
246
|
-
fail('invalid', 'Shared expectation requires --resolve-conflict.');
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
if (expected === absent)
|
|
250
|
-
fail('invalid', 'Resolution needs exactly one --expect-shared or --expect-shared-null.');
|
|
251
|
-
return { expectedShared: absent ? null : scalarText(options.expectShared) };
|
|
252
|
-
}
|
|
253
144
|
function structureFields(value) {
|
|
254
145
|
const source = text(value, 65536);
|
|
255
146
|
let parsed;
|
|
@@ -273,22 +164,26 @@ const paged = [
|
|
|
273
164
|
{ flags: '--offset <count>', description: 'Skip items before this page', defaultValue: 0, parse: (value) => number(value, 2147483647) },
|
|
274
165
|
];
|
|
275
166
|
const fields = [
|
|
167
|
+
['project', '--project <name>', 'Project on the hub (default: the profile name)'],
|
|
276
168
|
['java', '--java <path>', 'Java 21 JDK executable'],
|
|
277
169
|
['ghidraHome', '--ghidra-home <path>', 'Ghidra 12.1.2 installation'],
|
|
278
170
|
['mcpJar', '--mcp-jar <path>', 'Optional override of the packaged verified GhidraMCP runtime'],
|
|
279
|
-
['mcpJarSha256', '--mcp-jar-sha256 <sha>', 'Expected runtime artifact digest'],
|
|
280
|
-
['server', '--server <origin>', 'External Ghidra Server origin (omit for local startup)'],
|
|
281
|
-
['repository', '--repository <name>', 'Repository on the external server'],
|
|
282
|
-
['readerUser', '--reader-user <name>', 'Read-only external account'],
|
|
283
|
-
['publisherUser', '--publisher-user <name>', 'External publication account'],
|
|
284
171
|
['initialImportSeconds', '--initial-import-seconds <seconds>', 'Initial import/analysis budget (default 3600, range 1–86400 seconds)'],
|
|
285
|
-
['
|
|
286
|
-
['
|
|
287
|
-
['
|
|
172
|
+
['operationMinutes', '--operation-minutes <minutes>', 'Time limit of one native Ghidra operation or helper (default 30, range 1–10080 minutes)'],
|
|
173
|
+
['nativeHosts', '--native-hosts <count>', 'Native Ghidra host JVMs per profile; requests go to the least busy (default 2, range 1–64)'],
|
|
174
|
+
['workerHeap', '--worker-heap <size>', 'Maximum heap of a context worker JVM (default 2g; e.g. 3072m or 8g)'],
|
|
175
|
+
['hostHeap', '--host-heap <size>', 'Maximum heap of a native host JVM (default 4g)'],
|
|
176
|
+
['contextIdleMinutes', '--context-idle-minutes <minutes>', 'Idle minutes after the last command before a context worker stops (default 15, range 1–1440)'],
|
|
288
177
|
['debuggerPython', '--debugger-python <path>', 'Optional Python executable for a configured debugger offer'],
|
|
289
178
|
['windbgDir', '--windbg-dir <path>', 'Optional Windows debugger runtime directory'],
|
|
290
|
-
['archiveUrl', '--archive-url <url>', 'Explicit archive service base URL (disabled by default)'],
|
|
291
179
|
];
|
|
180
|
+
/** Maximum of each numeric profile setting (minimum 1). */
|
|
181
|
+
const numericFields = { initialImportSeconds: 86400, operationMinutes: 10080, nativeHosts: 64, contextIdleMinutes: 1440 };
|
|
182
|
+
/** A JVM heap size as `-Xmx` takes it. */
|
|
183
|
+
const heapSize = (value) => { const size = text(value, 16).toLowerCase(); if (!/^\d+[mg]$/.test(size))
|
|
184
|
+
fail('invalid', 'A heap size is a number with m or g, e.g. 4g.'); return size; };
|
|
185
|
+
const budgetsView = (profile, values) => ({ profile, initialImportSeconds: ghidraBudget(values) / 1000,
|
|
186
|
+
operationMinutes: values.operationMinutes === undefined ? OPERATION_MINUTES : number(values.operationMinutes, 10080, 1) });
|
|
292
187
|
const mode = (value) => {
|
|
293
188
|
if (value === undefined)
|
|
294
189
|
return;
|
|
@@ -296,316 +191,236 @@ const mode = (value) => {
|
|
|
296
191
|
fail('invalid', 'Mode must be headless or gui.');
|
|
297
192
|
return value;
|
|
298
193
|
};
|
|
194
|
+
/** Explicit loader choices for the first import (`formats loaders` lists what a file supports). */
|
|
195
|
+
function loaderInputs(o) {
|
|
196
|
+
const l = {};
|
|
197
|
+
if (o.language !== undefined)
|
|
198
|
+
l.language = text(o.language, 256);
|
|
199
|
+
if (o.compilerSpec !== undefined) {
|
|
200
|
+
if (o.language === undefined)
|
|
201
|
+
fail('invalid', '--compiler-spec needs --language.');
|
|
202
|
+
l.compilerSpec = text(o.compilerSpec, 256);
|
|
203
|
+
}
|
|
204
|
+
if (o.imageBase !== undefined) {
|
|
205
|
+
const base = text(o.imageBase, 32).replace(/^0x/i, '');
|
|
206
|
+
if (!/^[a-f0-9]{1,16}$/i.test(base))
|
|
207
|
+
fail('invalid', '--image-base must be a hexadecimal address.');
|
|
208
|
+
l.imageBase = base.toLowerCase();
|
|
209
|
+
}
|
|
210
|
+
if (o.loader !== undefined)
|
|
211
|
+
l.loader = text(o.loader, 512);
|
|
212
|
+
if (o.loaderOptions !== undefined) {
|
|
213
|
+
if (o.loader === undefined)
|
|
214
|
+
fail('invalid', '--loader-options needs --loader.');
|
|
215
|
+
let value;
|
|
216
|
+
try {
|
|
217
|
+
value = parseDomainJson(text(o.loaderOptions, 16000));
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
fail('invalid', '--loader-options must be a JSON object.');
|
|
221
|
+
}
|
|
222
|
+
const options = object(value);
|
|
223
|
+
for (const [name, item] of Object.entries(options))
|
|
224
|
+
if (!['string', 'number', 'boolean'].includes(typeof item))
|
|
225
|
+
fail('invalid', 'Loader option ' + name + ' must be a string, number or boolean.');
|
|
226
|
+
l.loaderOptions = options;
|
|
227
|
+
}
|
|
228
|
+
return Object.keys(l).length ? l : undefined;
|
|
229
|
+
}
|
|
299
230
|
const targetView = (target) => ({ target: target.id, name: target.name, binarySha256: target.binarySha256, size: target.size, createdAt: target.createdAt });
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
return
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
231
|
+
/** Core context commands: open, publish, refresh, discard, close and collection on the hub. */
|
|
232
|
+
function coreCommands(owner, options) {
|
|
233
|
+
const core = (c) => owner.core(c);
|
|
234
|
+
return [
|
|
235
|
+
command('targets', 'Targets registered in this profile\'s hub project', [
|
|
236
|
+
command('list', 'List the project\'s targets', async (_input, c) => ({ items: (await core(c).targets()).map(t => ({ target: t.id, name: t.name, sha256: t.sha256, size: t.size, createdAt: t.createdAt, createdBy: t.createdBy })) }), { permission: Permission.ReadOnly }),
|
|
237
|
+
command('file', 'Download the original input of a target into the local cache (hash verified)', async ({ options: o }, c) => ({ target: id(o.target, '--target'), path: await core(c).targetFile(id(o.target, '--target')) }), { permission: Permission.Update, options: [{ flags: '--target <id>', description: 'Hub target', required: true }] }),
|
|
238
|
+
]),
|
|
239
|
+
command('open [input]', 'Open a file or a hub target in a session; the first machine imports and publishes version 1', async ({ args, options: o }, c) => {
|
|
240
|
+
if (Boolean(args.input) === Boolean(o.target))
|
|
241
|
+
fail('invalid', 'Supply exactly one input path or --target.');
|
|
242
|
+
const session = text(o.session), loader = loaderInputs(o);
|
|
243
|
+
return core(c).open({ ...(args.input ? { file: resolve(c.cwd, text(args.input, 4096)) } : { target: id(o.target, '--target') }), session: session === 'new' ? session : id(session, '--session'),
|
|
244
|
+
analysis: o.analysis === true, ...(mode(o.mode) ? { mode: mode(o.mode) } : {}), timeoutSeconds: ghidraBudget(c.profile.values) / 1000, ...(loader ? { loader } : {}) });
|
|
245
|
+
}, { permission: Permission.Update, options: [{ flags: '--session <id>', description: 'Use new for independent work, or an existing session', required: true },
|
|
246
|
+
{ flags: '--target <id>', description: 'Open a registered target instead of supplying a file' },
|
|
247
|
+
{ flags: '--mode <mode>', description: 'headless (default) or gui' },
|
|
248
|
+
{ flags: '--analysis', description: 'Run full automatic analysis when this machine imports the target first' },
|
|
249
|
+
{ flags: '--no-analysis', description: 'Skip initial automatic analysis (the default)' },
|
|
250
|
+
{ flags: '--language <id>', description: 'Loader language when this machine imports the target first (e.g. x86:LE:32:default)' },
|
|
251
|
+
{ flags: '--compiler-spec <id>', description: 'Compiler spec for --language' },
|
|
252
|
+
{ flags: '--image-base <address>', description: 'Image base applied at the first import' },
|
|
253
|
+
{ flags: '--loader <name>', description: 'Installed loader name or class from formats loaders' },
|
|
254
|
+
{ flags: '--loader-options <json>', description: 'Named primitive loader options; requires --loader' }] }),
|
|
255
|
+
command('status', 'Without selectors: Ghidra runtime readiness. With --session/--target: checkout version, latest version, modified flag and worker', ({ options: o }, c) => {
|
|
256
|
+
if (o.session === undefined && o.target === undefined)
|
|
257
|
+
return new RuntimeManager(c).status();
|
|
258
|
+
if (o.session === undefined || o.target === undefined)
|
|
259
|
+
fail('invalid', 'Supply both --session and --target, or neither for runtime status.');
|
|
260
|
+
return core(c).status(scope(o));
|
|
261
|
+
}, { permission: Permission.ReadOnly, options: scoped.map(({ required: _, ...option }) => option) }),
|
|
262
|
+
command('save', 'Save the worker\'s program into the working copy', ({ options: o }, c) => core(c).saveWorkingCopy(scope(o)), { permission: Permission.Update, options: scoped }),
|
|
263
|
+
command('save-all', 'Save every running context of a session into its working copy', ({ options: o }, c) => core(c).saveAll(id(o.session, '--session')), { permission: Permission.Update, options: [{ flags: '--session <id>', description: 'Session whose contexts are saved', required: true }] }),
|
|
264
|
+
command('diagnostics', 'Hub, native runtime and worker state', [
|
|
265
|
+
command('lifecycle', 'Hub availability, native runtime and the contexts and workers of this machine', ({ options: o }, c) => {
|
|
266
|
+
if ((o.session === undefined) !== (o.target === undefined) && o.target !== undefined)
|
|
267
|
+
fail('invalid', '--target needs --session.');
|
|
268
|
+
return core(c).diagnostics(o.session === undefined ? undefined : { session: id(o.session, '--session'), target: o.target === undefined ? '' : id(o.target, '--target') });
|
|
269
|
+
}, { permission: Permission.ReadOnly, options: scoped.map(({ required: _, ...option }) => option) }),
|
|
270
|
+
]),
|
|
271
|
+
command('merge', 'Publish the working copy with Ghidra\'s merge; an unmodified copy returns unchanged', ({ options: o }, c) => core(c).merge(scope(o), { ...(o.comment === undefined ? {} : { comment: text(o.comment, 4096) }), close: Boolean(o.close) }), { permission: Permission.Update, options: [...scoped, { flags: '--comment <text>', description: 'Check-in comment' }, { flags: '--close', description: 'Release the working copy after publishing' }] }),
|
|
272
|
+
command('refresh', 'Merge newer published versions into the working copy', ({ options: o }, c) => core(c).refresh(scope(o)), { permission: Permission.Update, options: scoped }),
|
|
273
|
+
command('changes', 'Local changes of a working copy', [
|
|
274
|
+
command('discard', 'Drop local changes and check out the latest version again', ({ options: o }, c) => core(c).discard(scope(o)), { permission: 'Destructive', options: scoped }),
|
|
275
|
+
]),
|
|
276
|
+
command('close', 'Stop the context worker; --release also ends the checkout and deletes the copy', ({ options: o }, c) => core(c).close(scope(o), { release: Boolean(o.release), force: Boolean(o.force) }), { permission: Permission.Update, options: [...scoped, { flags: '--release', description: 'End the checkout and delete the working copy' }, { flags: '--force', description: 'With --release, discard unpublished changes' }] }),
|
|
277
|
+
command('gc', 'Release unmodified copies of closed contexts and cached binaries no open context uses', ({ options: o }, c) => core(c).gc({ dryRun: Boolean(o.dryRun) }), { permission: Permission.Update, options: [{ flags: '--dry-run', description: 'Report what would be removed' }] }),
|
|
278
|
+
command('budgets', 'Inspect or configure native execution budgets', [
|
|
279
|
+
command('show', 'Read effective per-request native budgets', (_invocation, c) => budgetsView(c.profile.name, c.profile.values), { permission: Permission.ReadOnly }),
|
|
280
|
+
command('set', 'Configure subsequent native requests', async ({ options: o }, c) => {
|
|
281
|
+
if (o.initialImportSeconds === undefined && o.operationMinutes === undefined)
|
|
282
|
+
fail('invalid', 'Supply at least one native budget.');
|
|
283
|
+
const store = options.runtime?.profileStore ?? new ProfileStore({ applicationId: c.appArguments.AppName, appArguments: c.appArguments });
|
|
284
|
+
const patch = {
|
|
285
|
+
...(o.initialImportSeconds === undefined ? {} : { initialImportSeconds: number(o.initialImportSeconds, 86400, 1) }),
|
|
286
|
+
...(o.operationMinutes === undefined ? {} : { operationMinutes: number(o.operationMinutes, 10080, 1) })
|
|
352
287
|
};
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
288
|
+
const { values } = await store.set(c.profile.name, patch);
|
|
289
|
+
return { ...budgetsView(c.profile.name, values), state: 'configured', appliesTo: 'subsequent-requests' };
|
|
290
|
+
}, { permission: Permission.Update, options: [{ flags: '--initial-import-seconds <seconds>', description: 'Initial import/analysis: 1–86400 seconds' },
|
|
291
|
+
{ flags: '--operation-minutes <minutes>', description: 'One native operation or helper: 1–10080 minutes' }] })
|
|
292
|
+
]),
|
|
293
|
+
];
|
|
357
294
|
}
|
|
295
|
+
/** Hand-written research leaves; the pinned query/mutation catalogs add the rest. */
|
|
296
|
+
function researchCommands(owner) {
|
|
297
|
+
const research = (c) => owner.research(c);
|
|
298
|
+
return [
|
|
299
|
+
command('strings', 'Read defined strings', [
|
|
300
|
+
command('search', 'Find literal text in defined string data; undefined literals: analysis search-byte-patterns', ({ options: o }, c) => research(c).strings(scope(o), text(o.contains, 4096), number(o.limit, 100, 1), number(o.offset, 2147483647)), { permission: Permission.ReadOnly, options: [...scoped, { flags: '--contains <text>', description: 'Literal case-insensitive substring', required: true }, ...paged] }),
|
|
301
|
+
]),
|
|
302
|
+
command('xrefs', 'Follow cross references', [
|
|
303
|
+
command('to', 'Find incoming references and their functions', ({ options: o }, c) => research(c).xrefs(scope(o), address(o.address), number(o.limit, 100, 1), number(o.offset, 2147483647)), { permission: Permission.ReadOnly, options: [...scoped, at, ...paged] }),
|
|
304
|
+
]),
|
|
305
|
+
command('types', 'Read and edit data types', [
|
|
306
|
+
command('struct-layout', 'Read a structure layout', ({ options: o }, c) => research(c).read(scope(o), '/get_struct_layout', { struct_name: text(o.name, 512) })
|
|
307
|
+
.then(value => ({ ...scope(o), value })), { permission: Permission.ReadOnly, options: [...scoped, { flags: '--name <name>', description: 'Structure name', required: true }] }),
|
|
308
|
+
command('create-struct', 'Create a structure in the working copy', ({ options: o }, c) => {
|
|
309
|
+
const who = scope(o), name = text(o.name, 512), fields = structureFields(o.fields);
|
|
310
|
+
if (o.replacePlaceholder)
|
|
311
|
+
return research(c).mutate(who, '/sdk/type-structure', { path: name.startsWith('/') ? name : '/' + name, fields, packing: -1, alignment: 0, replace_placeholder: true });
|
|
312
|
+
return research(c).mutate(who, '/create_struct', { name, fields });
|
|
313
|
+
}, { permission: Permission.Update, options: [...scoped, { flags: '--name <name>', description: 'New structure name', required: true },
|
|
314
|
+
{ flags: '--fields <json>', description: 'Array of {name,type,offset?}', required: true }, { flags: '--replace-placeholder', description: 'Replace only an existing empty structure' }] }),
|
|
315
|
+
]),
|
|
316
|
+
command('memory', 'Read or edit memory blocks', [
|
|
317
|
+
command('list', 'Read bounded memory blocks', ({ options: o }, c) => research(c).read(scope(o), '/list_program_items', { kind: 'segments', limit: number(o.limit, 100, 1), offset: number(o.offset, 2147483647) })
|
|
318
|
+
.then(value => ({ ...scope(o), value })), { permission: Permission.ReadOnly, options: [...scoped, ...paged] }),
|
|
319
|
+
command('create-block', 'Create an initialized/uninitialized or overlay block', ({ options: o }, c) => {
|
|
320
|
+
const parameters = { name: text(o.name, 512), address: address(o.address),
|
|
321
|
+
...(o.size === undefined ? {} : { size: number(o.size, 16777216, 1) }), read: o.read !== false, write: o.write !== false, execute: Boolean(o.execute),
|
|
322
|
+
initialized: o.initialized !== false, overlay: Boolean(o.overlay), volatile: Boolean(o.volatile), comment: o.comment === undefined ? '' : text(o.comment, 16000),
|
|
323
|
+
fill_byte: o.fillByte === undefined ? 0 : number(o.fillByte, 255), ...(o.bytesHex === undefined ? {} : { bytes_hex: o.bytesHex }), ...(o.bytesBase64 === undefined ? {} : { bytes_base64: o.bytesBase64 }) };
|
|
324
|
+
parameters.size = blockContent(parameters).size;
|
|
325
|
+
return research(c).mutate(scope(o), '/create_memory_block', parameters);
|
|
326
|
+
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--name <name>', description: 'Memory block name', required: true },
|
|
327
|
+
{ flags: '--size <bytes>', description: 'Positive size up to 16 MiB; defaults to content length' },
|
|
328
|
+
{ flags: '--bytes-hex <hex>', description: 'Initial bytes in hexadecimal; remainder uses fill-byte' },
|
|
329
|
+
{ flags: '--bytes-base64 <base64>', description: 'Initial bytes as canonical padded base64' },
|
|
330
|
+
{ flags: '--fill-byte <byte>', description: 'Fill byte from 0 to 255', defaultValue: 0 },
|
|
331
|
+
{ flags: '--initialized <boolean>', description: 'false creates uninitialized memory', defaultValue: true, parse: (v) => { if (v !== 'true' && v !== 'false')
|
|
332
|
+
fail('invalid', 'initialized must be true or false.'); return v === 'true'; } },
|
|
333
|
+
{ flags: '--overlay', description: 'Create a distinct overlay address space' },
|
|
334
|
+
{ flags: '--volatile', description: 'Mark memory volatile' }, { flags: '--comment <text>', description: 'Block comment' },
|
|
335
|
+
{ flags: '--no-read', description: 'Disable read permission' }, { flags: '--no-write', description: 'Disable write permission' },
|
|
336
|
+
{ flags: '--execute', description: 'Enable execution permission' }] }),
|
|
337
|
+
]),
|
|
338
|
+
command('functions', 'Read or name functions', [
|
|
339
|
+
command('decode', 'Decode executable bytes without defining instructions or functions', async ({ options: o }, c) => {
|
|
340
|
+
const who = scope(o), at = address(o.address), maxBytes = number(o.maxBytes ?? 64, 4096, 1), maxInstructions = number(o.maxInstructions ?? 16, 256, 1);
|
|
341
|
+
return { ...who, value: decodedInstructions(await research(c).read(who, '/decode_instructions', { address: at, max_bytes: maxBytes, max_instructions: maxInstructions }), at, maxBytes, maxInstructions) };
|
|
342
|
+
}, { permission: Permission.ReadOnly, options: [...scoped, at, { flags: '--max-bytes <count>', description: 'Read 1–4096 executable bytes', defaultValue: 64 }, { flags: '--max-instructions <count>', description: 'Decode at most 1–256 instructions', defaultValue: 16 }] }),
|
|
343
|
+
command('set-function-prototype', 'Set a C prototype and optional explicit compiler-supported calling convention', ({ options: o }, c) => research(c).mutate(scope(o), '/set_function_prototype', { function_address: address(o.address), prototype: text(o.prototype, 16000),
|
|
344
|
+
...(o.callingConvention === undefined ? {} : { calling_convention: text(o.callingConvention, 512) }) }), { permission: Permission.Update, options: [...scoped, at, { flags: '--prototype <signature>', description: 'Complete C prototype', required: true },
|
|
345
|
+
{ flags: '--calling-convention <name>', description: 'Explicit convention supported by the selected compiler specification' }] }),
|
|
346
|
+
command('get', 'Read a function and entry comments', ({ options: o }, c) => research(c).function(scope(o), address(o.address)), { permission: Permission.ReadOnly, options: [...scoped, at] }),
|
|
347
|
+
command('decompile', 'Read a bounded Unicode window of one decompiled function', ({ options: o }, c) => research(c).function(scope(o), address(o.address), true, { limit: number(o.limitChars ?? 16000, 32768, 1), offset: number(o.offsetChars ?? 0, 4 * 1024 ** 2) }), { permission: Permission.ReadOnly, options: [...scoped, at, { flags: '--limit-chars <count>', description: 'Return 1–32768 Unicode characters', defaultValue: 16000 }, { flags: '--offset-chars <count>', description: 'Skip Unicode characters in the returned native text', defaultValue: 0 }] }),
|
|
348
|
+
command('rename', 'Rename a function in the working copy', ({ options: o }, c) => {
|
|
349
|
+
const name = text(o.name, 512);
|
|
350
|
+
if (name !== name.trim())
|
|
351
|
+
fail('invalid', 'Function name may not have leading or trailing whitespace.');
|
|
352
|
+
return research(c).edit(scope(o), address(o.address), 'function.name', name);
|
|
353
|
+
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--name <name>', description: 'Desired function name', required: true }] }),
|
|
354
|
+
]),
|
|
355
|
+
command('comments', 'Read or edit listing comments', [
|
|
356
|
+
command('get', 'Read one kind or all five fields', ({ options: o }, c) => research(c).comment(scope(o), address(o.address), o.kind === undefined ? undefined : commentKind(o.kind)), { permission: Permission.ReadOnly, options: [...scoped, at, { flags: '--kind <kind>', description: 'eol, pre, post, plate or repeatable' }] }),
|
|
357
|
+
command('set', 'Set a comment in the working copy or clear it', ({ options: o }, c) => {
|
|
358
|
+
if (Boolean(o.clear) === (o.text !== undefined))
|
|
359
|
+
fail('invalid', 'Supply exactly one --text or --clear.');
|
|
360
|
+
return research(c).edit(scope(o), address(o.address), `comment.${commentKind(o.kind)}`, o.clear ? null : scalarText(o.text));
|
|
361
|
+
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--kind <kind>', description: 'eol, pre, post, plate or repeatable', required: true },
|
|
362
|
+
{ flags: '--text <text>', description: 'Desired text; empty text clears to null' }, { flags: '--clear', description: 'Clear this comment to null' }] }),
|
|
363
|
+
]),
|
|
364
|
+
];
|
|
365
|
+
}
|
|
366
|
+
/** The hub command tree. Until the hub module lands its stub throws; the rest of the CLI stays usable. */
|
|
358
367
|
export function createDefinition(options = {}) {
|
|
359
|
-
const owner = new Owner(options);
|
|
360
|
-
const storage = new AnalysisStorage(options.runtime?.profileStore, c => owner.releaseStorage(c)
|
|
368
|
+
const owner = new Owner(options), audit = new ActivityAudit();
|
|
369
|
+
const storage = new AnalysisStorage(options.runtime?.profileStore, c => owner.releaseStorage(c));
|
|
361
370
|
owner.storage = storage;
|
|
371
|
+
const research = (c) => owner.research(c), workspace = (c) => owner.workspace(c);
|
|
372
|
+
const ghidra = extendQueries(extendQueries(extendQueries([...coreCommands(owner, options), ...researchCommands(owner)], queryCommands(research)), mutationCommands(research)), [...codeReferenceCommands(research), ...stringAnchorCommands(research), ...contextDiagnosticCommands(research), ...sdkCommands(research), ...crossCommands(research),
|
|
373
|
+
...extensionCommands(c => new Extensions(join(analysisDirectory(c), 'workspace'))), ...programFileCommands(c => owner.files(c)), ...uiCommands(c => owner.ui(c)), ...trackingCommands(c => owner.tracking(c)), ...debuggerCommands(c => owner.debugger(c)), ...utilityCommands(), ...runtimeCommands((c, action, quiescent) => owner.runtime(c, action, quiescent))]);
|
|
362
374
|
const definition = {
|
|
363
|
-
name: 'insight-cli', applicationId: 'insight-cli', version: packageVersion, description: '
|
|
364
|
-
resources: [owner], permissions: { categories: [{ name: 'Destructive', description: 'Explicit deletion or replacement of retained research data', enabledByDefault: false }] }, ...(options.runtime ? { runtime: options.runtime } : {}),
|
|
375
|
+
name: 'insight-cli', applicationId: 'insight-cli', version: packageVersion, description: 'Reverse-engineering toolbox with shared Ghidra analysis through a hub',
|
|
376
|
+
resources: [owner, audit], permissions: { categories: [{ name: 'Destructive', description: 'Explicit deletion or replacement of retained research data', enabledByDefault: false }] }, ...(options.runtime ? { runtime: options.runtime } : {}),
|
|
365
377
|
profile: { fields: fields.map(([name, flags, description]) => ({ name: name, flags: flags, description: description,
|
|
366
|
-
...(
|
|
367
|
-
|
|
368
|
-
loginOptions: [{ flags: '--role <role>', description: 'External reader, publisher or archive role', defaultValue: 'reader' },
|
|
369
|
-
{ flags: '--password-stdin', description: 'Read the password from stdin' }],
|
|
370
|
-
async login(c, o) {
|
|
371
|
-
const role = text(o.role);
|
|
372
|
-
if (!['reader', 'publisher', 'archive'].includes(role))
|
|
373
|
-
fail('invalid', 'Role must be reader, publisher or archive.');
|
|
374
|
-
if (role !== 'archive' && !c.profile.values.server)
|
|
375
|
-
fail('configuration', 'Local server credentials are managed automatically.');
|
|
376
|
-
if (role === 'archive' && !c.profile.values.archiveUrl)
|
|
377
|
-
fail('configuration', 'Configure an archive URL before storing its token.');
|
|
378
|
-
if (!o.passwordStdin || !c.stdinAvailable)
|
|
379
|
-
fail('credentials', 'Supply --password-stdin for this role.');
|
|
380
|
-
let candidate = '';
|
|
381
|
-
for await (const chunk of c.io.input) {
|
|
382
|
-
candidate += chunk.toString();
|
|
383
|
-
if (candidate.length > 4096)
|
|
384
|
-
fail('limit', 'Password input exceeds 4096 characters.');
|
|
385
|
-
}
|
|
386
|
-
candidate = candidate.replace(/\r?\n$/, '');
|
|
387
|
-
if (!candidate || /[\r\n\0]/.test(candidate))
|
|
388
|
-
fail('credentials', 'Password must be one nonempty line.');
|
|
389
|
-
await c.secrets.set(role === 'archive' ? 'archiveToken' : role + 'Password', candidate);
|
|
390
|
-
return { authenticated: true, identity: { role, ...(role === 'archive' ? {} : { user: c.profile.values[role + 'User'] }), validation: 'stored; authority verified at connection' } };
|
|
391
|
-
},
|
|
392
|
-
async status(c) {
|
|
393
|
-
let reader = 'readerPassword', publisher = 'publisherPassword';
|
|
394
|
-
const external = Boolean(c.profile.values.server);
|
|
395
|
-
if (!external) {
|
|
396
|
-
try {
|
|
397
|
-
const local = JSON.parse(await readFile(join(c.appArguments.AppDataDirectory, 'workspace/server/local.json'), 'utf8'));
|
|
398
|
-
reader = local.readerSecret;
|
|
399
|
-
publisher = local.publisherSecret;
|
|
400
|
-
}
|
|
401
|
-
catch (error) {
|
|
402
|
-
if (error.code !== 'ENOENT')
|
|
403
|
-
throw error;
|
|
404
|
-
return { authenticated: false, identity: { mode: 'local', validation: 'managed on first open' } };
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
const readerStored = Boolean(await c.secrets.get(reader)), publisherStored = Boolean(await c.secrets.get(publisher));
|
|
408
|
-
return { authenticated: readerStored && publisherStored, identity: { mode: external ? 'external' : 'local', readerStored, publisherStored } };
|
|
409
|
-
},
|
|
410
|
-
async logout(c) {
|
|
411
|
-
await c.secrets.delete('archiveToken');
|
|
412
|
-
if (!c.profile.values.server)
|
|
413
|
-
return;
|
|
414
|
-
await c.secrets.delete('readerPassword');
|
|
415
|
-
await c.secrets.delete('publisherPassword');
|
|
416
|
-
},
|
|
417
|
-
},
|
|
378
|
+
...(name in numericFields ? { normalize: (value) => number(value, numericFields[name], 1) } : {}),
|
|
379
|
+
...(name === 'workerHeap' || name === 'hostHeap' ? { normalize: heapSize } : {}) })) },
|
|
418
380
|
builtins: [skillCommand()],
|
|
419
381
|
commands: [
|
|
420
|
-
...workCommands((c, action) =>
|
|
382
|
+
...workCommands((c, action) => action(workspace(c)), c => (options.hub ?? connectHub)(c)),
|
|
421
383
|
...artifactsCommands(),
|
|
422
|
-
...diagnosticsCommands(
|
|
423
|
-
...llvmCommands(
|
|
424
|
-
...dieCommands(
|
|
425
|
-
...lldbCommands(
|
|
426
|
-
...windbgCommands(
|
|
384
|
+
...diagnosticsCommands(workspace),
|
|
385
|
+
...llvmCommands(workspace),
|
|
386
|
+
...dieCommands(workspace),
|
|
387
|
+
...lldbCommands(workspace),
|
|
388
|
+
...windbgCommands(workspace),
|
|
427
389
|
...procmonCommands(),
|
|
428
|
-
...dnspyCommands(
|
|
429
|
-
...tsharkCommands(
|
|
430
|
-
...mitmproxyCommands(
|
|
431
|
-
...straceCommands(
|
|
432
|
-
...fridaCommands(
|
|
433
|
-
...sevenzipCommands(
|
|
434
|
-
...ilspyCommands(
|
|
435
|
-
...binaryCommands(
|
|
436
|
-
...captureCommands(
|
|
437
|
-
...toolProcessCommands({
|
|
438
|
-
command('targets', 'Inspect
|
|
439
|
-
command('add <input>', 'Consume input without starting a tool', async ({ args }, c) => targetView(await
|
|
390
|
+
...dnspyCommands(workspace),
|
|
391
|
+
...tsharkCommands(workspace),
|
|
392
|
+
...mitmproxyCommands(workspace),
|
|
393
|
+
...straceCommands(workspace),
|
|
394
|
+
...fridaCommands(workspace),
|
|
395
|
+
...sevenzipCommands(workspace),
|
|
396
|
+
...ilspyCommands(workspace),
|
|
397
|
+
...binaryCommands(workspace),
|
|
398
|
+
...captureCommands(workspace),
|
|
399
|
+
...toolProcessCommands({}, toolboxCommands()),
|
|
400
|
+
command('targets', 'Inspect local tool inputs', [
|
|
401
|
+
command('add <input>', 'Consume input without starting a tool', async ({ args }, c) => targetView(await workspace(c).importTarget(resolve(c.cwd, text(args.input, 4096)))), { permission: Permission.Update }),
|
|
440
402
|
command('list', 'List known inputs', ({ options: o }, c) => {
|
|
441
|
-
const items =
|
|
403
|
+
const items = workspace(c).targets(number(o.limit, 100, 1), number(o.offset, 2147483647));
|
|
442
404
|
return { items: items.map(targetView), offset: o.offset, limit: o.limit, truncated: items.length === o.limit };
|
|
443
405
|
}, { permission: Permission.ReadOnly, options: paged }),
|
|
444
|
-
command('show <target>', 'Show an input identity', ({ args }, c) => targetView(
|
|
445
|
-
]),
|
|
446
|
-
command('sessions', 'Inspect durable sessions', [
|
|
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
|
-
command('status <session>', 'Inspect saved work and unresolved outcomes', ({ args, options: o }, c) => {
|
|
449
|
-
const selected = owner.selected(c), session = id(args.session, 'session');
|
|
450
|
-
selected.workspace.session(session);
|
|
451
|
-
if (o.target)
|
|
452
|
-
return selected.research.status({ session, target: id(o.target, '--target') });
|
|
453
|
-
const limit = number(o.limit, 100, 1), offset = number(o.offset, 2147483647), contexts = selected.workspace.contexts(session, limit, offset);
|
|
454
|
-
return { session, contexts: contexts.map(context => selected.research.status(context)), limit, offset, truncated: contexts.length === limit };
|
|
455
|
-
}, { permission: Permission.ReadOnly, options: [{ flags: '--target <id>', description: 'Inspect one target context' }, ...paged] }),
|
|
406
|
+
command('show <target>', 'Show an input identity', ({ args }, c) => targetView(workspace(c).target(id(args.target, 'target'))), { permission: Permission.ReadOnly }),
|
|
456
407
|
]),
|
|
457
|
-
command('
|
|
458
|
-
command('
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
command('
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}, { permission: Permission.ReadOnly, options: scoped }),
|
|
469
|
-
command('budgets', 'Inspect or configure native execution budgets', [
|
|
470
|
-
command('show', 'Read effective per-request native budgets', (_invocation, c) => ({ profile: c.profile.name, initialImportSeconds: ghidraBudget(c.profile.values, 'import') / 1000, saveSeconds: ghidraBudget(c.profile.values, 'save') / 1000 }), { permission: Permission.ReadOnly }),
|
|
471
|
-
command('set', 'Configure subsequent native requests without invalidating retained research', async ({ options: o }, c) => {
|
|
472
|
-
if (o.initialImportSeconds === undefined && o.saveSeconds === undefined)
|
|
473
|
-
fail('invalid', 'Supply at least one native budget.');
|
|
474
|
-
const store = options.runtime?.profileStore ?? new ProfileStore({ applicationId: c.appArguments.AppName, appArguments: c.appArguments });
|
|
475
|
-
const patch = {
|
|
476
|
-
...(o.initialImportSeconds === undefined ? {} : { initialImportSeconds: number(o.initialImportSeconds, 86400, 1) }),
|
|
477
|
-
...(o.saveSeconds === undefined ? {} : { saveSeconds: number(o.saveSeconds, 3600, 1) })
|
|
478
|
-
};
|
|
479
|
-
const { values } = await store.set(c.profile.name, patch);
|
|
480
|
-
return { profile: c.profile.name, state: 'configured', initialImportSeconds: ghidraBudget(values, 'import') / 1000, saveSeconds: ghidraBudget(values, 'save') / 1000, appliesTo: 'subsequent-requests' };
|
|
481
|
-
}, { permission: Permission.Update, options: [{ flags: '--initial-import-seconds <seconds>', description: 'Initial import/analysis: 1–86400 seconds' },
|
|
482
|
-
{ flags: '--save-seconds <seconds>', description: 'Native save/export: 1–3600 seconds' }] })
|
|
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, '--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
|
-
command('open [input]', 'Start independent work or continue a context', async ({ args, options: o }, c) => {
|
|
488
|
-
if (Boolean(args.input) === Boolean(o.target))
|
|
489
|
-
fail('invalid', 'Supply exactly one input path or --target.');
|
|
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, '--target');
|
|
492
|
-
let previous;
|
|
493
|
-
try {
|
|
494
|
-
previous = selected.workspace.model(target).settings;
|
|
495
|
-
}
|
|
496
|
-
catch (error) {
|
|
497
|
-
if (!String(error.code).endsWith('.notFound'))
|
|
498
|
-
throw error;
|
|
499
|
-
}
|
|
500
|
-
const settings = { ...previous, autoAnalyze: typeof o.analysis === 'boolean' ? o.analysis : previous?.autoAnalyze ?? false,
|
|
501
|
-
...(o.language ? { language: text(o.language) } : {}), ...(o.compilerSpec ? { compilerSpec: text(o.compilerSpec) } : {}),
|
|
502
|
-
...(o.imageBase ? { imageBase: text(o.imageBase) } : {}), ...(o.loader ? { loader: text(o.loader, 512) } : {}),
|
|
503
|
-
...(o.loaderOptions !== undefined ? { loaderOptions: object(parseDomainJson(text(o.loaderOptions, 16000))) } : {}) };
|
|
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));
|
|
506
|
-
});
|
|
507
|
-
}, { permission: Permission.Update, options: [{ flags: '--session <id>', description: 'Use new for independent work, or an existing session', required: true },
|
|
508
|
-
{ flags: '--target <id>', description: 'Continue existing input instead of supplying a file' }, request,
|
|
509
|
-
{ flags: '--mode <mode>', description: 'Request headless or gui; continuation preserves current mode' },
|
|
510
|
-
{ flags: '--analysis', description: 'Opt in to full initial automatic analysis (new targets only)' },
|
|
511
|
-
{ flags: '--no-analysis', description: 'Skip initial automatic analysis (the default for new targets)' },
|
|
512
|
-
{ flags: '--language <id>', description: 'Explicit initial loader language' },
|
|
513
|
-
{ flags: '--compiler-spec <id>', description: 'Explicit initial compiler specification' },
|
|
514
|
-
{ flags: '--image-base <address>', description: 'Initial image base' },
|
|
515
|
-
{ flags: '--loader <name>', description: 'Explicit installed loader name/ID from formats loaders' },
|
|
516
|
-
{ flags: '--loader-options <json>', description: 'Named primitive SDK loader options, requiring --loader' }] }),
|
|
517
|
-
command('strings', 'Read defined strings', [
|
|
518
|
-
command('search', 'Find literal text in defined string data; undefined literals: analysis search-byte-patterns', ({ options: o }, c) => owner.selected(c).research.strings(scope(o), text(o.contains, 4096), number(o.limit, 100, 1), number(o.offset, 2147483647)), { permission: Permission.ReadOnly, options: [...scoped, { flags: '--contains <text>', description: 'Literal case-insensitive substring', required: true }, ...paged] }),
|
|
519
|
-
]),
|
|
520
|
-
command('xrefs', 'Follow cross references', [
|
|
521
|
-
command('to', 'Find incoming references and their functions', ({ options: o }, c) => owner.selected(c).research.xrefs(scope(o), address(o.address), number(o.limit, 100, 1), number(o.offset, 2147483647)), { permission: Permission.ReadOnly, options: [...scoped, at, ...paged] }),
|
|
522
|
-
]),
|
|
523
|
-
command('types', 'Read and edit data types', [
|
|
524
|
-
command('struct-layout', 'Read a structure layout', ({ options: o }, c) => owner.selected(c).research.read(scope(o), '/get_struct_layout', { struct_name: text(o.name, 512) })
|
|
525
|
-
.then(value => ({ ...scope(o), value })), { permission: Permission.ReadOnly, options: [...scoped, { flags: '--name <name>', description: 'Structure name', required: true }] }),
|
|
526
|
-
command('create-struct', 'Create and save a private structure', ({ options: o }, c) => {
|
|
527
|
-
const selected = owner.selected(c), who = scope(o), name = text(o.name, 512), fields = structureFields(o.fields);
|
|
528
|
-
if (o.replacePlaceholder) {
|
|
529
|
-
const parameters = { path: name.startsWith('/') ? name : '/' + name, fields, packing: -1, alignment: 0, replace_placeholder: true };
|
|
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));
|
|
531
|
-
}
|
|
532
|
-
return selected.research.mutate(who, '/create_struct', { name, fields }, async (backend) => {
|
|
533
|
-
const result = object(await backend.call(who, '/get_struct_layout', { struct_name: name }));
|
|
534
|
-
if (result.name !== name || !Array.isArray(result.fields) || result.fields.length !== fields.length)
|
|
535
|
-
fail('partial', 'Structure readback omitted fields or changed its name.');
|
|
536
|
-
for (let i = 0; i < fields.length; i++)
|
|
537
|
-
if (object(result.fields[i]).name !== fields[i].name)
|
|
538
|
-
fail('partial', 'Structure readback changed a field name.');
|
|
539
|
-
return result;
|
|
540
|
-
}, o.requestId === undefined ? undefined : id(o.requestId, '--request-id'));
|
|
541
|
-
}, { permission: Permission.Update, options: [...scoped, { flags: '--name <name>', description: 'New structure name', required: true },
|
|
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] }),
|
|
543
|
-
]),
|
|
544
|
-
command('memory', 'Read or edit memory blocks', [
|
|
545
|
-
command('list', 'Read bounded memory blocks', ({ options: o }, c) => owner.selected(c).research.read(scope(o), '/list_program_items', { kind: 'segments', limit: number(o.limit, 100, 1), offset: number(o.offset, 2147483647) })
|
|
546
|
-
.then(value => ({ ...scope(o), value })), { permission: Permission.ReadOnly, options: [...scoped, ...paged] }),
|
|
547
|
-
command('create-block', 'Create a saved initialized/uninitialized or overlay block with verified content', ({ options: o }, c) => {
|
|
548
|
-
const selected = owner.selected(c), who = scope(o), parameters = { name: text(o.name, 512), address: address(o.address),
|
|
549
|
-
...(o.size === undefined ? {} : { size: number(o.size, 16777216, 1) }), read: o.read !== false, write: o.write !== false, execute: Boolean(o.execute),
|
|
550
|
-
initialized: o.initialized !== false, overlay: Boolean(o.overlay), volatile: Boolean(o.volatile), comment: o.comment === undefined ? '' : text(o.comment, 16000),
|
|
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 }) };
|
|
552
|
-
const expected = blockContent(parameters);
|
|
553
|
-
parameters.size = expected.size;
|
|
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));
|
|
555
|
-
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--name <name>', description: 'Memory block name', required: true },
|
|
556
|
-
{ flags: '--size <bytes>', description: 'Positive size up to 16 MiB; defaults to content length' },
|
|
557
|
-
{ flags: '--bytes-hex <hex>', description: 'Initial bytes in hexadecimal; remainder uses fill-byte' },
|
|
558
|
-
{ flags: '--bytes-base64 <base64>', description: 'Initial bytes as canonical padded base64' },
|
|
559
|
-
{ flags: '--fill-byte <byte>', description: 'Fill byte from 0 to 255', defaultValue: 0 },
|
|
560
|
-
{ flags: '--initialized <boolean>', description: 'false creates uninitialized memory', defaultValue: true, parse: (v) => { if (v !== 'true' && v !== 'false')
|
|
561
|
-
fail('invalid', 'initialized must be true or false.'); return v === 'true'; } },
|
|
562
|
-
{ flags: '--overlay', description: 'Create a distinct overlay address space' },
|
|
563
|
-
{ flags: '--volatile', description: 'Mark memory volatile' }, { flags: '--comment <text>', description: 'Block comment' },
|
|
564
|
-
{ flags: '--no-read', description: 'Disable read permission' }, { flags: '--no-write', description: 'Disable write permission' },
|
|
565
|
-
{ flags: '--execute', description: 'Enable execution permission' }, request] }),
|
|
566
|
-
]),
|
|
567
|
-
command('functions', 'Read or name functions', [
|
|
568
|
-
command('decode', 'Decode executable bytes without defining instructions or functions', async ({ options: o }, c) => {
|
|
569
|
-
const selected = owner.selected(c), who = scope(o), at = address(o.address), maxBytes = number(o.maxBytes ?? 64, 4096, 1), maxInstructions = number(o.maxInstructions ?? 16, 256, 1);
|
|
570
|
-
const value = decodedInstructions(await selected.research.read(who, '/decode_instructions', { address: at, max_bytes: maxBytes, max_instructions: maxInstructions }), at, maxBytes, maxInstructions);
|
|
571
|
-
const context = selected.workspace.context(who);
|
|
572
|
-
return { ...who, value: { ...value, view: { revision: context.baseRevision, identity: digest({ context: context.id, generation: context.generation, snapshot: context.workingSnapshot, nativeModification: object(value.read_only).modification }) } } };
|
|
573
|
-
}, { permission: Permission.ReadOnly, options: [...scoped, at, { flags: '--max-bytes <count>', description: 'Read 1–4096 executable bytes', defaultValue: 64 }, { flags: '--max-instructions <count>', description: 'Decode at most 1–256 instructions', defaultValue: 16 }] }),
|
|
574
|
-
command('set-function-prototype', 'Set a C prototype and optional explicit compiler-supported calling convention', ({ options: o }, c) => {
|
|
575
|
-
const selected = owner.selected(c), who = scope(o), parameters = { function_address: address(o.address), prototype: text(o.prototype, 16000),
|
|
576
|
-
...(o.callingConvention === undefined ? {} : { calling_convention: text(o.callingConvention, 512) }) };
|
|
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));
|
|
578
|
-
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--prototype <signature>', description: 'Complete C prototype', required: true },
|
|
579
|
-
{ flags: '--calling-convention <name>', description: 'Explicit convention supported by the selected compiler specification' }, request] }),
|
|
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] }),
|
|
581
|
-
command('decompile', 'Read a bounded Unicode window of one decompiled function', ({ options: o }, c) => owner.selected(c).research.function(scope(o), address(o.address), true, { limit: number(o.limitChars ?? 16000, 32768, 1), offset: number(o.offsetChars ?? 0, 4 * 1024 ** 2) }), { permission: Permission.ReadOnly, options: [...scoped, at, { flags: '--limit-chars <count>', description: 'Return 1–32768 Unicode characters', defaultValue: 16000 }, { flags: '--offset-chars <count>', description: 'Skip Unicode characters in the returned native text', defaultValue: 0 }] }),
|
|
582
|
-
command('rename', 'Record a saved private name', ({ options: o }, c) => {
|
|
583
|
-
const name = text(o.name, 512);
|
|
584
|
-
if (name !== name.trim())
|
|
585
|
-
fail('invalid', 'Function name may not have leading or trailing whitespace.');
|
|
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));
|
|
587
|
-
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--name <name>', description: 'Desired function name', required: true }, request, ...resolveOptions] }),
|
|
588
|
-
]),
|
|
589
|
-
command('comments', 'Read or edit listing comments', [
|
|
590
|
-
command('get', 'Read one kind or all five fields', ({ options: o }, c) => owner.selected(c).research.comment(scope(o), address(o.address), o.kind === undefined ? undefined : commentKind(o.kind)), { permission: Permission.ReadOnly, options: [...scoped, at, { flags: '--kind <kind>', description: 'eol, pre, post, plate or repeatable' }] }),
|
|
591
|
-
command('set', 'Record a saved private comment or clear it', ({ options: o }, c) => {
|
|
592
|
-
if (Boolean(o.clear) === (o.text !== undefined))
|
|
593
|
-
fail('invalid', 'Supply exactly one --text or --clear.');
|
|
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));
|
|
595
|
-
}, { permission: Permission.Update, options: [...scoped, at, { flags: '--kind <kind>', description: 'eol, pre, post, plate or repeatable', required: true },
|
|
596
|
-
{ flags: '--text <text>', description: 'Desired text; empty text clears to null' }, { flags: '--clear', description: 'Clear this comment to null' }, request, ...resolveOptions] }),
|
|
597
|
-
]),
|
|
408
|
+
command('sessions', 'Ghidra sessions on this machine', [
|
|
409
|
+
command('list', 'List sessions and their contexts', async (_input, c) => {
|
|
410
|
+
const sessions = new Map();
|
|
411
|
+
for (const r of await owner.core(c).contexts())
|
|
412
|
+
sessions.set(r.session, [...sessions.get(r.session) ?? [], r.target]);
|
|
413
|
+
return { items: [...sessions].map(([session, targets]) => ({ session, targets })) };
|
|
414
|
+
}, { permission: Permission.ReadOnly }),
|
|
415
|
+
command('status <session>', 'List the contexts of one session', async ({ args }, c) => {
|
|
416
|
+
const session = id(args.session, 'session'), contexts = await owner.core(c).contexts(session);
|
|
417
|
+
return { session, contexts: contexts.map(r => ({ target: r.target, name: r.name, sha256: r.sha256, mode: r.mode, state: r.closedAt ? 'closed' : 'open', worker: r.worker })) };
|
|
418
|
+
}, { permission: Permission.ReadOnly }),
|
|
598
419
|
]),
|
|
420
|
+
hubCommands(),
|
|
421
|
+
command('ghidra', 'Shared Ghidra analysis: one working copy per session and target', ghidra),
|
|
599
422
|
],
|
|
600
423
|
};
|
|
601
|
-
|
|
602
|
-
scopedFailures({ ...entry, children: extendQueries(extendQueries(extendQueries(entry.children ?? [], queryCommands(c => owner.selected(c).research)), mutationCommands(c => owner.selected(c).research)), [...codeReferenceCommands(c => owner.selected(c).research), ...stringAnchorCommands(c => owner.selected(c).research), ...contextDiagnosticCommands(c => owner.selected(c).research, c => owner.selected(c).workspace), ...sdkCommands(c => owner.selected(c).research), ...sdkFileCommands(c => owner.selected(c).sdkFiles), ...trackingCommands(c => owner.selected(c).tracking), ...crossCommands(c => owner.selected(c).research), ...administrationCommands(c => owner.selected(c).administration, options.backend ? undefined : async (c) => { const status = await new RuntimeManager(c).status(); return status.state === 'not_ready' ? { ...status.server, connected: false, state: 'runtime_not_ready', missing: status.missing } : undefined; }),
|
|
603
|
-
...extensionCommands(c => new Extensions(join(analysisDirectory(c), 'workspace'))), ...extensionInventoryCommands(c => owner.selected(c).backend), ...pluginCommands(c => owner.selected(c).ui), ...synchronizationCommands(c => owner.selected(c).synchronization), ...utilityCommands(), ...runtimeCommands((c, action, quiescent) => owner.runtime(c, action, quiescent)), ...lifecycleCommands(c => owner.selected(c).lifecycle, c => new RuntimeManager(c).status()), ...projectCommands(c => owner.selected(c).projects), ...uiCommands(c => owner.selected(c).ui), ...debuggerCommands(c => owner.selected(c).debugger), ...archiveCommands(c => owner.selected(c).archive)]) }, owner) : entry);
|
|
604
|
-
const audit = new ActivityAudit(), auth = definition.auth;
|
|
605
|
-
return { ...definition, auth: { ...auth,
|
|
606
|
-
login: (c, o) => audit.run(c, 'auth login', { args: {}, options: {} }, () => auth.login(c, o)),
|
|
607
|
-
status: c => audit.run(c, 'auth status', { args: {}, options: {} }, () => auth.status(c)),
|
|
608
|
-
logout: c => audit.run(c, 'auth logout', { args: {}, options: {} }, () => auth.logout(c)),
|
|
609
|
-
}, commands: [...[...(commands ?? []).map(e => storage.wrap(e)), storage.commands()].map(e => audit.wrap(e)), audit.commands()] };
|
|
424
|
+
return { ...definition, commands: [...[...(definition.commands ?? []).map(e => storage.wrap(e)), storage.commands()].map(e => audit.wrap(e)), audit.commands()] };
|
|
610
425
|
}
|
|
611
426
|
export const createInsightCli = (options = {}) => createCli(createDefinition(options));
|