Skip to content

fix(adb): verify pushes to long device paths - #3458

Closed
HawkForge wants to merge 7 commits into
morluto:mainfrom
HawkForge:fix/adb-push-digest-budget
Closed

HawkForge wants to merge 7 commits into
morluto:mainfrom
HawkForge:fix/adb-push-digest-budget

Conversation

@HawkForge

@HawkForge HawkForge commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3369. push-adb-file now verifies a push to a long device path. Previously, a correct sha256sum answer that exceeded the capture budget was reported as device_digest_source: "unavailable". When an answer genuinely cannot be read within its budget, the operation now returns the documented resource_constraint failure instead of an unverified success.

Problem and expected behavior

sha256sum echoes the device path after the digest, but the capture budget was a fixed 1 KiB. For a 1,142-character path, the correct checksum line exceeded it. runAdb returned AnalysisResourceConstraintError, and the push path treated every digest failure as "the device did not answer sha256sum". Callers got the same outcome as a device without sha256sum, and the reason was lost. The issue expects a correct digest to verify the transfer (docs/adb-device-analysis.md), and a capture-budget failure to remain a resource_constraint, distinguishable from an absent command.

Change and scope

In src/adb/AdbProvider.ts (pushFile):

  • The sha256sum capture budget is 1024 + 2 × byteLength(device_path). The factor of two leaves room for a sha256sum that escapes special characters in the echoed path.
  • A digest probe that fails with AnalysisResourceConstraintError is returned as that error instead of becoming "unavailable". Other failures (no sha256sum, protocol errors) keep the existing "unavailable" result and limitation.

Not included: changing what other digest failures (for example cancellation) report.

Ordinary fix within existing boundaries; scope decision not applicable. The push itself and its mutation authority are unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: ADB provider push verification.
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix).
  • CLI and MCP/tool-catalog contract: unchanged schema; an oversized digest answer now yields the existing resource_constraint error code.
  • Provider, bridge, target-format, or platform compatibility: ADB provider only.
  • Evidence, artifact, provenance, or reconstruction contract: long-path pushes report device_sha256 and device_digest_source: "device_sha256sum".
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): same adb commands and arguments; only the capture budget changes.
  • Generated metadata, package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

(The checked effects belong to the existing push_adb_file operation, which launches adb and writes the caller's file to the device; this PR doesn't add any.)

Evidence and regression coverage

  • Tests added or updated (src/adb/AdbProvider.test.ts):
    • "verifies the device-side digest for a long device path" — a stub adb answers sha256sum for a 1,132-character path built from 220-character directories (each component within the usual 255-byte limit, per review); expects device_sha256 to equal the local digest with source device_sha256sum.
    • "reports an oversized sha256sum answer as a resource constraint" — a stub answers with 8 KiB; expects a resource_constraint refusal.
  • Base reproduction or other evidence: both tests fail with the source change reverted (the first returns unavailable/null, the second succeeds). A CLI run on base with a stub adb (REA_ADB_PATH) and a 1,142-character path returned device_digest_source: "unavailable", device_sha256: null.
  • User-visible CLI/MCP output (if applicable): after the change, the same CLI run returns device_digest_source: "device_sha256sum" with the correct digest for both a 25-character and a 1,142-character path.
  • Remaining proof gaps: no live Android device or emulator was used; the producer is a local stub, as in the issue's reproduction.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • New tests with the fix reverted — both fail
  • npx vitest run src/adb tests/boundary/mcp/adbMcp.test.ts — 134 passed
  • npm run check — passed
  • node scripts/rea.mjs push-adb-file probe-device <local> <device-path> --format json with a stub adb, before/after — unavailable → device_sha256sum for the 1,142-character path (macOS arm64, Node 24.13)

Compatibility, safety, and release

  • Breaking changes or migration steps: none. A capture that overflows even the larger budget now fails with resource_constraint after the push has completed; previously it returned success with an unverified digest.
  • Real Hopper/Ghidra, browser, or OS coverage: no real device.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the capture budget grows with the caller-supplied path (bounded by its length); no new commands.

Author readiness

Human owner: @HawkForge

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@HawkForge
HawkForge marked this pull request as ready for review October 14, 2026 11:52
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

The PR gives pushFile enough room to capture a checksum line that includes a long device path.

  • ADB pushes capture enough checksum output for long device paths.

Reviews (7) · Last reviewed commit: "test(adb): keep only the long-path diges..." · Reviewed by Greptile

Comment thread src/adb/AdbProvider.test.ts Resolved
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: Both new tests fail on main and pass with this fix. A long device path no longer hides the checksum. A checksum answer that is too big now reports a resource limit.

