Repository navigation
feat(ghidra): admit caller-selected matching dSYM companions #2025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jimpablo
wants to merge
65
commits into
morluto:main
Choose a base branch
from
jimpablo:feat/dsym-companion-admission
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7,991
−312
Open
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
4d3b7a1
feat(ghidra): admit caller-selected matching dSYM companions
jimpablo f0eb9c4
fix(targets): partition dSYM identity and match the selected slice
jimpablo 104601e
fix(targets): keep legacy query ids and bound companion admission
jimpablo c219cb9
fix(targets): bound uuid walking and carry companion provenance
jimpablo ab3bf42
fix(contracts): budget command spans and partition companions by path
jimpablo 11e1002
fix(ghidra): commit companion identity in the analysis profile
jimpablo 731f243
fix(targets): carry companion identity through split mach-o variants
jimpablo 03f9058
fix(targets): charge traversal reads and bound staged member copies
jimpablo d3fe4a0
fix(ghidra): document and enforce dSYM admission resource budgets
morluto dbf8d2c
fix(ghidra): preserve dSYM resource refusals and staging coverage
morluto dea1571
fix(ghidra): stream dSYM UUID commands through their format owner
morluto 437eb2d
fix(ghidra): retain dSYM input ownership and shared format semantics
morluto 26effd7
fix(ghidra): preserve dSYM companion admission facts
morluto 0ab02a0
fix(ghidra): retain failed source copy owners
morluto 58af2fb
fix(targets): settle merged companion types and heap stub props
jimpablo 7bafafc
fix(macho): retain dSYM admission resources
morluto 71cee08
fix(ghidra): preserve dSYM identity and cleanup failures
morluto 7e7d3d2
fix(targets): settle merged types, heap stub props, and split oversiz…
jimpablo b735fd3
fix(ghidra): rebase onto main, drop hanging copy helper, restore staging
jimpablo 529d444
fix(targets): settle second rebase: weave dsym admission into new res…
jimpablo 07da6f1
fix(targets): restore upstream code dropped during rebase
jimpablo 1a2fa6a
fix(contracts): omit debug_companion from bare Mach-O summaries
jimpablo 0b4ae16
fix(targets): address companion admission review findings
jimpablo aa20d1d
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo 6b32456
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo 4483d21
fix(ghidra): harden dSYM companion admission, staging ownership, and …
jimpablo a7e17e6
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo d90dcca
fix(ghidra): preserve dSYM cleanup primary causes and reuse Mach-O lo…
jimpablo 8bec33a
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo c50d6f5
fix(ghidra): reject dsym_path in existing-project mode and enforce de…
jimpablo 636d664
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo 30e21fa
fix(macho): separate companion EOF truncation from traversal budget a…
jimpablo 97a2e09
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo fbef489
fix(cli): reuse absoluteLocalPathStringSchema for --dsym-path option
jimpablo f51fb61
fix(macho): clamp initial UUID prefix reads to remaining traversal bu…
jimpablo 2c150cb
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo 417b628
fix(dsym): enforce .dSYM bundle directory naming and pin companion di…
jimpablo 0988275
fix(dsym): preserve close cancellation, reject ambiguous FAT slices, …
jimpablo 390918f
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo a0cac2a
fix(dsym): preserve close cancellation during directory and staging c…
jimpablo a84c8a8
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo 6a32f35
fix(dsym): preserve member and directory refusals over final-close ca…
jimpablo c72fb30
docs(specs): add Mach-O dSYM companion feature specification
jimpablo dd33451
docs(specs): align module and checkpoint test paths in dsym plan
jimpablo a6f3b94
docs(specs): match symlink policy and saved-project error contract
jimpablo ca7d919
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo c50bf0d
fix(dsym): skip checkpoint restaging and harden companion identity
jimpablo 2152709
test(mcp): validate session dsym_path outputs via toolContract
jimpablo 4d3ad8f
fix(dsym): retain both companion and target cleanup owners on dual cl…
jimpablo 57f2edc
fix(dsym): reject duplicate FAT target CPU identities before slice na…
jimpablo 9560a44
fix(dsym): keep post-admission member read faults fatal across close …
jimpablo 9f36e1f
fix(dsym): use tagged member failure union and guard opaque abort rea…
jimpablo bdd456e
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo 616d5dc
chore(dsym): merge upstream/main and remove unused imports
jimpablo 3f8c9ce
chore(dsym): restore upstream files modified by lint-staged during merge
jimpablo 92d9d79
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo b244242
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo ea7612b
fix(contracts): preserve headerless issues alongside dsym_path and ex…
jimpablo 03b3ff8
chore(dsym): restore upstream javascriptStaticAnalysis modified by li…
jimpablo 4d761f9
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo 858d124
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo 65d40a3
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo b32d1bf
Merge remote-tracking branch 'upstream/main' into feat/dsym-companion…
jimpablo cbddb9d
test(target): verify dsym_path rejection on Hopper and IDA databases
jimpablo 336d28c
fix(ghidra): preserve dSYM parse failures, refusals, and staging owne…
jimpablo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
docs(specs): add Mach-O dSYM companion feature specification
- Loading branch information
commit c72fb30bcc2e97bba82ce83b7b6591bef8d3d473
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Implementation plan | ||
|
|
||
| ## Boundary and contracts | ||
|
|
||
| - `src/domain/machoDebugCompanion.ts`: own pure incremental `machoUuidReads`, | ||
| thin and universal `readMachoUuidEntries` (delegating container and | ||
| load-command framing to `src/domain/apple/machoContainer.ts` and | ||
| `src/domain/apple/machoLoadCommands.ts`), and CPU-scoped `(uuid, cpuType, | ||
| cpuSubtypeBase)` matching in `matchMachOCompanionEntries`. | ||
| - `src/application/DebugCompanionAdmission.ts` and | ||
| `src/application/BinaryTargetResolver.ts`: admit the caller-selected bundle at | ||
| target resolution before any provider starts. Reuse the resolver's open target | ||
| handle, enforce normalized `.dSYM` directory naming, enumerate | ||
| `Contents/Resources/DWARF` through `OwnedDirectoryHandle` and | ||
| `withRegularFileCompletion`, deduplicate `(dev, ino)` digests, and attach | ||
| `MachODebugCompanion` to Mach-O `BinaryTarget` variants or project | ||
| `debug_companion_rejected` refusals via `src/domain/targetDiagnostics.ts`. | ||
| - `src/contracts/sessionLifecycleInputs.ts`, | ||
| `src/contracts/sessionToolContracts.ts`, `src/cli/coreNativeCommands.ts`, | ||
| `src/application/DirectAnalysis.ts`, and | ||
| `src/application/binary/BinarySessionOpen.ts`: expose optional absolute | ||
| `dsym_path` / `--dsym-path` across MCP `open_binary` and one-shot native CLI | ||
| commands with contract-level headerless-format pairing rejection. | ||
| - `src/ghidra/GhidraDebugCompanion.ts`, `src/ghidra/GhidraClient.ts`, | ||
| `src/ghidra/GhidraAnalysisProfile.ts`, and | ||
| `src/domain/liveBinaryTargetSummary.ts`: reject `REA_GHIDRA_PROJECT_PATH` | ||
| pairing before headless launch, commit `debug_companion` into the Ghidra | ||
| analysis profile so saved Program checkpoints stay isolated from bare imports, | ||
| stage the verified member beside the private snapshot, and project `dsym` | ||
| facts into target-admission evidence. | ||
|
|
||
| ## Incremental work and validation | ||
|
|
||
| 1. Add pure Mach-O `LC_UUID` decoding, shared FAT container validation, and | ||
| CPU-scoped matching rules with unit coverage in | ||
| `src/domain/machoDebugCompanion.test.ts`. | ||
| 2. Implement bounded `.dSYM` bundle admission, structured refusal diagnostics, | ||
| and close-failure/cancellation handle ownership with boundary and | ||
| process-global regression suites (`tests/boundary/filesystem/targetDiagnostics.test.ts`, | ||
| `tests/process-global/debugCompanionAdmissionFailures.test.ts`). | ||
| 3. Thread `dsym_path` / `--dsym-path` through MCP and CLI contracts, session | ||
| open, and direct analysis; regenerate tool catalog projections. | ||
| 4. Add private Ghidra staging, `REA_GHIDRA_PROJECT_PATH` refusal, | ||
| analysis-profile/checkpoint isolation, and target-admission evidence | ||
| (`tests/boundary/filesystem/ghidraDebugCompanion.test.ts`, | ||
| `tests/process-global/ghidraDebugCompanionStagingLifetime.test.ts`, | ||
| `src/ghidra/GhidraProvider.behavior.test.ts`, | ||
| `src/ghidra/GhidraCheckpointStore.test.ts`). | ||
| 5. Author [provider documentation](../../../providers/dsym.md), register public | ||
| navigation and route entries, and run documentation, route, static, and deep | ||
| verification checks. | ||
|
|
||
| ## Effects and compatibility | ||
|
|
||
| All new inputs are optional; omitting `dsym_path` preserves existing target | ||
| resolution, analysis-profile digests, Program checkpoints, and Evidence shapes. | ||
| Staging writes only inside REA's private runtime root (`0600` files, `0700` | ||
| directories) and cleans up with the ephemeral session root. Neither the caller's | ||
| executable nor `.dSYM` bundle is modified or executed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Mach-O dSYM companion admission | ||
|
|
||
| Issue: https://github.com/morluto/rea/issues/1193 | ||
|
|
||
| ## Problem and outcome | ||
|
|
||
| REA imports an immutable private executable snapshot into its ephemeral Ghidra | ||
| project, so an adjacent `.dSYM` bundle beside the caller's original Mach-O | ||
| executable is never visible to Ghidra's `DSymSectionProvider`. Stripped or | ||
| linked Mach-O binaries consequently lose DWARF parameter names, structured data | ||
| types, and source-anchored type paths unless the analyst manually prepares an | ||
| external Ghidra project. | ||
|
|
||
| Admit an explicitly caller-selected `.dSYM` bundle (`dsym_path` on MCP | ||
| `open_binary`, `--dsym-path` on native CLI commands), prove before provider | ||
| startup that a bundle member's `LC_UUID` and CPU identity match the selected | ||
| Mach-O target image, stage only the verified DWARF member beside the private | ||
| Ghidra snapshot, and record companion provenance in target-admission evidence | ||
| and the committed Ghidra analysis profile. | ||
|
|
||
| ## Requirements | ||
|
|
||
| - **Explicit caller selection**: accept optional absolute `dsym_path` / | ||
| `--dsym-path`; never infer or auto-discover adjacent `.dSYM` bundles. | ||
| Omitting `dsym_path` preserves existing executable-only behavior. | ||
| - **Bundle shape and target applicability**: the resolved path must name a | ||
| `.dSYM` bundle directory (`*.dSYM`, including trailing `/` or `/.`) containing | ||
| regular-file DWARF members under `Contents/Resources/DWARF`, opened without | ||
| following symlinks on bundle components or members where the host supports | ||
| `O_NOFOLLOW`. Pairings with headerless formats (`raw-binary`, `dos-com`), | ||
| non-Mach-O targets, or pre-imported `REA_GHIDRA_PROJECT_PATH` sessions | ||
| (`-process -noanalysis`) fail closed as caller input (`invalid_request` / | ||
| `invalid_input`) with constraint `debug_companion_rejected`. | ||
|
jimpablo marked this conversation as resolved.
Resolved
|
||
| - **Mandatory `LC_UUID` and CPU matching**: thin and universal containers | ||
| validate Mach-O header/load-command framing and universal slice bounds, | ||
| alignment, overlap, and header-versus-table CPU agreement. Placeholder | ||
| all-zero UUIDs never match. Reject targets without a usable `LC_UUID`, | ||
| universal targets or members with duplicate `(cpuType, cpuSubtypeBase)` slices | ||
| (`ambiguous_target_slice` / `ambiguous_member_slice`), bundles with no | ||
| matching `(uuid, cpuType, cpuSubtypeBase)` member (`uuid_mismatch`), and | ||
| distinct matching members whose SHA-256 digests disagree | ||
| (`conflicting_matching_members`). | ||
| - **Bounded admission and handle ownership**: examine at most 16 entries in | ||
| `Contents/Resources/DWARF`, cap matched member size and cumulative | ||
| matching-member digest reads at 1 GiB (deduplicating hard links sharing one | ||
| `(dev, ino)` file identity), and bound incremental header/UUID traversal to a | ||
| 64 KiB read window and 64 MiB total header I/O across target and candidates. | ||
| Preserve refusal diagnostics ahead of final-close cancellation, retain failed | ||
| handles when descriptor or directory close fails, and honor cancellation | ||
| across member reads, staging copies, and cleanup retries. | ||
| - **Private staging and provenance**: stage only the matched DWARF member inside | ||
| REA's private runtime root at | ||
| `<snapshot>.dSYM/Contents/Resources/DWARF/<snapshot>` with `0600` file | ||
| permissions (`0700` directories) and post-copy size/SHA-256 verification, | ||
| leaving the caller's bundle untouched. Record | ||
| `dsym { source_path, member_sha256, uuid, staged_member }` in target-admission | ||
| evidence and `debug_companion { source_path, uuid, member_sha256 }` in | ||
| `GhidraAnalysisProfile` so companion-selected and bare runs never share an | ||
| analysis-profile digest or Program checkpoint. | ||
|
|
||
| ## Acceptance | ||
|
|
||
| - Domain tests cover thin and universal `LC_UUID` decoding, shared FAT container | ||
| validation delegation, placeholder zero UUIDs, CPU/subtype matching, and | ||
| duplicate-slice ambiguity. | ||
| - Boundary and process-global lifecycle tests cover `.dSYM` directory naming, | ||
| symlink rejection, entry/size/I/O limits, mismatch and conflict diagnostics, | ||
| staging digest verification, analysis-profile and checkpoint isolation, and | ||
| close-failure/cancellation invariants across directory, member, and staging | ||
| handles. | ||
| - Real macOS `clang -g` + `dsymutil` fixtures verify CLI and MCP admission of | ||
| matching bundles, caller-input rejection of mismatched bundles, and Ghidra | ||
| DWARF recovery of imported signatures and structured types where Ghidra is | ||
| available. | ||
| - User-facing prerequisites, CLI/MCP usage, and limits are documented in | ||
| [Mach-O debug companion analysis with Ghidra](../../../providers/dsym.md). | ||
|
|
||
| ## Out of scope | ||
|
|
||
| Implicit `.dSYM` discovery, DWARF source-file content acquisition, per-slice | ||
| companion overrides independent of target architecture selection, staging into | ||
| pre-existing `REA_GHIDRA_PROJECT_PATH` projects, Hopper/IDA companion staging, | ||
| and non-Mach-O debug companion formats. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Tasks | ||
|
|
||
| - [x] Define Mach-O `LC_UUID` decoding, shared FAT slice validation, and CPU-scoped companion matching rules (`src/domain/machoDebugCompanion.ts`, `src/domain/machoDebugCompanion.test.ts`). | ||
| - [x] Implement bounded `.dSYM` bundle admission, refusal diagnostics, and cancellation/cleanup handle ownership at target resolution (`src/application/DebugCompanionAdmission.ts`, `tests/boundary/filesystem/targetDiagnostics.test.ts`, `tests/process-global/debugCompanionAdmissionFailures.test.ts`). | ||
| - [x] Expose optional `dsym_path` / `--dsym-path` across MCP `open_binary` and native CLI commands, and regenerate catalog projections. | ||
| - [x] Stage verified DWARF members into private Ghidra runtime roots, isolate `GhidraAnalysisProfile` and Program checkpoints, reject `REA_GHIDRA_PROJECT_PATH` pairing, and record `dsym` admission evidence (`src/ghidra/GhidraDebugCompanion.ts`, `src/ghidra/GhidraAnalysisProfile.ts`, `src/ghidra/GhidraProvider.behavior.test.ts`). | ||
| - [x] Author [provider documentation](../../../providers/dsym.md) and pass route, catalog, static, and deep verification gates. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.