@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
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
import insight.nativecheckout.InsightSnapshotFields;
|
|
2
|
-
import insight.nativecheckout.InsightSnapshotInspect;
|
|
3
|
-
import com.google.gson.*;
|
|
4
|
-
import com.xebyte.headless.GhidraServerManager;
|
|
5
|
-
import ghidra.GhidraApplicationLayout;
|
|
6
|
-
import ghidra.framework.*;
|
|
7
|
-
import ghidra.framework.client.RepositoryAdapter;
|
|
8
|
-
import ghidra.framework.model.*;
|
|
9
|
-
import ghidra.framework.project.DefaultProjectManager;
|
|
10
|
-
import ghidra.framework.data.*;
|
|
11
|
-
import ghidra.program.database.ProgramDB;
|
|
12
|
-
import ghidra.program.model.listing.Program;
|
|
13
|
-
import ghidra.util.task.TaskMonitor;
|
|
14
|
-
import insight.nativecheckout.HeadlessProgramMergeManager;
|
|
15
|
-
import db.InsightNativeFingerprint;
|
|
16
|
-
import java.nio.file.*;
|
|
17
|
-
import java.nio.channels.FileChannel;
|
|
18
|
-
import java.util.*;
|
|
19
|
-
|
|
20
|
-
/** Service-only native lifecycle. Native checkouts and their native change sets are never synthesized. */
|
|
21
|
-
public final class InsightNativeCheckout {
|
|
22
|
-
static final TaskMonitor MONITOR=TaskMonitor.DUMMY;
|
|
23
|
-
static final Object CONSUMER=new Object();
|
|
24
|
-
static boolean permitMerge=true;
|
|
25
|
-
/** Set when a request leaves this JVM in a doubtful state (an Error or a failed cleanup): a service then exits. */
|
|
26
|
-
static volatile boolean poisoned;
|
|
27
|
-
static class Projects extends DefaultProjectManager {Projects(){super();}}
|
|
28
|
-
static final class HeadChanged extends RuntimeException {HeadChanged(){super("Shared head changed before native check-in");}}
|
|
29
|
-
static class Factory extends ghidra.program.database.GhidraProgramMultiUserMergeManagerFactory {
|
|
30
|
-
@Override protected DomainObjectMergeManager doGetMergeManager(DomainObject result,DomainObject mine,DomainObject original,DomainObject latest){
|
|
31
|
-
// Check-in must commit the already journaled candidate. A server race aborts, never silently changes that candidate.
|
|
32
|
-
if(!permitMerge)throw new HeadChanged();
|
|
33
|
-
return new HeadlessProgramMergeManager((Program)result,(Program)mine,(Program)original,(Program)latest,
|
|
34
|
-
((ProgramDB)latest).getChanges(),((ProgramDB)mine).getChanges());
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
static void require(boolean value,String reason){if(!value)throw new IllegalStateException(reason);}
|
|
38
|
-
static String text(JsonObject q,String name){return q.get(name).getAsString();}
|
|
39
|
-
static final Gson GSON=new GsonBuilder().serializeNulls().create();
|
|
40
|
-
static void write(Path path,Object value)throws Exception {
|
|
41
|
-
Path temporary=path.resolveSibling(path.getFileName()+".new-"+UUID.randomUUID());
|
|
42
|
-
try(var channel=FileChannel.open(temporary,StandardOpenOption.CREATE_NEW,StandardOpenOption.WRITE)){
|
|
43
|
-
var bytes=java.nio.ByteBuffer.wrap(GSON.toJson(value).getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
|
44
|
-
while(bytes.hasRemaining())channel.write(bytes);channel.force(true);
|
|
45
|
-
}
|
|
46
|
-
Files.move(temporary,path,StandardCopyOption.ATOMIC_MOVE,StandardCopyOption.REPLACE_EXISTING);
|
|
47
|
-
if(!System.getProperty("os.name").startsWith("Windows"))try(var channel=FileChannel.open(path.getParent(),StandardOpenOption.READ)){channel.force(true);}
|
|
48
|
-
}
|
|
49
|
-
/** Set before the first operation-journal write of the current request; after it, no refusal is "not sent". */
|
|
50
|
-
private static boolean intentStarted;
|
|
51
|
-
static void intent(Path journal,Object value)throws Exception {intentStarted=true;write(journal,value);}
|
|
52
|
-
static void source(Program p,JsonObject owner){
|
|
53
|
-
require(p.getExecutableSHA256().equals(text(owner,"sourceSha")),"Native source identity changed");
|
|
54
|
-
if(!p.getOptions("Insight").getString("Publication Engine","").equals("native-checkout-v1"))throw new InsightNativeMigration.Required();
|
|
55
|
-
}
|
|
56
|
-
/** The program is this target's native model; no bytes are read. */
|
|
57
|
-
static void identified(DomainFile file,JsonObject owner)throws Exception {
|
|
58
|
-
Program p=(Program)file.getDomainObject(CONSUMER,false,false,MONITOR);
|
|
59
|
-
try{source(p,owner);}finally{p.release(CONSUMER);}
|
|
60
|
-
}
|
|
61
|
-
/** The saved state of a local file as Ghidra identifies it; the database is not read. */
|
|
62
|
-
static Map<String,Object> saved(DomainFile file,JsonObject owner)throws Exception {
|
|
63
|
-
Program p=(Program)file.getDomainObject(CONSUMER,false,false,MONITOR);
|
|
64
|
-
try{source(p,owner);return Map.of("fingerprint",InsightNativeFingerprint.saved(p),"modified",file.isCheckedOut()&&file.modifiedSinceCheckout(),"version",file.getVersion(),"fileId",file.getFileID(),
|
|
65
|
-
"language",p.getLanguageID().toString(),"compiler",p.getCompilerSpec().getCompilerSpecID().toString(),"imageBase",p.getImageBase().toString());}
|
|
66
|
-
finally{p.release(CONSUMER);}
|
|
67
|
-
}
|
|
68
|
-
/** Every file with local bytes, at any depth; unmodified server items have none. */
|
|
69
|
-
static void local(DomainFolder folder,Set<String> names){
|
|
70
|
-
for(DomainFile f:folder.getFiles())if(!f.isVersioned()||f.isCheckedOut()||f.isHijacked()||f.canRecover())names.add(f.getPathname().substring(1));
|
|
71
|
-
for(DomainFolder child:folder.getFolders())if(child.isLinked())names.add(child.getPathname().substring(1)+"/");else local(child,names);
|
|
72
|
-
}
|
|
73
|
-
/** Ghidra's save counter of the local file: a later save of a file that survived its release is seen without reading it. */
|
|
74
|
-
static long localVersion(DomainFile file)throws Exception {
|
|
75
|
-
Program p=(Program)file.getDomainObject(CONSUMER,false,false,MONITOR);
|
|
76
|
-
try{return InsightNativeFingerprint.localVersion(p);}finally{p.release(CONSUMER);}
|
|
77
|
-
}
|
|
78
|
-
static boolean sameRelease(JsonObject receipt,JsonObject q){
|
|
79
|
-
// The checkout, its base version and its file identify a release. Receipts of earlier builds also recorded
|
|
80
|
-
// fingerprints, which name nothing comparable any more and are not consulted.
|
|
81
|
-
if(!Objects.equals(receipt.get("checkoutId"),q.get("checkoutId"))||!Objects.equals(receipt.get("version"),q.get("verifiedVersion")))return false;
|
|
82
|
-
return !receipt.has("fileId")||Objects.equals(receipt.get("fileId"),q.get("fileId"));
|
|
83
|
-
}
|
|
84
|
-
/** A new intent can prove the local file left between server termination and native undo's local deletion. */
|
|
85
|
-
static boolean survivingRelease(JsonObject receipt,JsonObject q,String fileId,long localVersion){
|
|
86
|
-
// The intent was recorded only after Ghidra reported this checkout unmodified and without recovery data. The
|
|
87
|
-
// file left behind is that one only while it was not saved again.
|
|
88
|
-
return receipt.has("fileId")&&receipt.has("localVersion")&&Objects.equals(receipt.get("state"),new JsonPrimitive("release_intent"))&&sameRelease(receipt,q)&&
|
|
89
|
-
fileId.equals(text(receipt,"fileId"))&&localVersion>=0&&receipt.get("localVersion").getAsLong()==localVersion;
|
|
90
|
-
}
|
|
91
|
-
static boolean backupName(String program,String name){
|
|
92
|
-
String keep=program+".keep";
|
|
93
|
-
return name.equals(keep)||name.startsWith(keep+".")&&name.substring(keep.length()+1).matches("[1-9][0-9]*");
|
|
94
|
-
}
|
|
95
|
-
/** Include occupied server names too: undoCheckout chooses a name absent from both filesystems. */
|
|
96
|
-
static Map<String,String> backupInventory(Project project,String program){
|
|
97
|
-
Map<String,String> files=new TreeMap<>();
|
|
98
|
-
for(DomainFile file:project.getProjectData().getRootFolder().getFiles())if(backupName(program,file.getName()))files.put(file.getName(),file.getFileID());
|
|
99
|
-
return files;
|
|
100
|
-
}
|
|
101
|
-
static String createdBackup(String program,JsonObject before,JsonObject after){
|
|
102
|
-
require(before!=null&&after!=null,"Native backup creation inventory is missing");
|
|
103
|
-
for(var entry:before.entrySet())require(backupName(program,entry.getKey())&&entry.getValue().equals(after.get(entry.getKey())),"Pre-existing native backup identity changed");
|
|
104
|
-
var added=new TreeSet<>(after.keySet());added.removeAll(before.keySet());
|
|
105
|
-
require(added.size()==1&&backupName(program,added.first()),"Native backup creation is ambiguous");
|
|
106
|
-
JsonElement id=after.get(added.first());require(id!=null&&id.isJsonPrimitive()&&id.getAsJsonPrimitive().isString()&&!id.getAsString().isEmpty(),"Native backup identity is missing");
|
|
107
|
-
return added.first();
|
|
108
|
-
}
|
|
109
|
-
static boolean backupMatches(JsonObject journal,String name,Map<String,Object> saved){try{
|
|
110
|
-
JsonObject files=journal.getAsJsonObject("result").getAsJsonObject("disposableBackups");
|
|
111
|
-
if(files==null||!files.has(name))return false;
|
|
112
|
-
JsonElement proof=files.get(name);
|
|
113
|
-
if(proof.isJsonPrimitive()){
|
|
114
|
-
// Older proofs were recorded only for a before-image-equal backup (not saveAs-created Update copies).
|
|
115
|
-
return name.endsWith(".keep")&&proof.equals(journal.getAsJsonObject("before").get("fingerprint"))&&saved.get("fingerprint").equals(proof.getAsString());
|
|
116
|
-
}
|
|
117
|
-
if(!proof.isJsonObject())return false;
|
|
118
|
-
JsonObject created=proof.getAsJsonObject();
|
|
119
|
-
if(!saved.get("fileId").equals(text(created,"fileId"))||!saved.get("fingerprint").equals(text(created,"fingerprint"))||
|
|
120
|
-
!journal.get("backupExpected").getAsBoolean())return false;
|
|
121
|
-
if(created.get("schema").getAsInt()==2||created.get("schema").getAsInt()==3){
|
|
122
|
-
String program=text(journal.getAsJsonObject("request").getAsJsonObject("owner"),"path").substring(1);
|
|
123
|
-
return text(journal.getAsJsonObject("request"),"operation").equals("discard")&&
|
|
124
|
-
name.equals(createdBackup(program,journal.getAsJsonObject("backupFilesBefore"),journal.getAsJsonObject("backupFilesAfter")))&&
|
|
125
|
-
journal.getAsJsonObject("backupFilesAfter").get(name).equals(created.get("fileId"))&&
|
|
126
|
-
name.equals(text(journal.getAsJsonObject("result"),"retainedKeepFile"))&&
|
|
127
|
-
(created.get("schema").getAsInt()==3||created.get("fingerprint").equals(journal.getAsJsonObject("before").get("fingerprint")));
|
|
128
|
-
}
|
|
129
|
-
boolean newFile=journal.has("backupAbsent")&&(journal.get("backupAbsent").getAsBoolean()||journal.has("backupBeforeFileId")&&!journal.get("backupBeforeFileId").isJsonNull()&&
|
|
130
|
-
!journal.get("backupBeforeFileId").equals(created.get("fileId")));
|
|
131
|
-
return name.endsWith(".keep")&&newFile&&created.get("schema").getAsInt()==1;
|
|
132
|
-
}catch(RuntimeException unproved){return false;}}
|
|
133
|
-
static boolean ownedBackupJournal(String filename,JsonObject journal,JsonObject q,JsonObject owner){try{
|
|
134
|
-
JsonObject request=journal.getAsJsonObject("request"),result=journal.getAsJsonObject("result");
|
|
135
|
-
return request!=null&&result!=null&&owner.equals(request.getAsJsonObject("owner"))&&Objects.equals(request.get("root"),q.get("root"))&&
|
|
136
|
-
Objects.equals(request.get("fileId"),q.get("fileId"))&&text(request,"request").matches("q_[a-f0-9-]{36}")&&
|
|
137
|
-
filename.equals(text(request,"request")+"-"+text(request,"operation")+".json")&&
|
|
138
|
-
(text(request,"operation").equals("update")&&text(result,"state").equals("updated")||text(request,"operation").equals("discard")&&text(result,"state").equals("discarded"))&&
|
|
139
|
-
result.get("baseVersion").getAsInt()<=q.get("verifiedVersion").getAsInt();
|
|
140
|
-
}catch(RuntimeException unproved){return false;}}
|
|
141
|
-
/** A completed discard replaces one checkout in this same project. Incomplete intents never extend the chain. */
|
|
142
|
-
static Set<Long> backupCheckouts(List<JsonObject> journals,JsonObject q){
|
|
143
|
-
Set<Long> ids=new HashSet<>();ids.add(q.get("checkoutId").getAsLong());boolean changed;
|
|
144
|
-
do{changed=false;for(JsonObject journal:journals)try{
|
|
145
|
-
JsonObject request=journal.getAsJsonObject("request"),result=journal.getAsJsonObject("result"),saved=result.getAsJsonObject("saved");
|
|
146
|
-
if(text(request,"operation").equals("discard")&&text(result,"state").equals("discarded")&&ids.contains(result.get("checkoutId").getAsLong())&&
|
|
147
|
-
result.get("modified").getAsBoolean()==false&&Objects.equals(request.get("checkoutId"),journal.get("checkoutId"))&&
|
|
148
|
-
!Objects.equals(request.get("checkoutId"),result.get("checkoutId"))&&request.get("checkoutId").getAsLong()>=0&&
|
|
149
|
-
Objects.equals(saved.get("fileId"),q.get("fileId"))&&Objects.equals(saved.get("version"),result.get("baseVersion"))&&
|
|
150
|
-
text(saved,"fingerprint").matches("[a-f0-9]{64}")&&
|
|
151
|
-
result.get("baseVersion").getAsInt()>=journal.get("baseVersion").getAsInt())changed|=ids.add(request.get("checkoutId").getAsLong());
|
|
152
|
-
}catch(RuntimeException unproved){/* A partial receipt cannot connect checkouts. */}}while(changed);
|
|
153
|
-
return ids;
|
|
154
|
-
}
|
|
155
|
-
/** Only an expected backup newly created by a completed owned native operation, still at its recorded bytes, is disposable. */
|
|
156
|
-
static Map<String,String> backups(Project project,Path operations,JsonObject q,JsonObject owner)throws Exception {
|
|
157
|
-
String name=text(owner,"path").substring(1);Map<String,String> proved=new TreeMap<>();List<JsonObject> journals=new ArrayList<>();
|
|
158
|
-
try(var paths=Files.list(operations)){
|
|
159
|
-
for(Path path:paths.filter(p->p.getFileName().toString().matches("q_[a-f0-9-]{36}-(update|discard)\\.json")).sorted().toList()){
|
|
160
|
-
JsonObject journal=JsonParser.parseString(Files.readString(path)).getAsJsonObject();
|
|
161
|
-
if(ownedBackupJournal(path.getFileName().toString(),journal,q,owner))journals.add(journal);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
Set<Long> checkouts=backupCheckouts(journals,q);
|
|
165
|
-
for(JsonObject journal:journals){
|
|
166
|
-
JsonObject result=journal.getAsJsonObject("result"),files=result.getAsJsonObject("disposableBackups");
|
|
167
|
-
if(files==null||!checkouts.contains(result.get("checkoutId").getAsLong()))continue;
|
|
168
|
-
for(String keep:files.keySet()){
|
|
169
|
-
if(!backupName(name,keep))continue;
|
|
170
|
-
DomainFile backup=project.getProjectData().getFile("/"+keep);
|
|
171
|
-
if(backup==null||backup.isVersioned()||backup.canRecover()||backup.isCheckedOut()||backup.isHijacked())continue;
|
|
172
|
-
try{Map<String,Object> current=saved(backup,owner);if(backupMatches(journal,keep,current))proved.put(keep,current.get("fingerprint").toString());}
|
|
173
|
-
catch(Exception unproved){/* Unreadable or foreign bytes remain private. */}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return proved;
|
|
177
|
-
}
|
|
178
|
-
/** Update's createKeepFile deletes an existing .keep. Prove that exact file disposable before entering native merge. */
|
|
179
|
-
static boolean replaceableBackup(Project project,Path operations,JsonObject q,JsonObject owner,int base,Map<String,Object> intent){
|
|
180
|
-
JsonObject proof=q.deepCopy();proof.addProperty("verifiedVersion",base);
|
|
181
|
-
try{
|
|
182
|
-
String keep=text(owner,"path").substring(1)+".keep";
|
|
183
|
-
DomainFile backup=project.getProjectData().getFile("/"+keep);
|
|
184
|
-
if(backup==null||!Objects.equals(backup.getFileID(),intent.get("backupBeforeFileId")))return false;
|
|
185
|
-
String fingerprint=backups(project,operations,proof,owner).get(keep);
|
|
186
|
-
if(fingerprint==null)return false;
|
|
187
|
-
intent.put("backupReplacementProof",Map.of("name",keep,"fileId",intent.get("backupBeforeFileId"),"fingerprint",fingerprint));
|
|
188
|
-
return true;
|
|
189
|
-
}catch(Exception unproved){return false;}
|
|
190
|
-
}
|
|
191
|
-
static Map<String,String> releaseFiles(Project project,Path operations,JsonObject q,JsonObject owner,boolean localProgram)throws Exception {
|
|
192
|
-
var files=new TreeSet<String>();local(project.getProjectData().getRootFolder(),files);
|
|
193
|
-
Map<String,String> backups=backups(project,operations,q,owner);var allowed=new TreeSet<>(backups.keySet());
|
|
194
|
-
if(localProgram)allowed.add(text(owner,"path").substring(1));
|
|
195
|
-
require(files.equals(allowed),"Unpublished native project files must be retained");return backups;
|
|
196
|
-
}
|
|
197
|
-
static boolean released(Path root,JsonObject q)throws Exception {
|
|
198
|
-
Path path=root.resolve("released.json");if(!Files.exists(path))return false;
|
|
199
|
-
var released=JsonParser.parseString(Files.readString(path)).getAsJsonObject();
|
|
200
|
-
return text(released,"state").equals("released")&&sameRelease(released,q);
|
|
201
|
-
}
|
|
202
|
-
static void deleteReleased(Path root,ProjectLocator locator)throws Exception {
|
|
203
|
-
for(Path target:List.of(locator.getProjectDir().toPath(),locator.getMarkerFile().toPath())){
|
|
204
|
-
if(!Files.exists(target,LinkOption.NOFOLLOW_LINKS))continue;
|
|
205
|
-
require(!Files.isSymbolicLink(target)&&target.toRealPath().getParent().equals(root),"Native deletion escaped owned project");
|
|
206
|
-
// Validate the whole tree first: a Windows junction is a directory whose children live elsewhere.
|
|
207
|
-
List<Path> entries=new ArrayList<>();
|
|
208
|
-
Files.walkFileTree(target,new SimpleFileVisitor<Path>(){
|
|
209
|
-
FileVisitResult visit(Path path,java.nio.file.attribute.BasicFileAttributes at){require(!at.isSymbolicLink()&&!at.isOther(),"Native deletion met a link");entries.add(path);return FileVisitResult.CONTINUE;}
|
|
210
|
-
@Override public FileVisitResult preVisitDirectory(Path path,java.nio.file.attribute.BasicFileAttributes at)throws java.io.IOException{require(path.toRealPath().startsWith(root),"Native deletion escaped owned project");return visit(path,at);}
|
|
211
|
-
@Override public FileVisitResult visitFile(Path path,java.nio.file.attribute.BasicFileAttributes at){return visit(path,at);}
|
|
212
|
-
});
|
|
213
|
-
Collections.reverse(entries);for(Path entry:entries)Files.delete(entry);
|
|
214
|
-
}
|
|
215
|
-
require(!locator.getMarkerFile().exists()&&!locator.getProjectDir().exists(),"Native project remains");
|
|
216
|
-
}
|
|
217
|
-
static void history(RepositoryAdapter repository,String path,Map<String,Object> out)throws Exception {
|
|
218
|
-
String name=path.substring(1);
|
|
219
|
-
out.put("versions",Arrays.stream(repository.getVersions("/",name)).map(v->Map.of("version",v.getVersion(),"comment",Objects.toString(v.getComment(),""))).toList());
|
|
220
|
-
out.put("checkouts",Arrays.stream(repository.getCheckouts("/",name)).map(c->Map.of("id",c.getCheckoutId(),"version",c.getCheckoutVersion(),"user",c.getUser())).toList());
|
|
221
|
-
out.put("checkinActive",repository.isCheckinActive("/",name));
|
|
222
|
-
}
|
|
223
|
-
/** Ends exactly one server checkout whose own project no longer exists; its private work cannot be recovered. */
|
|
224
|
-
static Map<String,Object> abandon(RepositoryAdapter repository,JsonObject q,JsonObject owner)throws Exception {
|
|
225
|
-
Path root=Path.of(text(q,"root"));String name=text(owner,"path").substring(1);long id=q.get("checkoutId").getAsLong();
|
|
226
|
-
require(root.isAbsolute()&&!Files.exists(root,LinkOption.NOFOLLOW_LINKS),"Native project still exists");
|
|
227
|
-
require(root.getParent().getFileName().toString().equals(text(owner,"context")),"Malformed native binding");
|
|
228
|
-
var item=repository.getItem("/",name);require(item!=null&&item.getFileID().equals(text(q,"fileId")),"Native file ID changed");
|
|
229
|
-
require(!repository.isCheckinActive("/",name),"A native check-in is active");
|
|
230
|
-
String owned="/"+text(owner,"context")+"/"+root.getFileName()+"/view";boolean present=false;
|
|
231
|
-
// Everything is proved before the only effect.
|
|
232
|
-
for(var checkout:repository.getCheckouts("/",name)){
|
|
233
|
-
boolean project=Objects.toString(checkout.getProjectPath(),"").replace('\\','/').endsWith(owned);
|
|
234
|
-
require(project==(checkout.getCheckoutId()==id),"Server checkout belongs to another project");
|
|
235
|
-
if(!project)continue;
|
|
236
|
-
require(checkout.getUser().equals(System.getenv("GHIDRA_SERVER_USER"))&&checkout.getCheckoutType()==ghidra.framework.store.CheckoutType.NORMAL&&
|
|
237
|
-
checkout.getCheckoutVersion()==q.get("baseVersion").getAsInt(),"Server checkout differs from its receipt");
|
|
238
|
-
present=true;
|
|
239
|
-
}
|
|
240
|
-
if(q.get("check").getAsBoolean())return Map.of("state","endable");
|
|
241
|
-
require(!Files.exists(root,LinkOption.NOFOLLOW_LINKS),"Native project still exists");
|
|
242
|
-
if(present)repository.terminateCheckout("/",name,id,false);
|
|
243
|
-
for(var checkout:repository.getCheckouts("/",name))require(checkout.getCheckoutId()!=id,"Owned checkout remains");
|
|
244
|
-
return Map.of("state","abandoned","terminated",present);
|
|
245
|
-
}
|
|
246
|
-
/** One-shot helper: one request file, one JSON result line, then exit. */
|
|
247
|
-
public static void main(String[] args){
|
|
248
|
-
var output=System.out;System.setOut(System.err);Map<String,Object> result;
|
|
249
|
-
try{require(args.length==1,"Owned request required");initialize();result=handle(Path.of(args[0]));}
|
|
250
|
-
catch(Throwable failure){failure.printStackTrace(System.err);result=unknown(failure);}
|
|
251
|
-
output.println(GSON.toJson(result));System.exit(0);
|
|
252
|
-
}
|
|
253
|
-
private static boolean registered;
|
|
254
|
-
/** Ghidra and the stock multi-user merge factory are initialized once per JVM (helper or long-lived service). */
|
|
255
|
-
static synchronized void initialize()throws Exception {
|
|
256
|
-
if(!Application.isInitialized())Application.initializeApplication(new GhidraApplicationLayout(),new HeadlessGhidraApplicationConfiguration());
|
|
257
|
-
if(!registered){
|
|
258
|
-
Class.forName("ghidra.program.database.ProgramMultiUserMergeManagerFactory");
|
|
259
|
-
PluggableServiceRegistry.registerPluggableService(ghidra.program.database.ProgramMultiUserMergeManagerFactory.class,new Factory());registered=true;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
static Map<String,Object> unknown(Throwable failure){
|
|
263
|
-
return Map.of("state","unknown","diagnostic",failure.getClass().getSimpleName(),"reason",Objects.toString(failure.getMessage(),failure.toString()),"code",failure instanceof InsightNativeMigration.Required?"migration":"unknown");
|
|
264
|
-
}
|
|
265
|
-
/** One native checkout operation. Per-request state is reset, so a long-lived service handles requests independently. */
|
|
266
|
-
static Map<String,Object> handle(Path requestFile){
|
|
267
|
-
Project project=null;GhidraServerManager server=null;
|
|
268
|
-
// The journal of an Update or check-in is written right before Ghidra is called. A refusal before this call began
|
|
269
|
-
// writing it, while the journal was positively absent when the request started, called nothing: "not sent".
|
|
270
|
-
boolean preCall=false;intentStarted=false;
|
|
271
|
-
Map<String,Object> out=new LinkedHashMap<>();
|
|
272
|
-
permitMerge=true;HeadlessProgramMergeManager.invocations=0;HeadlessProgramMergeManager.phases.clear();
|
|
273
|
-
try {
|
|
274
|
-
JsonObject q=JsonParser.parseString(Files.readString(requestFile)).getAsJsonObject();
|
|
275
|
-
boolean abandoning=text(q,"operation").equals("abandon");
|
|
276
|
-
Path root=abandoning?Path.of(text(q,"root")):Path.of(text(q,"root")).toRealPath();
|
|
277
|
-
JsonObject owner=abandoning?q.getAsJsonObject("owner"):JsonParser.parseString(Files.readString(root.resolve("native-owner.json"))).getAsJsonObject();
|
|
278
|
-
require(owner.equals(q.getAsJsonObject("owner")),"Native owner receipt changed");
|
|
279
|
-
require(text(owner,"protocol").equals("native-checkout-v1")&&text(owner,"path").equals("/"+text(owner,"target")+".bin"),"Malformed native binding");
|
|
280
|
-
String operation=text(q,"operation"),path=text(owner,"path"),name=path.substring(1);
|
|
281
|
-
if(!abandoning&&(operation.equals("update")||operation.equals("checkin"))&&q.has("request")&&text(q,"request").matches("q_[a-f0-9-]{36}"))
|
|
282
|
-
preCall=Files.notExists(root.resolve("operations").resolve(text(q,"request")+"-"+operation+".json"),LinkOption.NOFOLLOW_LINKS);
|
|
283
|
-
server=new GhidraServerManager();server.connect();require(server.isConnected(),"Native repository disconnected");
|
|
284
|
-
RepositoryAdapter repository=server.server().getRepository(text(owner,"repository"));repository.connect();
|
|
285
|
-
require(repository.getUser().hasWritePermission()&&repository.getUser().getName().equals(System.getenv("GHIDRA_SERVER_USER")),"Publisher authority required");
|
|
286
|
-
if(abandoning){
|
|
287
|
-
out.putAll(abandon(repository,q,owner));repository.disconnect();server.disconnect();server=null;return out;
|
|
288
|
-
}
|
|
289
|
-
ProjectLocator locator=new ProjectLocator(root.toString(),"view");Projects manager=new Projects();
|
|
290
|
-
// After a proved release the project is never reopened: an interrupted deletion can leave it unreadable.
|
|
291
|
-
if((operation.equals("release")||operation.equals("drop"))&&released(root,q)){
|
|
292
|
-
require(Arrays.stream(repository.getCheckouts("/",name)).noneMatch(c->c.getCheckoutId()==q.get("checkoutId").getAsLong()),"Owned checkout remains");
|
|
293
|
-
if(operation.equals("drop"))deleteReleased(root,locator);
|
|
294
|
-
repository.disconnect();server.disconnect();server=null;return new LinkedHashMap<>(Map.of("state",operation.equals("drop")?"dropped":"released"));
|
|
295
|
-
}
|
|
296
|
-
if(operation.equals("create")&&!locator.getMarkerFile().exists())project=manager.createProject(locator,repository,false);
|
|
297
|
-
else project=manager.openProject(locator,false,false);
|
|
298
|
-
require(locator.getProjectDir().toPath().toRealPath().getParent().equals(root),"Native project moved outside owned storage");
|
|
299
|
-
var bound=project.getProjectData().getRepository();
|
|
300
|
-
// The binding is compared first: a reconnect synchronizes the project with whatever repository it names.
|
|
301
|
-
require(bound!=null&&bound.getName().equals(repository.getName())&&bound.getServerInfo().equals(repository.getServerInfo()),"Saved native repository binding changed");
|
|
302
|
-
// A saved project's connection can be inactive under load; it reconnects once to its own, verified repository.
|
|
303
|
-
if(!bound.isConnected())try{bound.connect();}catch(Exception reconnect){reconnect.printStackTrace(System.err);}
|
|
304
|
-
require(bound.isConnected(),"Saved native repository is not connected");
|
|
305
|
-
DomainFile file=project.getProjectData().getFile(path);require(file!=null,"Native file missing");
|
|
306
|
-
if(operation.equals("create")&&!file.isCheckedOut()){
|
|
307
|
-
String projectPath=ghidra.framework.store.ItemCheckoutStatus.getProjectPath(locator.toString(),false);
|
|
308
|
-
require(Arrays.stream(repository.getCheckouts("/",name)).noneMatch(c->projectPath.equals(c.getProjectPath())),"Uncertain checkout creation must be reconciled");
|
|
309
|
-
identified(file,owner);require(file.checkout(false,MONITOR),"Native checkout denied");
|
|
310
|
-
}
|
|
311
|
-
require(!file.isCheckedOutExclusive(),"Ordinary native checkout required");
|
|
312
|
-
if(q.has("fileId"))require(file.getFileID().equals(text(q,"fileId")),"Native file ID changed");
|
|
313
|
-
if(q.has("checkoutId")&&file.isCheckedOut())require(file.getCheckoutStatus().getCheckoutId()==q.get("checkoutId").getAsLong(),"Native checkout owner changed");
|
|
314
|
-
Path operations=root.resolve("operations");Files.createDirectories(operations);
|
|
315
|
-
// Opening a file for writing discards Ghidra's recovery snapshot of unsaved changes. A file that has one is
|
|
316
|
-
// reported as it is and never opened: that work is kept for its owner to recover.
|
|
317
|
-
if(operation.equals("unsaved")){
|
|
318
|
-
// Ghidra's own open applies the recovery data or deletes it; this helper reads and writes none of it.
|
|
319
|
-
// Everything is checked before the only effect.
|
|
320
|
-
require(file.isCheckedOut()&&file.getCheckoutStatus().getCheckoutVersion()==q.get("baseVersion").getAsInt(),"Native checkout differs from its receipt");
|
|
321
|
-
boolean keep=q.get("keep").getAsBoolean(),present=file.canRecover();
|
|
322
|
-
if(present){
|
|
323
|
-
ProgramDB p=(ProgramDB)file.getDomainObject(CONSUMER,false,keep,MONITOR);
|
|
324
|
-
if(keep)try{p.save("insight recovered unsaved changes",MONITOR);}
|
|
325
|
-
catch(Throwable failure){
|
|
326
|
-
// Closing a restored program that was not saved makes Ghidra delete its recovery data. The process
|
|
327
|
-
// ends as an interrupted session does instead: the data stays and the command can be repeated.
|
|
328
|
-
failure.printStackTrace(System.err);System.err.flush();Runtime.getRuntime().halt(70);
|
|
329
|
-
}
|
|
330
|
-
p.release(CONSUMER);
|
|
331
|
-
require(!file.canRecover(),"Ghidra kept the recovery data");
|
|
332
|
-
}
|
|
333
|
-
out.put("state",!present?"absent":keep?"recovered":"discarded");
|
|
334
|
-
}
|
|
335
|
-
if(file.canRecover()){
|
|
336
|
-
require(operation.equals("status"),"Unsaved changes of an interrupted session can be recovered; keep them with `ghidra changes recover-unsaved` or drop them with `ghidra changes discard-unsaved` before this operation");
|
|
337
|
-
out.put("recoverable",true);out.put("modified",file.isCheckedOut()&&file.modifiedSinceCheckout());out.put("fileId",file.getFileID());out.put("checkedOut",file.isCheckedOut());
|
|
338
|
-
var local=new TreeSet<String>();local(project.getProjectData().getRootFolder(),local);out.put("projectFiles",local);
|
|
339
|
-
if(file.isCheckedOut()){out.put("checkoutId",file.getCheckoutStatus().getCheckoutId());out.put("baseVersion",file.getCheckoutStatus().getCheckoutVersion());}
|
|
340
|
-
history(repository,path,out);out.put("state","ready");project.close();project=null;repository.disconnect();server.disconnect();server=null;return out;
|
|
341
|
-
}
|
|
342
|
-
if(operation.equals("update")||operation.equals("checkin")||operation.equals("discard")){
|
|
343
|
-
String request=text(q,"request");require(request.matches("q_[a-f0-9-]{36}"),"Native request identity required");
|
|
344
|
-
Path journal=operations.resolve(request+"-"+operation+".json");
|
|
345
|
-
if(Files.exists(journal)){
|
|
346
|
-
JsonObject prior=JsonParser.parseString(Files.readString(journal)).getAsJsonObject();
|
|
347
|
-
require(prior.getAsJsonObject("request").equals(q),"Native request changed");
|
|
348
|
-
require(prior.has("result"),"Native outcome is unknown; do not retry");
|
|
349
|
-
out=new Gson().fromJson(prior.get("result"),LinkedHashMap.class);
|
|
350
|
-
}else{
|
|
351
|
-
require(file.isCheckedOut(),"Native checkout missing");
|
|
352
|
-
var before=saved(file,owner);long checkout=file.getCheckoutStatus().getCheckoutId();int base=file.getCheckoutStatus().getCheckoutVersion(),head=file.getLatestVersion();
|
|
353
|
-
Map<String,Object> intent=new LinkedHashMap<>();intent.put("request",q);intent.put("before",before);intent.put("checkoutId",checkout);intent.put("baseVersion",base);intent.put("headVersion",head);
|
|
354
|
-
DomainFile priorKeep=project.getProjectData().getFile(path+".keep");boolean keepAbsent=priorKeep==null;
|
|
355
|
-
String priorKeepId=keepAbsent?null:priorKeep.getFileID();
|
|
356
|
-
boolean backupExpected=file.modifiedSinceCheckout()&&(operation.equals("discard")||operation.equals("update")&&head>base);
|
|
357
|
-
intent.put("backupAbsent",keepAbsent);intent.put("backupBeforeFileId",priorKeepId);intent.put("backupExpected",backupExpected);
|
|
358
|
-
if(operation.equals("discard")){
|
|
359
|
-
var backupsBefore=backupInventory(project,name);intent.put("backupFilesBefore",backupsBefore);
|
|
360
|
-
intent(journal,intent);
|
|
361
|
-
file.undoCheckout(backupExpected);
|
|
362
|
-
out.put("state","discarded");out.put("retainedKeepFile","");
|
|
363
|
-
if(backupExpected){
|
|
364
|
-
var backupsAfter=backupInventory(project,name);intent.put("backupFilesAfter",backupsAfter);
|
|
365
|
-
String keep=createdBackup(name,GSON.toJsonTree(backupsBefore).getAsJsonObject(),GSON.toJsonTree(backupsAfter).getAsJsonObject());
|
|
366
|
-
DomainFile created=project.getProjectData().getFile("/"+keep);
|
|
367
|
-
require(created!=null&&!created.isVersioned()&&!created.canRecover()&&!created.isCheckedOut()&&!created.isHijacked(),"Native discard backup is not private");
|
|
368
|
-
var actual=saved(created,owner);
|
|
369
|
-
// Ghidra's undoCheckout made this copy; it is identified as it stands now, so a later edit of it is noticed.
|
|
370
|
-
require(Objects.equals(actual.get("fileId"),backupsAfter.get(keep)),"Native discard backup differs from the created file");
|
|
371
|
-
out.put("retainedKeepFile",keep);out.put("disposableBackups",Map.of(keep,Map.of("schema",3,"fileId",actual.get("fileId"),"fingerprint",actual.get("fingerprint"))));
|
|
372
|
-
}
|
|
373
|
-
file=project.getProjectData().getFile(path);require(file.checkout(false,MONITOR),"Native checkout after discard was refused");
|
|
374
|
-
}else if(operation.equals("update")){
|
|
375
|
-
intent(journal,intent);
|
|
376
|
-
// Only dirty incoming Update can replace .keep. A refusal is a completed pre-call outcome,
|
|
377
|
-
// carried by the existing conflict/recovery path; incomplete/legacy intents remain unknown.
|
|
378
|
-
if(backupExpected&&!keepAbsent&&!replaceableBackup(project,operations,q,owner,base,intent)){
|
|
379
|
-
require(file.getCheckoutStatus().getCheckoutId()==checkout&&file.getCheckoutStatus().getCheckoutVersion()==base,"Backup refusal did not preserve local state");
|
|
380
|
-
out.put("state","conflict");out.put("conflict","Existing native backup is not proved disposable; retain and inspect this project before Update");
|
|
381
|
-
var refusal=new LinkedHashMap<String,Object>(Map.of("schema",1,"operation","update","invoked",false,"reason","protected_existing_backup"));
|
|
382
|
-
refusal.put("fileId",priorKeepId);out.put("preCallRefusal",refusal);
|
|
383
|
-
}else{
|
|
384
|
-
if(intent.containsKey("backupReplacementProof"))intent(journal,intent);
|
|
385
|
-
try{if(head>base)file.merge(false,MONITOR);
|
|
386
|
-
require(file.getCheckoutStatus().getCheckoutId()==checkout&&file.getCheckoutStatus().getCheckoutVersion()>=head,"Native Update did not establish the requested ancestry");
|
|
387
|
-
out.put("state","updated");}
|
|
388
|
-
catch(HeadlessProgramMergeManager.UnresolvedNativeConflict conflict){
|
|
389
|
-
require(file.getCheckoutStatus().getCheckoutId()==checkout&&file.getCheckoutStatus().getCheckoutVersion()==base,"Native conflict did not preserve local state");
|
|
390
|
-
out.put("state","conflict");out.put("conflict",conflict.getMessage());
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}else{
|
|
394
|
-
if(head!=base||head!=q.get("expectedVersion").getAsInt()){
|
|
395
|
-
// A known pre-call head race is not an unknown check-in: none was issued.
|
|
396
|
-
out.put("state","conflict");out.put("conflict","Shared head changed before native check-in");
|
|
397
|
-
intent.put("result",out);intent(journal,intent);
|
|
398
|
-
}else if(!file.modifiedSinceCheckout()){
|
|
399
|
-
intent.put("marker","insight native "+request);intent(journal,intent);out.put("state","empty");
|
|
400
|
-
}else{
|
|
401
|
-
intent.put("marker","insight native "+request);intent(journal,intent);
|
|
402
|
-
permitMerge=false;
|
|
403
|
-
try{file.checkin(new DefaultCheckinHandler("insight native "+request,true,false),MONITOR);out.put("state","checked_in");}
|
|
404
|
-
catch(HeadChanged changed){
|
|
405
|
-
require(file.getCheckoutStatus().getCheckoutId()==checkout&&file.getCheckoutStatus().getCheckoutVersion()==base&&Arrays.stream(repository.getVersions("/",name)).noneMatch(v->("insight native "+request).equals(v.getComment())),"Check-in outcome is unknown");
|
|
406
|
-
out.put("state","conflict");out.put("conflict",changed.getMessage());
|
|
407
|
-
}finally{permitMerge=true;}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
out.put("saved",saved(file,owner));out.put("checkoutId",file.getCheckoutStatus().getCheckoutId());out.put("baseVersion",file.getCheckoutStatus().getCheckoutVersion());
|
|
411
|
-
out.put("modified",file.modifiedSinceCheckout());out.put("nativeMergeInvocations",HeadlessProgramMergeManager.invocations);out.put("nativePhases",HeadlessProgramMergeManager.phases);
|
|
412
|
-
if(backupExpected&&out.get("state").equals("updated")){
|
|
413
|
-
DomainFile keep=project.getProjectData().getFile(path+".keep");
|
|
414
|
-
// Ghidra's dirty Update uses createFile/saveAs, assigning the copy a new DB ID inside the fingerprinted bytes.
|
|
415
|
-
if(keep!=null&&(keepAbsent||priorKeepId!=null&&!priorKeepId.equals(keep.getFileID()))&&!keep.isVersioned()&&!keep.canRecover()&&!keep.isCheckedOut()&&!keep.isHijacked())try{
|
|
416
|
-
var actual=saved(keep,owner);out.put("disposableBackups",Map.of(name+".keep",Map.of("schema",1,"fileId",actual.get("fileId"),"fingerprint",actual.get("fingerprint"))));
|
|
417
|
-
}
|
|
418
|
-
catch(Exception unproved){/* An unreadable backup remains private; it cannot invalidate native completion. */}
|
|
419
|
-
}
|
|
420
|
-
intent.put("result",out);intent(journal,intent);
|
|
421
|
-
}
|
|
422
|
-
}else if(operation.equals("release")){
|
|
423
|
-
Path releaseFile=root.resolve("released.json");
|
|
424
|
-
Map<String,Object> release=new LinkedHashMap<>(Map.of("checkoutId",q.get("checkoutId").getAsLong(),"version",q.get("verifiedVersion").getAsInt(),
|
|
425
|
-
"fileId",text(q,"fileId")));
|
|
426
|
-
if(file.isCheckedOut()){
|
|
427
|
-
// Ghidra's own answer decides: a checkout it reports modified, or with recoverable changes, holds work.
|
|
428
|
-
require(file.getCheckoutStatus().getCheckoutVersion()==q.get("verifiedVersion").getAsInt()&&!file.canRecover()&&!file.modifiedSinceCheckout(),"Unpublished native work must be retained");
|
|
429
|
-
release.put("disposableBackups",releaseFiles(project,operations,q,owner,true));release.put("localVersion",localVersion(file));
|
|
430
|
-
release.put("state","release_intent");write(releaseFile,release);file.undoCheckout(false);
|
|
431
|
-
}else{
|
|
432
|
-
var prior=JsonParser.parseString(Files.readString(releaseFile)).getAsJsonObject();
|
|
433
|
-
require(text(prior,"state").equals("release_intent")&&sameRelease(prior,q),"Release intent changed");
|
|
434
|
-
boolean surviving=file.isHijacked();
|
|
435
|
-
if(surviving)require(!file.canRecover()&&survivingRelease(prior,q,file.getFileID(),localVersion(file)),"Unproved surviving native file must be retained");
|
|
436
|
-
release.put("disposableBackups",releaseFiles(project,operations,q,owner,surviving));
|
|
437
|
-
}
|
|
438
|
-
require(Arrays.stream(repository.getCheckouts("/",name)).noneMatch(c->c.getCheckoutId()==q.get("checkoutId").getAsLong()),"Owned checkout remains");
|
|
439
|
-
release.put("state","released");write(releaseFile,release);out.put("state","released");
|
|
440
|
-
project.close();project=null;repository.disconnect();server.disconnect();server=null;return out;
|
|
441
|
-
}else if(operation.equals("drop")){
|
|
442
|
-
require(false,"Verified release receipt differs");
|
|
443
|
-
}else if(operation.equals("prune-backups")){
|
|
444
|
-
// A checkout kept after its verified publication: Update/discard backups proved by this checkout's own
|
|
445
|
-
// journals hold no unpublished work. Anything else, including the program, is retained.
|
|
446
|
-
require(file.isCheckedOut()&&file.getCheckoutStatus().getCheckoutVersion()==q.get("verifiedVersion").getAsInt()&&!file.modifiedSinceCheckout()&&!file.canRecover(),
|
|
447
|
-
"Backup pruning requires the verified unchanged checkout");
|
|
448
|
-
List<String> pruned=new ArrayList<>();
|
|
449
|
-
for(var entry:backups(project,operations,q,owner).entrySet()){
|
|
450
|
-
DomainFile backup=project.getProjectData().getFile("/"+entry.getKey());
|
|
451
|
-
if(backup!=null&&!backup.isVersioned()&&!backup.isCheckedOut()&&saved(backup,owner).get("fingerprint").equals(entry.getValue())){backup.delete();pruned.add(entry.getKey());}
|
|
452
|
-
}
|
|
453
|
-
out.put("state","pruned");out.put("pruned",pruned);
|
|
454
|
-
}else if(operation.equals("inspect")||operation.equals("fields")||operation.equals("export")){
|
|
455
|
-
require(saved(file,owner).get("fingerprint").equals(text(q,"fingerprint")),"Saved native view changed");
|
|
456
|
-
ProgramDB p=(ProgramDB)file.getDomainObject(CONSUMER,false,false,MONITOR);
|
|
457
|
-
try{
|
|
458
|
-
if(operation.equals("export")){
|
|
459
|
-
Path target=Path.of(text(q,"output"));require(target.getParent().toRealPath().startsWith(root)&&!Files.exists(target),"Native export escaped owned storage");
|
|
460
|
-
p.saveToPackedFile(target.toFile(),MONITOR);
|
|
461
|
-
}else out.put("value",operation.equals("fields")?InsightSnapshotFields.inspect(p,q.getAsJsonArray("selectors")):InsightSnapshotInspect.inspect(p,q.getAsJsonObject("parameters")));
|
|
462
|
-
}
|
|
463
|
-
finally{p.release(CONSUMER);}
|
|
464
|
-
}else require(operation.equals("create")||operation.equals("status")||operation.equals("unsaved"),"Unknown native operation");
|
|
465
|
-
if(project!=null){
|
|
466
|
-
if(!out.containsKey("saved"))out.put("saved",saved(file,owner));
|
|
467
|
-
out.put("modified",file.modifiedSinceCheckout());out.put("fileId",file.getFileID());out.put("checkedOut",file.isCheckedOut());
|
|
468
|
-
out.put("recoverable",file.canRecover());
|
|
469
|
-
var local=new TreeSet<String>();local(project.getProjectData().getRootFolder(),local);out.put("projectFiles",local);
|
|
470
|
-
if(file.isCheckedOut()){out.put("checkoutId",file.getCheckoutStatus().getCheckoutId());out.put("baseVersion",file.getCheckoutStatus().getCheckoutVersion());}
|
|
471
|
-
}
|
|
472
|
-
history(repository,path,out);out.putIfAbsent("state","ready");out.put("guiWindows",java.awt.Window.getWindows().length);
|
|
473
|
-
require(java.awt.Window.getWindows().length==0,"Unexpected GUI window");
|
|
474
|
-
if(project!=null){project.close();project=null;}repository.disconnect();server.disconnect();server=null;
|
|
475
|
-
return out;
|
|
476
|
-
}catch(Throwable failure){failure.printStackTrace(System.err);
|
|
477
|
-
if(failure instanceof Error)poisoned=true;
|
|
478
|
-
try{if(project!=null)project.close();}catch(Throwable cleanup){poisoned=true;}
|
|
479
|
-
try{if(server!=null)server.disconnect();}catch(Throwable cleanup){poisoned=true;}
|
|
480
|
-
if(java.awt.Window.getWindows().length>0)poisoned=true;
|
|
481
|
-
// A migration requirement keeps its own diagnosis.
|
|
482
|
-
if(preCall&&!intentStarted&&!(failure instanceof Error)&&!(failure instanceof InsightNativeMigration.Required)){
|
|
483
|
-
var refused=new LinkedHashMap<String,Object>(unknown(failure));refused.put("code","not-sent");return refused;
|
|
484
|
-
}
|
|
485
|
-
return unknown(failure);}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
package db;
|
|
2
|
-
|
|
3
|
-
import db.buffers.InsightBlockTransfer;
|
|
4
|
-
import ghidra.program.database.ProgramDB;
|
|
5
|
-
import ghidra.program.model.listing.Program;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* `of` and `content` read a whole database and are for the two places where the coordinator itself copies or
|
|
9
|
-
* converts one (initial publication, legacy migration). Native checkouts are identified by `saved` and `version`.
|
|
10
|
-
*/
|
|
11
|
-
public final class InsightNativeFingerprint {
|
|
12
|
-
public static String of(Program p)throws Exception {
|
|
13
|
-
if(p.isChanged())throw new IllegalStateException("Program has unsaved changes");
|
|
14
|
-
return InsightBlockTransfer.fingerprint(((ProgramDB)p).getDBHandle().getBufferMgr().getSourceFile());
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Identity of one saved state of a local file, from what Ghidra itself keeps: the file, its base version and
|
|
18
|
-
* the version of its local buffer file, which Ghidra advances on every save. No bytes are read.
|
|
19
|
-
* It names a saved state so that a later request can tell whether it still looks at the same one; it says
|
|
20
|
-
* nothing about content, and whether a checkout holds work is Ghidra's own `modifiedSinceCheckout()`.
|
|
21
|
-
*/
|
|
22
|
-
public static String saved(Program p)throws Exception {
|
|
23
|
-
if(p.isChanged())throw new IllegalStateException("Program has unsaved changes");
|
|
24
|
-
var file=p.getDomainFile();Object source=((ProgramDB)p).getDBHandle().getBufferMgr().getSourceFile();
|
|
25
|
-
// A repository item (no local file) is one immutable version; the database is never read to name a state.
|
|
26
|
-
if(!(source instanceof db.buffers.LocalManagedBufferFile local))return version(file.getFileID(),file.getVersion());
|
|
27
|
-
// Only what the local project knows: a worker's project is not connected to the repository server.
|
|
28
|
-
return identity("local|"+file.getFileID()+"|"+(file.isCheckedOut()?"base "+file.getVersion():"private")+"|"+local.getVersion());
|
|
29
|
-
}
|
|
30
|
-
/** The version of a program's local buffer file, which Ghidra advances on every save; -1 without a local file. */
|
|
31
|
-
public static long localVersion(Program p){
|
|
32
|
-
Object source=((ProgramDB)p).getDBHandle().getBufferMgr().getSourceFile();
|
|
33
|
-
return source instanceof db.buffers.LocalManagedBufferFile local?local.getVersion():-1;
|
|
34
|
-
}
|
|
35
|
-
/** Identity of one immutable version of a repository item. */
|
|
36
|
-
public static String version(String fileId,int version)throws Exception {return identity("server|"+fileId+"|"+version);}
|
|
37
|
-
private static String identity(String value)throws Exception {
|
|
38
|
-
return java.util.HexFormat.of().formatHex(java.security.MessageDigest.getInstance("SHA-256").digest(("insight-saved-state-v1|"+value).getBytes(java.nio.charset.StandardCharsets.UTF_8)));
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Every saved record except what opening a program writes by itself: the derived Metadata table, rebuilt
|
|
42
|
-
* from options on save, and the GUI's "Should Ask To Analyze" flag. Stored file bytes are included; memory
|
|
43
|
-
* block bytes are in chained buffers too, so callers also require an equal program identity.
|
|
44
|
-
*/
|
|
45
|
-
public static String content(Program p)throws Exception {
|
|
46
|
-
DBHandle db=((ProgramDB)p).getDBHandle();
|
|
47
|
-
var hash=java.security.MessageDigest.getInstance("SHA-256");
|
|
48
|
-
var tables=new java.util.TreeMap<String,Table>();
|
|
49
|
-
for(Table table:db.getTables())if(!table.getName().equals("Metadata"))tables.put(table.getName(),table);
|
|
50
|
-
for(Table table:tables.values()){
|
|
51
|
-
boolean properties=table.getName().equals("Property Table");Schema schema=table.getSchema();
|
|
52
|
-
add(hash,table.getName().getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
|
53
|
-
add(hash,(schema.getVersion()+"|"+schema.getKeyName()+"|"+String.join("|",schema.getFieldNames())+"|"+java.util.Arrays.stream(schema.getFields()).map(f->f.getClass().getName()).toList()).getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
|
54
|
-
var records=table.iterator();
|
|
55
|
-
while(records.hasNext()){
|
|
56
|
-
DBRecord record=records.next();
|
|
57
|
-
if(properties&&record.getKeyField() instanceof StringField key&&"Program Information.Should Ask To Analyze".equals(key.getString()))continue;
|
|
58
|
-
add(hash,record.getKeyField().getBinaryData());
|
|
59
|
-
for(int i=0;i<record.getColumnCount();i++){Field field=record.getFieldValue(i);add(hash,field==null||field.isNull()?null:field.getBinaryData());}
|
|
60
|
-
}
|
|
61
|
-
hash.update((byte)2);
|
|
62
|
-
}
|
|
63
|
-
var files=p.getMemory().getAllFileBytes();
|
|
64
|
-
for(int i=0;i<files.size();i++){
|
|
65
|
-
var file=files.get(i);long size=file.getSize();
|
|
66
|
-
add(hash,(i+"|"+file.getFilename()+"|"+size).getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
|
67
|
-
for(long at=0;at<size;at+=1<<20){
|
|
68
|
-
byte[] original=new byte[(int)Math.min(1<<20,size-at)],modified=new byte[original.length];
|
|
69
|
-
if(file.getOriginalBytes(at,original)!=original.length||file.getModifiedBytes(at,modified)!=modified.length)throw new java.io.IOException("Incomplete stored file bytes");
|
|
70
|
-
add(hash,original);add(hash,modified);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return java.util.HexFormat.of().formatHex(hash.digest());
|
|
74
|
-
}
|
|
75
|
-
private static void add(java.security.MessageDigest hash,byte[] value){
|
|
76
|
-
hash.update((byte)(value==null?0:1));if(value==null)return;
|
|
77
|
-
hash.update(java.nio.ByteBuffer.allocate(4).putInt(value.length).array());hash.update(value);
|
|
78
|
-
}
|
|
79
|
-
public static String of(DBHandle db)throws Exception{return InsightBlockTransfer.fingerprint(db.getBufferMgr().getSourceFile());}
|
|
80
|
-
}
|