Results

I ran the one test file the pull request changes, on a fresh build of main 62bf098.

Check Main plus this PR's tests only Main plus this PR's tests and fix
src/adb/AdbProvider.test.ts fail, 63 of 65 passed pass, 65 of 65
  • Before the fix, the long-path test saw the digest source "unavailable". It wanted the device checksum.
  • Before the fix, the oversized-answer test got a success where it wanted a refusal.
  • After the fix, both pass. The 63 older tests in the same file still pass.
  • The test uses a stub adb shell script, not a real adb or a real device.

Not run

  • No full test suite, and nothing under tests/acceptance/setup/. Some of those files run doctor.
  • No real adb and no device or emulator.
  • I did not run the pull request's own head tree. I applied its diff to main 62bf098 and ran that.
  • No type check, lint or other check scripts.
  • Real CI has not run on this head. GitHub shows only Greptile Review and PR readiness, both passed. The declaration check ran twice. One run passed. One was cancelled. The build and test workflows have not run on this head.

Thanks, HawkForge, for the fix.

Commands
export PATH=~/.local/opt/node24/bin:$PATH
git apply 3458.tests.diff        # tests only
npm run test:focused -- src/adb/AdbProvider.test.ts
git apply 3458.src.diff          # add the fix
npm run test:focused -- src/adb/AdbProvider.test.ts

Before each run I checked the file for the word doctor. It has none.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 24.18.0 (~/.local/opt/node24); vitest 5.0.3; turbo 2.11.7
  • The box was shared with other test jobs while this ran.
  • Head: 7a99a4b
  • Base: 62bf098

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

sha256sum echoes the device path, so a correct digest line for a path
near 1 KiB exceeded the fixed 1 KiB capture budget. The resulting
resource failure was then reported as device_digest_source "unavailable",
the same outcome as a device without sha256sum. Size the budget to the
path, and return a capture-budget failure as a resource constraint
instead of an unverified success.

Fixes #3369
@HawkForge

Copy link
Copy Markdown
Contributor Author

merged main in to fix the conflict. main moved the digest receipt to the object form, so the oversized-answer branch uses that now too, same messages. AdbProvider tests pass (94), and both new ones still fail without the fix.

@HawkForge

Copy link
Copy Markdown
Contributor Author

main moved again (the push target now goes through devicePath after the directory probe), so I merged it in and the digest budget is sized from devicePath now. AdbProvider tests pass (96), and the long path test still fails without the fix.

@CassieFox23

Copy link
Copy Markdown
Contributor

Update for head b79b8bc. Thanks, HawkForge, for merging main twice.

My earlier comment said real CI had not run. It has now. Source tests, Portable tests and CI required are red, but only in two files that this PR does not touch. They are src/dotnet/ManagedCilDecoding.test.ts and src/dotnet/ManagedSignatureResolution.test.ts. The base commit 23def04 fails the same 3 tests. Main's fix, 5a5bcb6, is not in this head yet.

src/adb/AdbProvider.test.ts passes in CI (96 tests). I did not re-run your new tests.

🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@HawkForge

Copy link
Copy Markdown
Contributor Author

merged main again (picks up 5a5bcb6). main now treats an oversized or timed out sha256sum answer as a failed verification by itself, so I took main's version there and this PR is down to the digest budget sized from devicePath plus the 2 tests. AdbProvider tests pass (106), the long path test still fails without the fix.

@morluto

morluto commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thank you for covering long device paths. Main now preserves checksum capacity failures as typed errors with the completed-push partial observation, which resolves the classification tracked in #3369. This PR also proposes increasing the checksum capture budget based on the selected path, so a valid long-path response can verify successfully; main at ca3fd7b still uses a fixed 1 KiB budget. I am keeping it open. If you would like to continue, could you focus the diff and tests on that remaining long-path behavior while retaining main’s partial-failure semantics? This is source-derived; I did not run an adb device in this pass.

HawkForge and others added 2 commits October 28, 2026 19:49
Main already covers an oversized checksum answer as a resource
constraint with the completed push retained.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@HawkForge

Copy link
Copy Markdown
Contributor Author

merged main in and trimmed it down. the oversized-answer test is gone since main already covers that with the completed push kept as a partial observation, and the source change is just the sha256sum budget sized from devicePath. so it's only the long-path case now: one test that fails on main and passes here. AdbProvider tests pass (106).

@HawkForge HawkForge closed this Oct 29, 2026
@HawkForge HawkForge mentioned this pull request Oct 29, 2026
17 of 22 tasks
@morluto morluto added area: tests Test suite and verification bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] ADB push reports checksum capture overflow as device unavailability

3 participants