feat: integrate ghidra-cli v0.1

This commit is contained in:
hermes 2026-07-28 20:20:05 +00:00
52 changed files with 6689 additions and 126 deletions

View file

@ -3,18 +3,18 @@
A small, dependable command-line interface for read-only Ghidra analysis.
The repository is named `ghidra-cli`; the installed executable is `ghidr`.
The project now has its version 0.1 Rust contract foundation. The typed CLI,
public envelopes and schemas, bounded Rust/Java protocol, and synchronous
execution seam are present; store, process/sandbox, and Ghidra adapter execution
remain deliberately unconnected.
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.
Proposed usage:
Usage:
```console
ghidr doctor
ghidr inspect ./sample
ghidr functions ./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
@ -32,12 +32,63 @@ available explicitly through `--format human`.
including the Ghidra MCP comparison that informed protocol safeguards and
the post-version-0.1 roadmap.
## Status
## Pinned package
Foundation only. Every accepted command currently returns a typed
`internal_not_implemented` runtime error instead of pretending Ghidra analysis
succeeded. Subsequent layers implement the library's synchronous executor
contract while preserving the committed schemas and reviewed fixtures.
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`:
```console
nix run . -- doctor
nix develop
```
The native fixtures are reproducible Nix outputs rather than committed opaque
binaries:
```console
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:
```console
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:
```console
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