Skip to content

feat(ghidra): stage FreeBSD host support for validation - #13140

Closed
morluto wants to merge 4 commits into
mainfrom
audit/freebsd-ghidra-7174
Closed

morluto wants to merge 4 commits into
mainfrom
audit/freebsd-ghidra-7174

Conversation

@morluto

@morluto morluto commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Summary

Builds on #7174 by @ocochard (Olivier Cochard-Labbé). This branch preserves his original commits, 4cbbed0667 and 74d78d6f72, and brings the proposal forward to current main. The goal is Ghidra analysis on FreeBSD/amd64 with the same ownership and cleanup guarantees expected on existing hosts.

This draft stages Ghidra installation recognition and process inspection. Owned launches are refused on FreeBSD while the process authority questions below are open. This draft requests a scope decision and FreeBSD validation, including which shared process entry points are in scope.

Changes

  • Use FreeBSD's fixed /bin/ps, separate output columns, and the sid keyword. Preserve current Linux and macOS command selection, Linux tracing arguments, and typed cancellation.
  • Parse one identity row at a time with a fixed locale, UTC, and unrestricted output width. Keep incomplete, duplicate, and invisible rows unresolved. FreeBSD process visibility can hide a live PID, so an empty snapshot cannot establish exit.
  • Refuse the fallback environment read on FreeBSD. Its flattened ps eww output combines argv with environment and cannot authenticate REA_PROCESS_RUN_ID.
  • Retain the x64 Ghidra native directory and JVM mapping with installation fixture coverage. Hold supported-platform documentation until the runtime path is verified.

Scope and proof still needed

  • Decide whether to limit FreeBSD launch support to Ghidra or cover the other shared owned-launch consumers, including MCP doctor and the generic command runner.
  • Establish generation and exit evidence before allowing signals. lstart is formatted at one-second precision, and FreeBSD PID allocation can use randomized increments. A native kinfo_proc reader can expose subsecond start time, but visibility failures still need an explicit unavailable state. Start time formatting · PID allocation · Process visibility
  • Validate an environment-only source under ordinary user permissions. FreeBSD's procstat environment path exposes a separate list and omits it on read failure. Validate the structured output and bind the read to the same generation before accepting a token. procstat environment reader
  • Verify real FreeBSD/amd64 rea doctor and Ghidra decompilation with a supported Node, JDK, and Ghidra. Exercise cleanup with live children, hidden or unreadable PIDs, exit, cancellation during finalization, and retry before declaring support.

Evidence

  • npm run check:fast passed. The focused macOS/arm64 run passed 552 tests across 30 files with 2 skips.
  • The macOS/arm64 source tests exercise the FreeBSD rows and cancellation at the subprocess boundary using controlled output. Restoring the old false-absence classification made both regression tests fail. The Ghidra fixture exercises native tool lookup and JVM platform matching.
  • feat(ghidra): inspect FreeBSD amd64 installations #7174 reports a real FreeBSD/Ghidra 12.2 smoke test on an older stacked branch. The draft has not been executed on FreeBSD.
  • The original PR's author declarations remain with its human owner. This continuation is a draft pending scope and real-platform evidence.

ocochard and others added 4 commits October 25, 2026 22:51
Map freebsd/x64 to Ghidra's freebsd_x86_64 native directory (found
under build/os in FreeBSD packages), expect ELF native tools, and
accept a JVM reporting os.name=FreeBSD.
BSD ps treats everything after the first '=' in -o as the column
header, so pass one -o per column. FreeBSD has no 'sess' keyword; use
'sid' there.

Without procfs, read process identities on FreeBSD from one ps snapshot:
lstart as the start identity, plus parent, process group, effective UID
and zombie/exiting state. FreeBSD ps exits 1 without output when none of
the requested PIDs exists; report those PIDs as absent. This lets
owned-process baselines and cleanup revalidation work, which the Ghidra
provider requires to launch Java.
@morluto
morluto marked this pull request as ready for review November 21, 2026 16:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T16:06:10.875082Z 8891f31 Draft marked ready
ℹ️ 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.

@morluto

morluto commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

The changes are now on the original PR, #7174, with @ocochard’s commits preserved. Continuing the work there.

@morluto morluto closed this Nov 21, 2026
@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[Medium impact] The PR changes FreeBSD host recognition and shared process workflows.

Fix the existing process finalization tests before merging; the new FreeBSD paths bypass their fake commands.

Fix All in CodexFindings

  1. P1 Cancellation tests bypass their fixtures ▶
Fix with agent prompt
### Issue 1
src/process/systemPs.ts:66-67
The existing tests in `processObservationCommandFinalization.test.ts` use `freebsd` to select a fake `ps` from `PATH`. The sampler and `freebsd-list` cases now run the real `/bin/ps`, so the fake command never writes its ready marker and the tests fail on non-Windows hosts. The `freebsd-environment` case also fails because the read now rejects before starting the fake command.

Update these tests to inject the subprocess boundary, and test the environment refusal separately. Keep the assertions that cancellation waits for the child to exit.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Stages FreeBSD installation recognition and process inspection without enabling owned launches.

  • Ghidra checks recognize FreeBSD/amd64 native tools.
  • FreeBSD process inspection can read visible process identities.
  • FreeBSD owned launches stay blocked without stronger process proof.
  • Process capture reads FreeBSD session IDs from ps.

Acknowledged by morluto: owned launches remain disabled while generation identity, exit proof, environment-only token reads, shared-consumer scope, and real FreeBSD validation remain unresolved. Supported-platform documentation is intentionally deferred.

Supersession: local history contains the two preserved commits from #7174. Current GitHub status and later overlapping PRs could not be checked because GitHub access requires authentication.

Review conclusions are source-derived; tests were not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[FreeBSD host] --> B[Installation recognition]
  B --> C[Native directory and JVM matching]
  A --> D[Process inspection]
  D --> E[Fixed ps and separate columns]
  E --> F[Missing rows remain unknown]
  A --> G[Owned launch preparation]
  G --> H[Refused before launch]
  A --> I[Environment token read]
  I --> J[Unavailable]
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/process/systemPs.ts
Comment on lines +66 to +67
if (platform === "darwin" || platform === "freebsd")
return { command: "/bin/ps", source: "system" };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Cancellation tests bypass their fixtures

The existing tests in processObservationCommandFinalization.test.ts use freebsd to select a fake ps from PATH. The sampler and freebsd-list cases now run the real /bin/ps, so the fake command never writes its ready marker and the tests fail on non-Windows hosts. The freebsd-environment case also fails because the read now rejects before starting the fake command.

Update these tests to inject the subprocess boundary, and test the environment refusal separately. Keep the assertions that cancellation waits for the child to exit.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/process/systemPs.ts
Line: 66-67

Comment:
**Cancellation tests bypass their fixtures**

The existing tests in `processObservationCommandFinalization.test.ts` use `freebsd` to select a fake `ps` from `PATH`. The sampler and `freebsd-list` cases now run the real `/bin/ps`, so the fake command never writes its ready marker and the tests fail on non-Windows hosts. The `freebsd-environment` case also fails because the read now rejects before starting the fake command.

Update these tests to inject the subprocess boundary, and test the environment refusal separately. Keep the assertions that cancellation waits for the child to exit.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex

@morluto morluto added enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants