Repository navigation
fix(ghidra): retain bounded LaunchSupport failure output - #2010
lyly-bonbon wants to merge 15 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2c170b3cc
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
TL;DR: On Linux with real Ghidra 12.1.4, a failed LaunchSupport keeps its stderr and stdout in the JSON, as described. The newest commit puts the exit code and signal one level deeper, under a layer that names the failed phase. One gap remains: REA hides only its own session token, so any other secret in the output stays visible. ResultsBase is edf4624. Head is 90cda4e, which sits on top of c2c170b. I tested it as base plus the PR's four changed files. All four are unchanged between the PR's parent and base, so this equals a merge onto base. GitHub's own merge ref now targets a newer main, 42b0ed1, so I did not use it. Real-world runs used Node 24.18.0 only.
Six tests failed on base. They are the new ones: two unit cases, the The key repro. A stand-in LaunchSupport prints 3 KiB to stderr and exits 7. The reason is on the last line. On head, the exit code and signal are still there. They moved from Not run
Thanks, lyly-bonbon, for the PR. Changes since the earlier headI ran this PR twice. The first head was c2c170b. The second is 90cda4e.
What each case showedReal failure, short output. I used the real Truncation. At 20,585 bytes, head kept the first 8,192 bytes of stderr. The reason on the last line was cut. Redaction. The redactor knows one thing: the random session token REA makes for each run. The stand-in jar read that token from the session file and printed it. Head showed Test setup
Commands# build and typecheck, each tree (Node 24, under a memory cap)
npm ci && npm run build && npm run test:prepare
npm run typecheck
npm run test:focused -- src/ghidra/GhidraSessionError.test.ts \
tests/boundary/mcp/ghidraFailureDiagnostics.test.ts \
src/ghidra/GhidraRequestQueue.test.ts \
tests/boundary/providers/ghidra/ghidraClient.test.ts \
tests/boundary/providers/ghidra/ghidraLauncher.test.ts
# the PR's two files on Node 22 and 26 (head only)
npm run test:focused -- src/ghidra/GhidraSessionError.test.ts \
tests/boundary/mcp/ghidraFailureDiagnostics.test.ts
# real-world run, per tree and per case
GHIDRA_INSTALL_DIR=<scratch copy> JAVA_HOME=<JDK 21> \
node scripts/rea.mjs analyze <program> --provider ghidra --jsonCases:
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@morluto Could you approve the CI run for this PR? It is still awaiting maintainer approval. Thanks to CassieFox23 for the Linux testing. Could you confirm how you would like to handle these two points from that feedback before merging?
The two earlier inline findings were addressed in |
dandgabr
left a comment
There was a problem hiding this comment.
Review corrections
- P3 — Bound LaunchSupport output before redaction.
ghidraJavaLaunch()callsexecFileOutput()without amaxBuffer, whose default capture is unbounded. On a LaunchSupport failure,GhidraSessionErrornow passes the complete captured stdout and stderr through the redactor before applying the 8 KiB diagnostic projection limit. A failing or compromised local helper can therefore retain arbitrarily large output and trigger unbounded redaction work during startup failure. Set an explicit capture ceiling at the command boundary and preserve whether capture was truncated.
|
Regarding the capture-limit review: confirmed from the source that LaunchSupport has no capture ceiling. The 8 KiB bound applies only to projected diagnostics; it does not bound capture or redaction work. A capture limit also affects successful #2011 has now merged for #1992 and retains the same unbounded capture path. This PR conflicts with that alternative implementation. I am leaving this concern pending until the remaining scope is settled, rather than adding a capture policy to the overlapping implementation. |
|
@greptileai review |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffd5f4119e
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Node timers can fire while performance.now() is still a fraction of a millisecond short of the monotonic deadline. ProviderStartupDeadline then reported interruption "timeout" and an aborted signal while remainingMs() returned ceil(0.x) = 1, so polling loops guarded by remainingMs() > 0 (Hopper and Ghidra startup) could run past an elapsed deadline, and the real-timer test "aborts a bounded wait when its real monotonic deadline expires" failed intermittently in CI (expected 1 to be 0). Once the deadline's own timer has classified a timeout, report zero remaining time. A deterministic regression test fires the timer with the monotonic clock 0.4 ms short of the deadline. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d16e6ae56
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. Fixed in 4d16e6a. Root cause: Session failure redaction received plain strings without capture completeness, so it removed complete tokens but could retain a credential prefix when maxBuffer cut the other pipe. Structural fix: Capture completeness now reaches the client-owned authentication redactor. It delegates to the existing truncation-aware credential redactor for both streams before output bounds; unknown abort completeness is conservative too. Bounded successful helper warnings preserve their truncation fact. Source validation: Added a source regression carrying a cut token prefix through session failure projection; inspected the production client callback, command/launch projection, and credential redactor. Targeted formatting used pinned Node 24.18.0 with two threads; git diff --check passed. Tests, typechecks, lint, builds, provider workloads, and CI reruns were intentionally not executed at the user’s request. Authored regressions remain unexecuted. Remaining cleanup: no directly related source cleanup identified in this bounded pass. Runtime/provider behavior remains unverified by this revision. Fixed in 4d16e6a. Root cause: The shared execFile failure extractor treated Node’s missing killed property as false even for the maxBuffer path, which terminates the process. Structural fix: The shared execution boundary now normalizes ERR_CHILD_PROCESS_STDIO_MAXBUFFER to killed:true. LaunchSupport preserves that owner fact; ABORT_ERR still keeps final termination/completeness explicitly unknown. Source validation: Updated the maxBuffer diagnostic regression to omit the killed property and still require killed:true; inspected both shared extractor and helper/launch consumers. Targeted formatting used pinned Node 24.18.0 with two threads; git diff --check passed. Tests, typechecks, lint, builds, provider workloads, and CI reruns were intentionally not executed at the user’s request. Authored regressions remain unexecuted. Remaining cleanup: no directly related source cleanup identified in this bounded pass. Runtime/provider behavior remains unverified by this revision. Fixed in 4d16e6a. Root cause: The merged launch envelope and helper-specific nested envelope serialized the same captured streams independently. Structural fix: The existing launch_outcome now owns the streams plus code, killed, and capture-truncation metadata. Nested helper causes retain error identity/code/signal but omit the duplicate command_outcome when the outer launch already owns it. Standalone/abort helper failures keep their meaningful envelope. Source validation: Added a single-output/redaction regression and updated the overflow boundary assertion to the single launch outcome; inspected the existing launch-failure contract and cause recursion. Targeted formatting used pinned Node 24.18.0 with two threads; git diff --check passed. Tests, typechecks, lint, builds, provider workloads, and CI reruns were intentionally not executed at the user’s request. Authored regressions remain unexecuted. Remaining cleanup: no directly related source cleanup identified in this bounded pass. Runtime/provider behavior remains unverified by this revision. |
|
Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open. Fixed publicly in 32be546. Credential redaction selected the suffix from only the initial retained tokens before mutation, so an authentication value crossing token boundaries could leave a suffix visible. Suffix selection now spans the retained token set before mutation. Producer/consumer inspection covered LaunchSupport output retention and the redaction boundary; diff whitespace review passed. Tests, builds, lint, typechecks, provider workloads, CI reruns, and real Ghidra verification were not run at the explicit user request. No directly related source cleanup remains. |
* fix(comparison): preserve incomplete function call evidence Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty. Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls. * fix(comparison): recheck historical calls-only changes --------- Co-authored-by: morluto <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8cd3edb8fe
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let redacted = | ||
| suffixLength === 0 ? text : text.slice(0, text.length - suffixLength); | ||
| for (const token of credentials) | ||
| redacted = redacted.replaceAll(token, replacement); |
There was a problem hiding this comment.
Redact overlapping full tokens before slicing the suffix
When an incomplete diagnostic contains a complete retained token that overlaps the selected credential-prefix suffix—for example, an old 64-hex token ending in c followed by characters 2–63 of a current token beginning in c—the computed 63-character suffix starts at the old token's last character. Slicing here therefore removes that last character before replaceAll runs and returns the other 63 characters of the old bearer token in the newly exposed Ghidra command output. Fresh evidence after the earlier retained-token report is that this revision now chooses the suffix globally but still performs complete-token replacement only after the destructive slice; redact matches on the original text, including intervals crossing the suffix boundary, before emitting it.
AGENTS.md reference: AGENTS.md:L13-L13
Useful? React with 👍 / 👎.
| [previous, current], | ||
| "[REDACTED]", | ||
| ), | ||
| ).toBe("[REDACTED][REDACTED]"); |
There was a problem hiding this comment.
Overlap test expects extra marker
This assertion expects two [REDACTED] markers, but redactCapturedTransportCredentials returns one. The fixture gives suffixLength 63 and cutoff 63. The complete token overlaps that cutoff, so the function moves cutoff to 0 and returns only the trailing replacement.
Both secrets are hidden, but this assertion fails and blocks the test suite. Expect one marker for the merged secret range.
| ).toBe("[REDACTED][REDACTED]"); | |
| ).toBe("[REDACTED]"); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/process/ProviderDiagnosticRedaction.test.ts
Line: 36
Comment:
**Overlap test expects extra marker**
This assertion expects two `[REDACTED]` markers, but `redactCapturedTransportCredentials` returns one. The fixture gives `suffixLength` 63 and `cutoff` 63. The complete token overlaps that cutoff, so the function moves `cutoff` to 0 and returns only the trailing replacement.
Both secrets are hidden, but this assertion fails and blocks the test suite. Expect one marker for the merged secret range.
```suggestion
).toBe("[REDACTED]");
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb8caea124
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ...(options.signal === undefined ? {} : { signal: options.signal }), | ||
| }); | ||
| } catch (cause: unknown) { | ||
| throw new GhidraLaunchSupportError(phase, cause); |
There was a problem hiding this comment.
Preserve abort reasons through the helper wrapper
When a caller aborts GhidraClient.start() with an explicit reason while -envvars or -vmargs is running, this extra wrapper changes the projected chain to AnalysisCancelledError -> GhidraLaunchError -> GhidraLaunchSupportError -> AbortError. describeCause starts at the cancellation error and, with MAX_CAUSE_DEPTH = 3, reaches the native AbortError at depth 3, so its cause (where Node preserves signal.reason) is replaced by cause_truncated; before this wrapper the supplied reason was still projected. Flatten the helper outcome or otherwise preserve the abort reason without consuming another cause level so CLI/MCP diagnostics do not drop caller-selected cancellation evidence.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
Thanks @lyly-bonbon for making LaunchSupport failures diagnosable instead of losing the JVM's output. Main now captures bounded helper output and carries the failed phase and command outcome through Ghidra error projection (main). |
Summary
Retain the output of failed Ghidra LaunchSupport commands in session diagnostics.
-envvarsand-vmargsfailures already preserve their exit code and nested cause, but stdout is dropped and stderr is only visible inside a message limited to 2 KiB.Refs #1992.
Problem and expected behavior
A LaunchSupport command that writes diagnostics and exits with code 7 should expose those diagnostics after startup cleanup. Before this change, stdout disappears; a useful reason at the end of a 3 KiB stderr stream is also lost when the error message is truncated.
Wrap the failed command at the LaunchSupport boundary and project its captured streams into
failure_cause.cause.command_outcome, with an 8 KiB UTF-8 budget per stream after credential redaction. The original command error remains the wrapper's cause, including its exit code and signal.Selected fields from the fixture's nested failure cause:
{ "name": "GhidraLaunchSupportError", "command_outcome": { "stdout": "LaunchSupport -envvars stdout diagnostic", "stdoutTruncated": false, "stderrTruncated": false, "outputTruncated": false }, "cause": { "code": 7, "signal": null } }Change and scope
Parse captured output into a typed
GhidraLaunchSupportErrorat the two LaunchSupport calls. The session projection only exposescommand_outcomefor that error type, so unrelated failures such as the Swift ownership-helper compiler retain their existing diagnostic representation.stdoutBytesandstderrBytesmeasure the captured text before redaction; they do not estimate bytes lost upstream.stdoutTruncatedandstderrTruncateddescribe the projection budget, whileoutputTruncatedrecords capture truncation. OnABORT_ERR,killedandoutputTruncatedarenull: nativeexecFilecancellation can settle before the child's exit and final stream delivery are observed.Contract and boundary impact
Evidence and regression coverage
command_outcomewas missing, then passed with the change.c2c170b3because unknown termination and capture completeness were reported asfalse. They pass with nullable fields and verify the fixture exits and its runtime is removed. Cancellation coverage stops at the production client diagnostic boundary; provider cancellation mapping is unchanged.c2c170b3because the nested command outcome duplicated the existing compiler outcome. The typed boundary prevents that duplication.For evidence-bearing changes:
Validation performed
On macOS arm64 with Node 24.18.0 and npm 11.16.0:
npm run test:focused -- src/ghidra/GhidraSessionError.test.ts tests/boundary/mcp/ghidraFailureDiagnostics.test.ts src/ghidra/GhidraRequestQueue.test.ts tests/boundary/providers/ghidra/ghidraClient.test.ts tests/boundary/providers/ghidra/ghidraLauncher.test.ts— 70 passed, 1 Windows-only test skipped.npm run check— passed, including typecheck, lint, formatting, unused-code checks, metadata and architecture guards. Lint reports warnings but no errors.git diff --check— passed.node scripts/verify-real-ghidra.mjs— could not run:GHIDRA_INSTALL_DIRis unset and this host has no configured Ghidra/JDK installation.Compatibility, safety, and release
Review checklist
type(scope): outcome.