@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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CheckoutStatus, LoaderInputs, NativeGhidra, NativeWorker, RepositoryRef, WorkingCopy } from './contract.js';
|
|
2
|
+
import { NativeHost } from './host.js';
|
|
3
|
+
import { versionResult, type NativeRuntime } from './jvm.js';
|
|
4
|
+
export declare function checkoutStatus(value: Record<string, unknown>): CheckoutStatus;
|
|
5
|
+
export { versionResult };
|
|
6
|
+
/** Loader choices as InsightWcOps reads them. */
|
|
7
|
+
export declare function loaderRequest(l: LoaderInputs | undefined): Record<string, unknown>;
|
|
8
|
+
export declare class JvmNativeGhidra implements NativeGhidra {
|
|
9
|
+
readonly runtime: NativeRuntime;
|
|
10
|
+
/** Imports in flight, by server, repository and program path. */
|
|
11
|
+
private readonly imports;
|
|
12
|
+
/** Runs every operation and helper of this layer: one JVM start per idle period, not per call. */
|
|
13
|
+
readonly host: NativeHost;
|
|
14
|
+
constructor(runtime: NativeRuntime, host?: NativeHost);
|
|
15
|
+
/** Stops the native host after its running operations; workers are stopped by their owner. */
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
get ghidraHome(): string;
|
|
18
|
+
get java(): string;
|
|
19
|
+
get extensionRoots(): string[];
|
|
20
|
+
helper(main: string, request: Record<string, unknown>, timeoutMs?: number): Promise<unknown>;
|
|
21
|
+
exportVersion(repository: RepositoryRef, programPath: string, version: number, output: string): Promise<{
|
|
22
|
+
version: number;
|
|
23
|
+
}>;
|
|
24
|
+
private copy;
|
|
25
|
+
exists(repository: RepositoryRef, programPath: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Imports of the same program by several agents of this layer share one import and analysis: the first caller's
|
|
28
|
+
* answer is its own, the others see the program as existing. Other machines race through the server (first writer wins).
|
|
29
|
+
*/
|
|
30
|
+
importPublish(input: {
|
|
31
|
+
repository: RepositoryRef;
|
|
32
|
+
file: string;
|
|
33
|
+
programPath: string;
|
|
34
|
+
name: string;
|
|
35
|
+
analysis: boolean;
|
|
36
|
+
timeoutSeconds?: number;
|
|
37
|
+
loader?: LoaderInputs;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
state: "published" | "exists";
|
|
40
|
+
version: number;
|
|
41
|
+
}>;
|
|
42
|
+
private importOnce;
|
|
43
|
+
checkout(repository: RepositoryRef, copy: WorkingCopy): Promise<CheckoutStatus>;
|
|
44
|
+
status(repository: RepositoryRef, copy: WorkingCopy): Promise<CheckoutStatus>;
|
|
45
|
+
startWorker(copy: WorkingCopy, mode: 'headless' | 'gui'): Promise<NativeWorker>;
|
|
46
|
+
checkin(repository: RepositoryRef, copy: WorkingCopy, comment: string): Promise<import("./contract.js").NativeConflict | {
|
|
47
|
+
state: "unchanged" | "published";
|
|
48
|
+
version: number;
|
|
49
|
+
}>;
|
|
50
|
+
update(repository: RepositoryRef, copy: WorkingCopy): Promise<import("./contract.js").NativeConflict | {
|
|
51
|
+
state: "updated" | "current";
|
|
52
|
+
version: number;
|
|
53
|
+
}>;
|
|
54
|
+
discard(repository: RepositoryRef, copy: WorkingCopy): Promise<CheckoutStatus>;
|
|
55
|
+
release(repository: RepositoryRef, copy: WorkingCopy, force: boolean): Promise<{
|
|
56
|
+
modified: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// NativeGhidra over one long-lived Ghidra JVM plus one worker JVM per open context (#161). Every answer comes from Ghidra's own state;
|
|
2
|
+
// the coordinator stops a context's worker before any step on its working copy.
|
|
3
|
+
import { rm } from 'node:fs/promises';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { NativeHost, runHelper, runOperation } from './host.js';
|
|
6
|
+
import { repositoryRequest, versionResult } from './jvm.js';
|
|
7
|
+
import { startWorker } from './worker.js';
|
|
8
|
+
export function checkoutStatus(value) {
|
|
9
|
+
return { checkedOut: value.checkedOut, version: value.version, latestVersion: value.latestVersion,
|
|
10
|
+
modified: value.modified, checkoutId: value.checkoutId };
|
|
11
|
+
}
|
|
12
|
+
export { versionResult };
|
|
13
|
+
/** Loader choices as InsightWcOps reads them. */
|
|
14
|
+
export function loaderRequest(l) {
|
|
15
|
+
if (!l)
|
|
16
|
+
return {};
|
|
17
|
+
return { ...(l.language ? { language: l.language } : {}), ...(l.compilerSpec ? { compilerSpec: l.compilerSpec } : {}), ...(l.imageBase ? { imageBase: l.imageBase } : {}),
|
|
18
|
+
...(l.loader ? { loader: l.loader } : {}), ...(l.loaderOptions ? { loaderOptions: l.loaderOptions } : {}) };
|
|
19
|
+
}
|
|
20
|
+
export class JvmNativeGhidra {
|
|
21
|
+
runtime;
|
|
22
|
+
/** Imports in flight, by server, repository and program path. */
|
|
23
|
+
imports = new Map();
|
|
24
|
+
/** Runs every operation and helper of this layer: one JVM start per idle period, not per call. */
|
|
25
|
+
host;
|
|
26
|
+
constructor(runtime, host) {
|
|
27
|
+
this.runtime = runtime;
|
|
28
|
+
this.host = host ?? new NativeHost(runtime);
|
|
29
|
+
}
|
|
30
|
+
/** Stops the native host after its running operations; workers are stopped by their owner. */
|
|
31
|
+
close() { return this.host.close(); }
|
|
32
|
+
get ghidraHome() { return this.runtime.ghidraHome; }
|
|
33
|
+
get java() { return this.runtime.java; }
|
|
34
|
+
get extensionRoots() { return this.runtime.extensionRoots ?? []; }
|
|
35
|
+
helper(main, request, timeoutMs) { return runHelper(this.host, main, request, timeoutMs); }
|
|
36
|
+
async exportVersion(repository, programPath, version, output) {
|
|
37
|
+
const result = await runOperation(this.host, this.runtime, { operation: 'export', ...repositoryRequest(repository), programPath, version, output: resolve(output) });
|
|
38
|
+
return { version: result.version };
|
|
39
|
+
}
|
|
40
|
+
copy(operation, repository, copy, extra = {}) {
|
|
41
|
+
return runOperation(this.host, this.runtime, { operation, ...repositoryRequest(repository), root: resolve(copy.root), programPath: copy.programPath, ...extra });
|
|
42
|
+
}
|
|
43
|
+
async exists(repository, programPath) {
|
|
44
|
+
return (await runOperation(this.host, this.runtime, { operation: 'exists', ...repositoryRequest(repository), programPath })).exists === true;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Imports of the same program by several agents of this layer share one import and analysis: the first caller's
|
|
48
|
+
* answer is its own, the others see the program as existing. Other machines race through the server (first writer wins).
|
|
49
|
+
*/
|
|
50
|
+
async importPublish(input) {
|
|
51
|
+
const r = input.repository, key = `${r.host}:${r.port}/${r.repository}/${input.programPath}`, running = this.imports.get(key);
|
|
52
|
+
if (running)
|
|
53
|
+
return { state: 'exists', version: (await running).version };
|
|
54
|
+
const started = this.importOnce(input).finally(() => this.imports.delete(key));
|
|
55
|
+
this.imports.set(key, started);
|
|
56
|
+
return started;
|
|
57
|
+
}
|
|
58
|
+
async importOnce(input) {
|
|
59
|
+
const timeout = input.timeoutSeconds === undefined ? undefined : Math.max(1, Math.floor(input.timeoutSeconds));
|
|
60
|
+
const result = await runOperation(this.host, this.runtime, { operation: 'import', ...repositoryRequest(input.repository), file: resolve(input.file), programPath: input.programPath,
|
|
61
|
+
name: input.name, analysis: input.analysis, ...(timeout === undefined ? {} : { timeoutSeconds: timeout }), ...loaderRequest(input.loader) }, timeout === undefined ? 6 * 3_600_000 : timeout * 1000 + this.host.operationMs);
|
|
62
|
+
return { state: result.state, version: result.version };
|
|
63
|
+
}
|
|
64
|
+
async checkout(repository, copy) { return checkoutStatus(await this.copy('checkout', repository, copy)); }
|
|
65
|
+
async status(repository, copy) { return checkoutStatus(await this.copy('status', repository, copy)); }
|
|
66
|
+
startWorker(copy, mode) { return startWorker(this.runtime, copy, mode, this.host); }
|
|
67
|
+
async checkin(repository, copy, comment) {
|
|
68
|
+
return versionResult(await this.copy('checkin', repository, copy, { comment }), ['published', 'unchanged']);
|
|
69
|
+
}
|
|
70
|
+
async update(repository, copy) { return versionResult(await this.copy('update', repository, copy), ['updated', 'current']); }
|
|
71
|
+
async discard(repository, copy) { return checkoutStatus(await this.copy('discard', repository, copy)); }
|
|
72
|
+
async release(repository, copy, force) {
|
|
73
|
+
const result = await this.copy('release', repository, copy, { force });
|
|
74
|
+
await rm(resolve(copy.root), { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
|
|
75
|
+
return { modified: result.modified === true };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type NativeRuntime } from './jvm.js';
|
|
2
|
+
/** A host stops this long after its last answer; the next request starts it again. */
|
|
3
|
+
export declare const NATIVE_HOST_IDLE_MS: number;
|
|
4
|
+
/** Hosts per native layer unless the profile says otherwise (`nativeHosts`). */
|
|
5
|
+
export declare const NATIVE_HOSTS = 2;
|
|
6
|
+
/** Time limit of one operation or helper unless the profile says otherwise (`operationMinutes`). */
|
|
7
|
+
export declare const OPERATION_MINUTES = 30;
|
|
8
|
+
/** A JVM that has not reported ready by then is stopped. */
|
|
9
|
+
export declare const JVM_START_MS: number;
|
|
10
|
+
export type HostRequest = {
|
|
11
|
+
kind: 'op';
|
|
12
|
+
request: Record<string, unknown>;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'helper';
|
|
15
|
+
main: string;
|
|
16
|
+
request: Record<string, unknown>;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'wheels';
|
|
19
|
+
args: string[];
|
|
20
|
+
};
|
|
21
|
+
/** An `{error,message}` answer as a native error; `prefix` names a helper. */
|
|
22
|
+
export declare function hostError(reply: {
|
|
23
|
+
error?: unknown;
|
|
24
|
+
message?: unknown;
|
|
25
|
+
}, prefix?: string): Error & {
|
|
26
|
+
code: string;
|
|
27
|
+
};
|
|
28
|
+
export declare class NativeHost {
|
|
29
|
+
private readonly runtime;
|
|
30
|
+
private readonly idleMs;
|
|
31
|
+
private readonly launch?;
|
|
32
|
+
private readonly size;
|
|
33
|
+
/** Hosts that take new requests. */
|
|
34
|
+
private readonly live;
|
|
35
|
+
private readonly launching;
|
|
36
|
+
private next;
|
|
37
|
+
private retiring?;
|
|
38
|
+
/** `launch` is a test seam: the command that runs the host (default: InsightNativeHost in the runtime's Java). */
|
|
39
|
+
constructor(runtime: NativeRuntime, idleMs?: number, launch?: ((temp: string) => {
|
|
40
|
+
command: string;
|
|
41
|
+
args: string[];
|
|
42
|
+
}) | undefined, size?: number);
|
|
43
|
+
/** PID of a running host, if any (diagnostics and tests). */
|
|
44
|
+
get pid(): number | undefined;
|
|
45
|
+
/** The profile's time limit of one operation or helper. */
|
|
46
|
+
get operationMs(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Sends one request to the least busy host and returns its value. A request over `timeoutMs` fails alone: a Java thread
|
|
49
|
+
* cannot be stopped safely, so its host takes no new requests and is stopped once its other requests are done.
|
|
50
|
+
*/
|
|
51
|
+
call(request: HostRequest, timeoutMs: number): Promise<unknown>;
|
|
52
|
+
/** Ends every host: running operations finish, then they exit. */
|
|
53
|
+
close(): Promise<void>;
|
|
54
|
+
/** The least busy host; while every host is busy and the pool has room another one starts for later requests. */
|
|
55
|
+
private pick;
|
|
56
|
+
/** A host being started, or a new one. */
|
|
57
|
+
private launched;
|
|
58
|
+
private start;
|
|
59
|
+
private died;
|
|
60
|
+
/** A host in doubt takes no new requests and exits once its running requests are done; they are never cut off. */
|
|
61
|
+
private retire;
|
|
62
|
+
/** A host with a request over its time limit: no new requests; stopped once its other requests are answered. */
|
|
63
|
+
private doom;
|
|
64
|
+
/** While requests are pending the host keeps the owner process alive; an idle host does not. */
|
|
65
|
+
private reference;
|
|
66
|
+
private settled;
|
|
67
|
+
}
|
|
68
|
+
/** Runs one InsightWcOps request in the host; import and export get a private scratch directory. */
|
|
69
|
+
export declare function runOperation(host: NativeHost, r: NativeRuntime, request: Record<string, unknown>, timeoutMs?: number): Promise<Record<string, unknown>>;
|
|
70
|
+
/** Runs one file-level helper (`<main>.run(request)`) in the host; returns its value. */
|
|
71
|
+
export declare function runHelper(host: NativeHost, main: string, request: Record<string, unknown>, timeoutMs?: number): Promise<unknown>;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// The long-lived Ghidra JVMs of a native layer (#161): working-copy operations and file-level helpers run here, so a
|
|
2
|
+
// command pays no JVM start. A small pool per JvmNativeGhidra; hosts start on demand and exit when idle or when their owner goes.
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { mkdir, mkdtemp, rm } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { javaClasspathArguments } from '../tool-runtime/java-arguments.js';
|
|
7
|
+
import { jvmArguments, jvmEnvironment, nativeError, Tail } from './jvm.js';
|
|
8
|
+
/** A host stops this long after its last answer; the next request starts it again. */
|
|
9
|
+
export const NATIVE_HOST_IDLE_MS = 10 * 60_000;
|
|
10
|
+
/** Hosts per native layer unless the profile says otherwise (`nativeHosts`). */
|
|
11
|
+
export const NATIVE_HOSTS = 2;
|
|
12
|
+
/** Time limit of one operation or helper unless the profile says otherwise (`operationMinutes`). */
|
|
13
|
+
export const OPERATION_MINUTES = 30;
|
|
14
|
+
/** A JVM that has not reported ready by then is stopped. */
|
|
15
|
+
export const JVM_START_MS = 15 * 60_000;
|
|
16
|
+
const codes = ['busy', 'not_found', 'modified', 'invalid', 'unavailable', 'failed'];
|
|
17
|
+
/** An `{error,message}` answer as a native error; `prefix` names a helper. */
|
|
18
|
+
export function hostError(reply, prefix = '') {
|
|
19
|
+
const code = codes.find(c => c === reply.error) ?? 'failed', message = String(reply.message ?? reply.error);
|
|
20
|
+
return nativeError(code, prefix ? prefix + ' failed: ' + message.slice(0, 1000) : message);
|
|
21
|
+
}
|
|
22
|
+
export class NativeHost {
|
|
23
|
+
runtime;
|
|
24
|
+
idleMs;
|
|
25
|
+
launch;
|
|
26
|
+
size;
|
|
27
|
+
/** Hosts that take new requests. */
|
|
28
|
+
live = new Set();
|
|
29
|
+
launching = new Set();
|
|
30
|
+
next = 1;
|
|
31
|
+
retiring;
|
|
32
|
+
/** `launch` is a test seam: the command that runs the host (default: InsightNativeHost in the runtime's Java). */
|
|
33
|
+
constructor(runtime, idleMs = NATIVE_HOST_IDLE_MS, launch, size = runtime.hosts ?? NATIVE_HOSTS) {
|
|
34
|
+
this.runtime = runtime;
|
|
35
|
+
this.idleMs = idleMs;
|
|
36
|
+
this.launch = launch;
|
|
37
|
+
this.size = size;
|
|
38
|
+
}
|
|
39
|
+
/** PID of a running host, if any (diagnostics and tests). */
|
|
40
|
+
get pid() { return [...this.live][0]?.child.pid; }
|
|
41
|
+
/** The profile's time limit of one operation or helper. */
|
|
42
|
+
get operationMs() { return (this.runtime.operationMinutes ?? OPERATION_MINUTES) * 60_000; }
|
|
43
|
+
/**
|
|
44
|
+
* Sends one request to the least busy host and returns its value. A request over `timeoutMs` fails alone: a Java thread
|
|
45
|
+
* cannot be stopped safely, so its host takes no new requests and is stopped once its other requests are done.
|
|
46
|
+
*/
|
|
47
|
+
async call(request, timeoutMs) {
|
|
48
|
+
const host = this.pick() ?? await this.launched();
|
|
49
|
+
if (host.idle) {
|
|
50
|
+
clearTimeout(host.idle);
|
|
51
|
+
host.idle = undefined;
|
|
52
|
+
}
|
|
53
|
+
const id = this.next++;
|
|
54
|
+
const answer = new Promise((resolve, reject) => {
|
|
55
|
+
const timer = setTimeout(() => {
|
|
56
|
+
const late = host.pending.get(id);
|
|
57
|
+
if (!late)
|
|
58
|
+
return;
|
|
59
|
+
host.pending.delete(id);
|
|
60
|
+
late.reject(nativeError('timeout', `The Ghidra operation exceeded ${Math.round(timeoutMs / 1000)} seconds; its native host is replaced once its other requests finish.`));
|
|
61
|
+
this.doom(host);
|
|
62
|
+
}, timeoutMs);
|
|
63
|
+
host.pending.set(id, { resolve, reject, timer });
|
|
64
|
+
});
|
|
65
|
+
this.reference(host);
|
|
66
|
+
host.child.stdin.write(JSON.stringify({ id, ...request }) + '\n');
|
|
67
|
+
return answer;
|
|
68
|
+
}
|
|
69
|
+
/** Ends every host: running operations finish, then they exit. */
|
|
70
|
+
async close() {
|
|
71
|
+
const started = await Promise.all([...this.launching].map(p => p.catch(() => undefined)));
|
|
72
|
+
const hosts = new Set([...this.live, ...started.filter((h) => h !== undefined)]);
|
|
73
|
+
for (const host of hosts) {
|
|
74
|
+
if (host.idle) {
|
|
75
|
+
clearTimeout(host.idle);
|
|
76
|
+
host.idle = undefined;
|
|
77
|
+
}
|
|
78
|
+
this.live.delete(host);
|
|
79
|
+
host.child.stdin?.end();
|
|
80
|
+
}
|
|
81
|
+
await Promise.all([...hosts].map(h => h.exited));
|
|
82
|
+
}
|
|
83
|
+
/** The least busy host; while every host is busy and the pool has room another one starts for later requests. */
|
|
84
|
+
pick() {
|
|
85
|
+
let best;
|
|
86
|
+
for (const host of this.live)
|
|
87
|
+
if (host.child.exitCode === null && host.child.signalCode === null && (!best || host.pending.size < best.pending.size))
|
|
88
|
+
best = host;
|
|
89
|
+
if (best?.pending.size && this.live.size + this.launching.size < this.size)
|
|
90
|
+
this.launched(true).catch(() => { });
|
|
91
|
+
return best;
|
|
92
|
+
}
|
|
93
|
+
/** A host being started, or a new one. */
|
|
94
|
+
launched(fresh = false) {
|
|
95
|
+
const [first] = this.launching;
|
|
96
|
+
if (first && !fresh)
|
|
97
|
+
return first;
|
|
98
|
+
const started = this.start().finally(() => this.launching.delete(started));
|
|
99
|
+
this.launching.add(started);
|
|
100
|
+
return started;
|
|
101
|
+
}
|
|
102
|
+
async start() {
|
|
103
|
+
if (this.retiring) {
|
|
104
|
+
const previous = this.retiring;
|
|
105
|
+
this.retiring = undefined;
|
|
106
|
+
await previous;
|
|
107
|
+
}
|
|
108
|
+
const r = this.runtime;
|
|
109
|
+
await mkdir(r.temp, { recursive: true });
|
|
110
|
+
const temp = await mkdtemp(join(r.temp, 'host-'));
|
|
111
|
+
let child;
|
|
112
|
+
try {
|
|
113
|
+
const { command, args } = this.launch?.(temp) ?? { command: r.java, args: await javaClasspathArguments(temp, 'ghidra', r.java, jvmArguments(r, temp, 'InsightNativeHost', { heap: r.hostHeap ?? '4g' })) };
|
|
114
|
+
child = spawn(command, args, { cwd: temp, windowsHide: true, stdio: ['pipe', 'pipe', 'pipe'], env: jvmEnvironment(temp) });
|
|
115
|
+
const proc = child, stderr = new Tail(), pending = new Map();
|
|
116
|
+
proc.stdin.on('error', () => { });
|
|
117
|
+
proc.stderr.on('data', c => stderr.push(c));
|
|
118
|
+
const exited = new Promise(resolve => proc.once('close', () => resolve()));
|
|
119
|
+
const host = { child: proc, temp, stderr, pending, exited };
|
|
120
|
+
let lines = '', ready, timer;
|
|
121
|
+
const readyLine = new Promise((resolve, reject) => {
|
|
122
|
+
ready = () => { clearTimeout(timer); resolve(); };
|
|
123
|
+
timer = setTimeout(() => reject(nativeError('timeout', `The Ghidra native host did not start in ${JVM_START_MS / 60_000} minutes.`)), JVM_START_MS);
|
|
124
|
+
void exited.then(() => { clearTimeout(timer); reject(this.died(host, 'The Ghidra native host exited during startup')); });
|
|
125
|
+
});
|
|
126
|
+
proc.stdout.on('data', (chunk) => {
|
|
127
|
+
const parts = (lines + chunk.toString()).split(/\r?\n/);
|
|
128
|
+
lines = parts.pop() ?? '';
|
|
129
|
+
for (const line of parts) {
|
|
130
|
+
if (line === 'INSIGHT_HOST_READY') {
|
|
131
|
+
ready?.();
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (!line.startsWith('INSIGHT_HOST '))
|
|
135
|
+
continue;
|
|
136
|
+
let reply;
|
|
137
|
+
try {
|
|
138
|
+
reply = JSON.parse(line.slice(13));
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const waiting = pending.get(Number(reply.id));
|
|
144
|
+
if (!waiting)
|
|
145
|
+
continue;
|
|
146
|
+
pending.delete(Number(reply.id));
|
|
147
|
+
clearTimeout(waiting.timer);
|
|
148
|
+
if (reply.error !== undefined) {
|
|
149
|
+
const error = hostError(reply);
|
|
150
|
+
if (process.env.INSIGHT_NATIVE_DEBUG)
|
|
151
|
+
error.message += '\n' + host.stderr.text.slice(-4000);
|
|
152
|
+
waiting.reject(error);
|
|
153
|
+
}
|
|
154
|
+
else
|
|
155
|
+
waiting.resolve(reply.value);
|
|
156
|
+
if (reply.recycle === true)
|
|
157
|
+
this.retire(host);
|
|
158
|
+
this.settled(host);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
void exited.then(() => {
|
|
162
|
+
this.live.delete(host);
|
|
163
|
+
if (host.idle)
|
|
164
|
+
clearTimeout(host.idle);
|
|
165
|
+
const failure = this.died(host, 'The Ghidra native host exited');
|
|
166
|
+
for (const [id, waiting] of pending) {
|
|
167
|
+
pending.delete(id);
|
|
168
|
+
clearTimeout(waiting.timer);
|
|
169
|
+
waiting.reject(failure);
|
|
170
|
+
}
|
|
171
|
+
return rm(temp, { recursive: true, force: true }).catch(() => { });
|
|
172
|
+
});
|
|
173
|
+
proc.once('error', () => { });
|
|
174
|
+
await readyLine;
|
|
175
|
+
this.live.add(host);
|
|
176
|
+
this.settled(host);
|
|
177
|
+
return host;
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
if (child && child.exitCode === null && child.signalCode === null) {
|
|
181
|
+
child.kill('SIGKILL');
|
|
182
|
+
await new Promise(r => child.once('close', r));
|
|
183
|
+
}
|
|
184
|
+
await rm(temp, { recursive: true, force: true }).catch(() => { });
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
died(host, what) {
|
|
189
|
+
const tail = host.stderr.text.split(/\r?\n/).map(l => l.trim()).filter(Boolean).slice(-6).join(' | ');
|
|
190
|
+
const error = nativeError('failed', what + (tail ? ': ' + tail.slice(-1500) : '.'));
|
|
191
|
+
if (process.env.INSIGHT_NATIVE_DEBUG)
|
|
192
|
+
error.message += '\n' + host.stderr.text.slice(-4000);
|
|
193
|
+
return error;
|
|
194
|
+
}
|
|
195
|
+
/** A host in doubt takes no new requests and exits once its running requests are done; they are never cut off. */
|
|
196
|
+
retire(host) {
|
|
197
|
+
if (!this.live.delete(host))
|
|
198
|
+
return;
|
|
199
|
+
// Its leftovers (open files of a working copy) end with its process: the next host starts after it is gone,
|
|
200
|
+
// unless it still runs other requests (those may take hours and must not hold everyone else up).
|
|
201
|
+
if (!host.pending.size)
|
|
202
|
+
this.retiring = host.exited;
|
|
203
|
+
host.child.stdin?.end();
|
|
204
|
+
}
|
|
205
|
+
/** A host with a request over its time limit: no new requests; stopped once its other requests are answered. */
|
|
206
|
+
doom(host) {
|
|
207
|
+
this.live.delete(host);
|
|
208
|
+
host.doomed = true;
|
|
209
|
+
if (!host.pending.size && host.child.exitCode === null && host.child.signalCode === null)
|
|
210
|
+
host.child.kill('SIGKILL');
|
|
211
|
+
}
|
|
212
|
+
/** While requests are pending the host keeps the owner process alive; an idle host does not. */
|
|
213
|
+
reference(host) {
|
|
214
|
+
host.child.ref();
|
|
215
|
+
for (const stream of [host.child.stdin, host.child.stdout, host.child.stderr])
|
|
216
|
+
stream?.ref?.();
|
|
217
|
+
}
|
|
218
|
+
settled(host) {
|
|
219
|
+
if (host.pending.size)
|
|
220
|
+
return;
|
|
221
|
+
if (host.doomed) {
|
|
222
|
+
this.doom(host);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
host.child.unref();
|
|
226
|
+
for (const stream of [host.child.stdin, host.child.stdout, host.child.stderr])
|
|
227
|
+
stream?.unref?.();
|
|
228
|
+
if (!this.live.has(host))
|
|
229
|
+
return;
|
|
230
|
+
if (host.idle)
|
|
231
|
+
clearTimeout(host.idle);
|
|
232
|
+
host.idle = setTimeout(() => { host.idle = undefined; if (this.live.has(host) && !host.pending.size) {
|
|
233
|
+
this.live.delete(host);
|
|
234
|
+
host.child.stdin?.end();
|
|
235
|
+
} }, this.idleMs);
|
|
236
|
+
host.idle.unref();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/** Operations that stage files (a temporary Ghidra project, the input copy) in a private scratch directory. */
|
|
240
|
+
const scratchOperations = new Set(['import', 'export']);
|
|
241
|
+
/** Runs one InsightWcOps request in the host; import and export get a private scratch directory. */
|
|
242
|
+
export async function runOperation(host, r, request, timeoutMs = host.operationMs) {
|
|
243
|
+
let temp;
|
|
244
|
+
if (scratchOperations.has(String(request.operation))) {
|
|
245
|
+
await mkdir(r.temp, { recursive: true });
|
|
246
|
+
temp = await mkdtemp(join(r.temp, 'op-'));
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
return await host.call({ kind: 'op', request: temp ? { ...request, temp } : request }, timeoutMs);
|
|
250
|
+
}
|
|
251
|
+
finally {
|
|
252
|
+
if (temp)
|
|
253
|
+
await rm(temp, { recursive: true, force: true }).catch(() => { });
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/** Runs one file-level helper (`<main>.run(request)`) in the host; returns its value. */
|
|
257
|
+
export async function runHelper(host, main, request, timeoutMs = host.operationMs) {
|
|
258
|
+
try {
|
|
259
|
+
return await host.call({ kind: 'helper', main, request }, timeoutMs);
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
error.message = main + ' failed: ' + error.message;
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommandContext } from '@eyeauras/cli-factory';
|
|
2
|
+
import { type NativeInputs } from '../native-inputs.js';
|
|
3
|
+
import type { NativeGhidra } from './contract.js';
|
|
4
|
+
import type { NativeRuntime } from './jvm.js';
|
|
5
|
+
export { JvmNativeGhidra } from './ghidra.js';
|
|
6
|
+
export type { NativeRuntime } from './jvm.js';
|
|
7
|
+
/** The runtime of resolved inputs with helper classes compiled under `directory`. */
|
|
8
|
+
export declare function nativeRuntime(inputs: NativeInputs, directory: string, temp: string, c?: CommandContext, user?: string): Promise<NativeRuntime>;
|
|
9
|
+
/** Resolves the profile's Ghidra runtime and returns the native layer bound to it. */
|
|
10
|
+
export declare function createNativeGhidra(c: CommandContext): Promise<{
|
|
11
|
+
native: NativeGhidra;
|
|
12
|
+
runtimeFingerprint: string;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { delimiter, join } from 'node:path';
|
|
2
|
+
import { analysisDirectory } from '../analysis-storage.js';
|
|
3
|
+
import { clientUserName } from '../core/layout.js';
|
|
4
|
+
import { nativeExtensionArguments, nativeHelpers, nativeInputs } from '../native-inputs.js';
|
|
5
|
+
import { JvmNativeGhidra } from './ghidra.js';
|
|
6
|
+
export { JvmNativeGhidra } from './ghidra.js';
|
|
7
|
+
/** The runtime of resolved inputs with helper classes compiled under `directory`. */
|
|
8
|
+
export async function nativeRuntime(inputs, directory, temp, c, user = clientUserName()) {
|
|
9
|
+
const classes = await nativeHelpers(directory, inputs, c), v = c?.profile.values ?? {};
|
|
10
|
+
return { java: inputs.java, ghidraHome: inputs.ghidraHome, classpath: classes + delimiter + inputs.classpath, jvm: nativeExtensionArguments(inputs), user, temp, extensionRoots: inputs.extensionRoots ?? [], debuggerWheels: inputs.debuggerWheels,
|
|
11
|
+
...(typeof v.workerHeap === 'string' ? { heap: v.workerHeap } : {}), ...(typeof v.hostHeap === 'string' ? { hostHeap: v.hostHeap } : {}),
|
|
12
|
+
...(v.nativeHosts === undefined ? {} : { hosts: Number(v.nativeHosts) }), ...(v.operationMinutes === undefined ? {} : { operationMinutes: Number(v.operationMinutes) }) };
|
|
13
|
+
}
|
|
14
|
+
/** Resolves the profile's Ghidra runtime and returns the native layer bound to it. */
|
|
15
|
+
export async function createNativeGhidra(c) {
|
|
16
|
+
const analysis = analysisDirectory(c), directory = join(analysis, 'workspace');
|
|
17
|
+
const inputs = await nativeInputs(c.profile.values, directory, c);
|
|
18
|
+
return { native: new JvmNativeGhidra(await nativeRuntime(inputs, directory, join(analysis, 'temp', 'native'), c)), runtimeFingerprint: inputs.fingerprint };
|
|
19
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { NativeConflict, RepositoryRef } from './contract.js';
|
|
2
|
+
/** A resolved Ghidra runtime. `classpath` already starts with the compiled helper classes. */
|
|
3
|
+
export interface NativeRuntime {
|
|
4
|
+
java: string;
|
|
5
|
+
ghidraHome: string;
|
|
6
|
+
classpath: string;
|
|
7
|
+
/** Extra JVM arguments of managed extensions. */
|
|
8
|
+
jvm: string[];
|
|
9
|
+
/** Client user name; every JVM runs as this Ghidra user. */
|
|
10
|
+
user: string;
|
|
11
|
+
/** Parent of per-call private JVM directories (user.home, tmpdir, Ghidra settings). */
|
|
12
|
+
temp: string;
|
|
13
|
+
/** Maximum heap of a worker JVM (`-Xmx`, default 2g) and of a native host (default 4g). */
|
|
14
|
+
heap?: string;
|
|
15
|
+
hostHeap?: string;
|
|
16
|
+
/** Native hosts of the layer (default NATIVE_HOSTS) and the time limit of one operation (default OPERATION_MINUTES). */
|
|
17
|
+
hosts?: number;
|
|
18
|
+
operationMinutes?: number;
|
|
19
|
+
/** Managed extension module roots (script inventory). */
|
|
20
|
+
extensionRoots?: string[];
|
|
21
|
+
/** Pure Python wheels of Ghidra's trace RMI agents, extracted for GUI workers (debugger). */
|
|
22
|
+
debuggerWheels?: string[];
|
|
23
|
+
}
|
|
24
|
+
export type NativeCode = 'busy' | 'not_found' | 'modified' | 'invalid' | 'unavailable' | 'failed' | 'remote' | 'timeout';
|
|
25
|
+
/** Errors carry code: 'native.<code>', as the offline fakes do (CliError codes cannot contain '_'). */
|
|
26
|
+
export declare const nativeError: (code: NativeCode, message: string) => Error & {
|
|
27
|
+
code: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function jvmArguments(r: NativeRuntime, temp: string, main: string, options?: {
|
|
30
|
+
gui?: boolean;
|
|
31
|
+
args?: string[];
|
|
32
|
+
heap?: string;
|
|
33
|
+
}): string[];
|
|
34
|
+
/** Only what a JVM needs: private home/temp directories and the platform essentials, never caller secrets. */
|
|
35
|
+
export declare function jvmEnvironment(temp: string, extra?: Record<string, string>, base?: NodeJS.ProcessEnv): Record<string, string>;
|
|
36
|
+
export declare const repositoryRequest: (r: RepositoryRef) => {
|
|
37
|
+
host: string;
|
|
38
|
+
port: number;
|
|
39
|
+
repository: string;
|
|
40
|
+
};
|
|
41
|
+
/** The last `<prefix> <json>` line; a helper's `{error,message}` becomes a native error. */
|
|
42
|
+
export declare function parseReply(stdout: string, stderr?: string, prefix?: string): Record<string, unknown>;
|
|
43
|
+
/** `_states` names the answers Ghidra gives for this operation. */
|
|
44
|
+
export declare function versionResult<S extends string>(value: Record<string, unknown>, _states: readonly S[]): {
|
|
45
|
+
state: S;
|
|
46
|
+
version: number;
|
|
47
|
+
} | NativeConflict;
|
|
48
|
+
/** Keeps the last `limit` characters of a stream. */
|
|
49
|
+
export declare class Tail {
|
|
50
|
+
private readonly limit;
|
|
51
|
+
text: string;
|
|
52
|
+
constructor(limit?: number);
|
|
53
|
+
push(chunk: Buffer | string): void;
|
|
54
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Ghidra JVMs of the native layer (#161): argument building and reply parsing.
|
|
2
|
+
import { nativeJvmDirectories } from '../native-inputs.js';
|
|
3
|
+
/** Errors carry code: 'native.<code>', as the offline fakes do (CliError codes cannot contain '_'). */
|
|
4
|
+
export const nativeError = (code, message) => Object.assign(new Error(message), { code: 'native.' + code });
|
|
5
|
+
export function jvmArguments(r, temp, main, options = {}) {
|
|
6
|
+
return ['-Xmx' + (options.heap ?? r.heap ?? '2g'), '-Djava.awt.headless=' + String(!options.gui), '-Dghidra.home=' + r.ghidraHome, '-Duser.name=' + r.user,
|
|
7
|
+
...nativeJvmDirectories(temp), ...r.jvm, '-cp', r.classpath, main, ...options.args ?? []];
|
|
8
|
+
}
|
|
9
|
+
/** Only what a JVM needs: private home/temp directories and the platform essentials, never caller secrets. */
|
|
10
|
+
export function jvmEnvironment(temp, extra = {}, base = process.env) {
|
|
11
|
+
const keep = ['PATH', 'SystemRoot', 'WINDIR', 'ComSpec', 'LANG', 'LC_ALL', 'DISPLAY', 'WAYLAND_DISPLAY', 'XAUTHORITY'];
|
|
12
|
+
const env = {};
|
|
13
|
+
for (const key of keep)
|
|
14
|
+
if (base[key] !== undefined)
|
|
15
|
+
env[key] = base[key];
|
|
16
|
+
return { ...env, HOME: temp, TMPDIR: temp, TEMP: temp, TMP: temp, USERPROFILE: temp, LOCALAPPDATA: temp, APPDATA: temp, XDG_RUNTIME_DIR: temp, ...extra };
|
|
17
|
+
}
|
|
18
|
+
export const repositoryRequest = (r) => ({ host: r.host, port: r.port, repository: r.repository });
|
|
19
|
+
/** The last `<prefix> <json>` line; a helper's `{error,message}` becomes a native error. */
|
|
20
|
+
export function parseReply(stdout, stderr = '', prefix = 'INSIGHT_WC') {
|
|
21
|
+
const line = stdout.split(/\r?\n/).filter(l => l.startsWith(prefix + ' ')).at(-1);
|
|
22
|
+
if (line === undefined) {
|
|
23
|
+
const tail = stderr.split(/\r?\n/).map(l => l.trim()).filter(Boolean).slice(-6).join(' | ');
|
|
24
|
+
throw nativeError('failed', 'The Ghidra helper ended without an answer' + (tail ? ': ' + tail.slice(-1500) : '.'));
|
|
25
|
+
}
|
|
26
|
+
const value = JSON.parse(line.slice(prefix.length + 1));
|
|
27
|
+
if (typeof value.error === 'string') {
|
|
28
|
+
const code = ['busy', 'not_found', 'modified', 'invalid', 'unavailable'].find(c => c === value.error) ?? 'failed';
|
|
29
|
+
throw nativeError(code, String(value.message ?? value.error));
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
/** `_states` names the answers Ghidra gives for this operation. */
|
|
34
|
+
export function versionResult(value, _states) {
|
|
35
|
+
if (value.state === 'conflict')
|
|
36
|
+
return { state: 'conflict', conflicts: Number(value.conflicts) || 1, summary: String(value.summary ?? 'Ghidra needs a decision') };
|
|
37
|
+
return { state: value.state, version: value.version };
|
|
38
|
+
}
|
|
39
|
+
/** Keeps the last `limit` characters of a stream. */
|
|
40
|
+
export class Tail {
|
|
41
|
+
limit;
|
|
42
|
+
text = '';
|
|
43
|
+
constructor(limit = 65536) {
|
|
44
|
+
this.limit = limit;
|
|
45
|
+
}
|
|
46
|
+
push(chunk) { this.text = (this.text + chunk.toString()).slice(-this.limit); }
|
|
47
|
+
}
|