Skip to content

feat(ghidra): reuse existing projects through verified copies - #7236

Merged
gensokyo-dev merged 10 commits into
mainfrom
feat/1048-ghidra-existing-project
Oct 26, 2026
Merged

gensokyo-dev merged 10 commits into
mainfrom
feat/1048-ghidra-existing-project

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1048 and #2147. Repeated Ghidra investigations can select an existing project instead of paying import and auto-analysis on every session. Builds on the launcher groundwork in #2150 by @akushonkamen and @morluto, preserving their attribution.

Change and scope

REA_GHIDRA_PROJECT_PATH selects an expanded .gpr marker; optional REA_GHIDRA_PROGRAM_NAME selects one exact root program (default: resolved executable filename). Shared CLI/MCP configuration and saved registrations use the same selection.

One provider owner fingerprints the selected .gpr/.rep pair with serial 64-KiB reads, copies only that pair into the owned runtime, and verifies copied content against the committed profile before launch. The engine runs -process -noanalysis -readOnly, skips repair scripts and exposes no database-edit capabilities. The bridge still validates the recorded import SHA against the admitted target. Source changes/mismatches fail explicitly; close/reopen resolves a new commitment.

Existing-project Evidence records caller/resolved paths, program and project content identity. Original analysis completeness/settings stay unknown; the authenticated bridge reports that origin with read-only capabilities and null completion. Fresh-import handshake semantics remain supported. Import overrides and Windows/special import profiles are rejected for this mode.

Scope decision: not applicable; existing static provider operations, owned helper processes/copies, no added target execution, injection or target mutation. The original database is read for copying/fingerprinting and is never opened/saved by Ghidra. No new installer or implicit persistent cache. Authored setup/contract/skill docs are updated; generated outputs remain ignored.

Executed validation

  • Focused Ghidra suites: 35 files, 958 passed / 4 platform skips, including copied-project identity, ignored sibling projects, stale content, configuration and strict origin/unknown-completion handshake cases.
  • Build, typecheck/lint, docs (9 cases), whole-repository formatting: passed with the updated main dependency lock.
  • Actual Linux x64 Ghidra 12.1.4 / JDK 21 CLI and SDK workflows passed. Full function inventory and two nonempty pseudocode results match fresh import by function identity; complete exported Evidence authenticates offline and source project/binary content stays unchanged.
  • Review regressions cover resolved executable names, unavailable Windows reuse, exact cancellation reasons, and shared /tmp parents. Actual Ghidra saved seed/analyzer reports reopen successfully as one immutable historical Evidence record linked from observations; a real project directly under /tmp also preserves identical facts and unchanged source content.
  • Real wrong-target digest and changed-after-open cases reject explicitly and clean up. Actual CLI decompilation matches MCP on the same selected project.
Completed investigation Fresh wall / family CPU Reuse wall / family CPU Fresh / reuse peak family GiB
ls, 652 functions 63.62 / 84.87 s 31.69 / 46.61 s 1.276 / 0.938
libcrypto, 14,338 functions 186.42 / 287.01 s 25.45 / 40.23 s 1.857 / 1.258

Matched rows use the same five-family catalog and complete task. A narrower executed ls pair removes the unused native family (97 tools), preserves facts, and uses 67,523 / 67,820 estimated full-wire tokens; the broader pair uses 85,151 / 85,448. Extra project provenance slightly increases response tokens. Estimates use cl100k_base; actual model usage is unmeasured. Preparation costs are separate: ls 36.17 s / 59.54 CPU s; crypto 231.76 s / 251.08 CPU s. Sequential shared-host samples do not establish a general speed ratio. All runs use 2-CPU affinity and an 8-GiB family guard; no OOM/guard or cleanup failure.

Full protocol, cold/warm calls, source revisions, heap settings, preparation, calibration receipts and limits: verification.

Baseline controls on main cd68181c9 and final feature bfd33f571 both produce the same 17 failures / 54 passes across six exact files: CLI advertised defaults (12), WorkBuddy/Trae paths, redirected-AppData uninstall, pcap ENOTDIR diagnostics and pwntools completed-read cleanup. Failure names and assertions match. Final-head CI run 40338086104 passed source tests, static checks, build/docs, Ghidra bridge compilation, Linux x64/arm64 and macOS arm64 packages, Windows capability/package tests, and Greptile review. Shard 7 reports 13 baseline failures; cancelled shard logs add the same WorkBuddy/pwntools baseline failures. Other cancelled coverage remains unverified. Readiness declarations stay unchecked.

Main subsequently fixed these failures. A local integration of final feature bfd33f571 with main 2b84efe0d built successfully and passed 248 tests across eight files, including both Ghidra boundary suites and all six baseline-control files. The authorized bypass applies to the old-baseline CI result, with current-main integration checked; no human-review attestation is made.

Real PE/Mach-O/macOS reuse and very large project trees remain unverified. Windows existing-project mode remains unsupported.

Author readiness

Human owner: @gensokyo-dev

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

The user explicitly authorized opening ready for review and bypassing this gate without an AI attestation of human review. Baseline CI failures, if any, will be attributed before applying the authorized bypass.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T14:19:04.083006Z bfd33f5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 792525ae8e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/ghidra/GhidraProvider.ts Resolved
Comment thread src/ghidra/GhidraProvider.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; all four earlier findings are fixed and no new blocking issue was found.

Summary

Adds opt-in reuse of existing Ghidra projects through fingerprint-checked private copies.

  • Ghidra can open a verified copy of an existing project.
  • Reused projects report unknown analysis history and block database edits.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Selected .gpr / .rep pair"] --> B["Fingerprint committed into profile"]
  B --> C["Copy into owned runtime"]
  C --> D{"Copied digest matches?"}
  D -- No --> E["Reject and clean up"]
  D -- Yes --> F["Launch process / noanalysis / readOnly"]
  F --> G["Authenticate bridge and check target digest"]
  G --> H["Read-only results with historical Evidence"]
  H --> I["Close and remove owned copy"]
Loading

Reviews (2) · Last reviewed commit: "fix(ghidra): preserve reused project bou..." · Reviewed by Greptile

Comment thread src/ghidra/GhidraProvider.ts Resolved
Comment thread src/ghidra/GhidraProjectSnapshot.ts Resolved
Comment thread src/ghidra/GhidraAnalysisProfile.ts Resolved
@gensokyo-dev
gensokyo-dev merged commit 1944751 into main Oct 26, 2026
36 of 49 checks passed
@gensokyo-dev
gensokyo-dev deleted the feat/1048-ghidra-existing-project branch October 26, 2026 14:31
@github-actions github-actions Bot mentioned this pull request Oct 26, 2026
3 tasks done
@morluto morluto added area: tests Test suite and verification enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Open a pre-imported Ghidra project so import and auto-analysis can happen outside the startup deadline

3 participants