A small, dependable Rust CLI for read-only Ghidra analysis
  • Rust 87.2%
  • Java 9.5%
  • Nix 2.7%
  • Shell 0.5%
Find a file
hermes 5c81b469e5
Some checks failed
checks / flake (push) Has been cancelled
fix: make help and version successful discovery
2026-07-29 04:15:53 +00:00
.forgejo/workflows feat: implement Ghidra adapter and Nix integration 2026-07-28 20:08:45 +00:00
docs fix: make help and version successful discovery 2026-07-29 04:15:53 +00:00
fixtures feat: integrate ghidra-cli v0.1 2026-07-28 22:20:39 +00:00
java feat: integrate ghidra-cli v0.1 2026-07-28 22:20:39 +00:00
schemas/v1 feat: integrate ghidra-cli v0.1 2026-07-28 22:20:39 +00:00
src fix: make help and version successful discovery 2026-07-29 04:15:53 +00:00
tests fix: make help and version successful discovery 2026-07-29 04:15:53 +00:00
.gitignore feat: implement Ghidra adapter and Nix integration 2026-07-28 20:08:45 +00:00
AGENTS.md docs: define v0.1 product and architecture contract 2026-07-28 18:52:31 +00:00
Cargo.lock feat: integrate ghidra-cli v0.1 2026-07-28 22:20:39 +00:00
Cargo.toml feat: integrate ghidra-cli v0.1 2026-07-28 22:20:39 +00:00
CONTEXT.md docs: define v0.1 product and architecture contract 2026-07-28 18:52:31 +00:00
deny.toml feat: implement Ghidra adapter and Nix integration 2026-07-28 20:08:45 +00:00
flake.lock feat: implement Ghidra adapter and Nix integration 2026-07-28 20:08:45 +00:00
flake.nix feat: integrate ghidra-cli v0.1 2026-07-28 22:20:39 +00:00
LICENSE docs: define v0.1 product and architecture contract 2026-07-28 18:52:31 +00:00
PRD.md fix: make help and version successful discovery 2026-07-29 04:15:53 +00:00
README.md fix: make help and version successful discovery 2026-07-29 04:15:53 +00:00

ghidra-cli

A small, dependable command-line interface for read-only Ghidra analysis. The repository is named ghidra-cli; the installed executable is ghidr.

Version 0.1 provides a synchronous Rust harness, strict Java headless adapter, content-addressed Analysis Store, Bubblewrap worker sandbox, reproducible native fixtures, and pinned x86-64 Linux Nix packaging.

Usage:

ghidr doctor
ghidr inspect ./sample
ghidr functions ./sample --limit 100
ghidr decompile ./sample --name main
ghidr clean ./sample --dry-run

Each command will identify the sample by its content, reuse compatible cached analysis, and produce versioned JSON by default. Human-readable presentation is available explicitly through --format human.

Agents can discover the complete command surface without initializing Ghidra:

ghidr --help
ghidr decompile --help
ghidr --version

These discovery requests return plain text on stdout with exit status 0 and leave stderr empty.

Documents

  • PRD.md defines the product requirements and initial delivery scope.
  • CONTEXT.md defines the domain language used throughout the project.
  • docs/adr/ records durable architectural decisions.
  • docs/research/ records cited prior-art investigations, including the Ghidra MCP comparison that informed protocol safeguards and the post-version-0.1 roadmap.

Pinned package

The flake fixes Ghidra at exactly 12.1.2 and uses JDK 21. It also closes over Rust, Bubblewrap, the Java adapter, deterministic Java/Nix formatters, cargo-deny, and statix:

nix run . -- doctor
nix develop

The native fixtures are reproducible Nix outputs rather than committed opaque binaries:

nix build .#fixtures
file result/elf-x86_64/known.elf result/pe32plus-x86_64/known.exe

Adapter boundary

The Ghidra worker dispatches doctor, inspect, functions, and decompile. inspect is the import/analyze vertical slice: the trusted harness stages the Sample and invokes official analyzeHeadless; the post-script reads only the current imported Program and private request/response paths. clean is in the five-operation Rust registry but is intentionally rejected by Java because it is a trusted, atomic Analysis Store transaction. This boundary is enforced by tests/adapter_contract.rs and documented in java/dispatch.txt.

The adapter accepts at most 1 MiB of request JSON before parsing, rejects missing/unknown fields, echoes protocol version/invocation/operation, and publishes at most 256 MiB through a temporary file plus same-filesystem atomic rename. It has no socket, network client, listener, script execution, mutation, or user-selected destination surface.

Checks

The complete pinned suite is:

cargo fmt --all --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-targets --all-features
cargo deny check
nix flake check --print-build-logs

nix flake check compiles Java with JDK 21 -Xlint:all -Werror, checks Google-style clang-format, nixfmt, and statix, builds both fixtures, runs the adapter against real Ghidra 12.1.2, and exercises inspect, functions, and decompile through the packaged ghidr path. Individual real-engine checks remain directly runnable as:

nix build .#checks.x86_64-linux.java-adapter-e2e --print-build-logs
nix build .#checks.x86_64-linux.real-ghidra-e2e --print-build-logs

License

Licensed under the Apache License 2.0.

Development may use AI assistance. Maintainers remain responsible for reviewing the resulting design and code, verifying provenance, testing behavior, and ensuring dependency-license compatibility.