Repository navigation
Conversation
pull_adb_package derived each host file name from the last segment of a device-reported `pm path` entry and joined it to the package output directory. A hostile or broken device could report `..`, `.`, an empty segment, backslash separators, NUL, or control characters and steer the pull outside the package directory or alias another file. parsePmPathOutput now validates every derived file name against `^[A-Za-z0-9][A-Za-z0-9._-]*\.apk$` and reports failures in `rejectedPaths` with the raw device path and a specific reason instead of returning them as pullable entries. The provider refuses the whole pull with an AnalysisProtocolError (`unreadable_output`) before creating any host directory or invoking `adb pull`; the message names the JSON-escaped raw device path and the error retains the `pm path` output as captured evidence. Names are never rewritten. Validation: parser cases for `..`, `.`, empty, backslash, NUL, ESC, hidden and non-APK names; provider stub test asserting no pull runs and no output directory is created. Real-device lane not re-run; ordinary `base.apk`, `split_*.apk`, and system module names are unaffected.
Codex Review Summary: ✅ CompletedThis 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: 8cb18a33e5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Addresses two review findings on the pm path file-name validation.
Ordering: when `pm path` printed only an unsafe entry, for example
`package:/data/app/x/..`, both `paths` and `unparsedLines` were empty, so
the legacy empty-output guard returned AnalysisUnsupportedTargetError
("may not be installed") and dropped the raw path and captured output.
The rejected-path check now runs before the empty/unparsed guards, so any
rejected entry fails the pull as `unreadable_output` with the
JSON-escaped device path in the message and the `pm path` output as
captured evidence.
Source-exact paths: each line was trimmed before matching, so a hostile
entry such as `package:/data/app/x/base.apk\t` was accepted as `base.apk`
and `adb pull` ran against a path different from the one reported. The
parser now strips only the protocol line terminator (`\n` or `\r\n`),
matches `^package:(.+)$` on the untrimmed line, keeps the device path
byte-for-byte, and rejects any path containing whitespace or control
characters (`\s`, `\p{Cc}`, including NUL, C1 controls and a stray `\r`).
Whitespace before the `package:` prefix is no longer trimmed away and the
line is reported as unrecognized. Lines that are entirely blank are still
skipped.
Validation: parser cases for trailing tab, trailing space, leading space
in the path, a space inside a directory, a C1 control, a leftover `\r`
from `\r\r\n`, an indented `package:` line, and CRLF output that must
still parse; provider stub tests where the only entry is `..` or has a
trailing space assert `unreadable_output`, no `adb pull`, and no output
directory. The new cases fail on the previous commit.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d78a26ab7b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Addresses two further review findings on the pm path file-name policy. Case-folded aliases: on Windows and default macOS volumes, a hostile listing with distinct APKs named `base.apk` and `BASE.apk` passed the host file-name pattern, and the pull loop's duplicate guard compared exact strings, so the second pull could replace bytes already digested for the first while both artifacts were reported as complete. The provider now refuses the whole pull, before the package directory is created or any `adb pull` runs, when two entries' file names differ as strings but are equal under case folding or NFC/NFKC normalisation. The refusal is an AnalysisProtocolError (`unreadable_output`) that names both raw device paths and retains the `pm path` output. The check is deliberately host-independent rather than probing the destination filesystem, so the same listing yields the same evidence wherever REA runs. Exact repeats keep the existing per-file overwrite refusal. Reserved device names: `NUL.apk`, `con.apk`, `COM1.apk`, `lpt9.apk` and similar matched the pattern even though Win32 resolves those basenames to a device regardless of extension. The reserved-name predicate used by webScriptExportPlan is extracted to src/domain/windowsReservedFileName.ts and both call sites use it; pm path entries with such names are rejected case-insensitively on every host, with the same tagged error. Tests cover the alias pair (case and Unicode forms), reserved names with and without extensions, near misses (`console.apk`, `com10.apk`), and a lone mixed-case `Base.apk` that is still pulled unchanged.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa4a00ffcd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ac0b0b643
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…e normalization alias A pm path entry such as /data/a\u034F/base.apk passed the device-path check: U+034F COMBINING GRAPHEME JOINER, the Hangul fillers (U+115F, U+3164, U+FFA0) and variation selectors are default-ignorable but not Cf, so neither \s nor Cc/Cf/Cs/Co matched them and displayDevicePath left them unescaped. Reject every Default_Ignorable_Code_Point and Noncharacter_Code_Point anywhere in the path, and escape default-ignorables in the caller-facing message. Both properties are stable across Unicode versions, unlike the unassigned set, so the same listing is refused the same way on every runtime. parsePmPathOutput admits only ASCII [A-Za-z0-9._-] file names, for which NFKC is the identity, so normalization_alias could never be returned. Reduce the collision key to an ASCII case fold, drop the normalization_alias reason, its synthetic test, and the docs mention.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc9290c4bb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
dandgabr
left a comment
There was a problem hiding this comment.
Review findings
P2 — Preserve or reject a CR immediately before LF
src/adb/AdbDeviceOutput.ts splits with /\r?\n/, so a carriage return at the end of a device-reported path is consumed as CRLF before unsafeDevicePathReason validates it. For example, if pm path emits package:/data/app/x/base.apk\r\n with the CR belonging to the path and LF as the record terminator, the parser accepts /data/app/x/base.apk and the provider pulls that altered path. This bypasses the control-character refusal and can select a different remote file while recording the altered path as evidence. Preserve the raw payload through validation: split on LF if that is the guaranteed ADB framing, then reject any remaining CR; otherwise reject this ambiguous record rather than silently normalizing it.
…urns
parsePmPathOutput split records on /\r?\n/, so a CR that belonged to a
device path (package:/data/app/x/base.apk\r\n with LF as the terminator)
was consumed as CRLF framing before unsafeDevicePathReason saw it. The
pull then targeted /data/app/x/base.apk, a different remote file, and
recorded that altered path as evidence.
Framing evidence: REA runs `adb shell pm path PKG` through execFile with
piped stdin. On a device with the shell v2 protocol, adb defaults to a
raw (non-PTY) session whenever a command is given, so output is LF-only.
On a device without shell v2 (Android 6 and earlier) adb always asks for
a remote PTY, whose output translation rewrites LF as CRLF, so CRLF
framing was possible and indistinguishable from a path-owned CR. No
fixture or documented compatibility relied on CRLF output.
Rule chosen: make the framing unambiguous at the source. pm path now
runs as `adb shell -T pm path PKG`. -T forbids a remote PTY; a device
that only supports a PTY shell makes adb refuse the command ("device
only supports allocating a pty"), which is now reported as
unsupported_target before any host directory exists. Every accepted
listing is therefore raw LF-framed output, and the parser splits on LF
only: any remaining U+000D stays in the device path and is refused as
whitespace_or_control with the raw path and the captured output. A
record that holds only a CR is reported as unparsed instead of being
skipped as blank.
Tests cover the reviewer example, a double CR, uniform CRLF, mixed
framing, a final CR without LF, LF-only parsing, the exact pm path argv,
the legacy PTY-only device refusal, and CLI and MCP projections of the
CR refusal with no pull and no host directory.
|
Thanks @dandgabr, this was a real hole: splitting on |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ffdd9e49a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Upstream now validates pm path file names itself (55b6148, 1d4c4eb): AdbHostFileName derives the final POSIX segment and applies only the selected host's rules, duplicate names are refused before output, and exact-name mkdir reservations detect case and Unicode aliases on the real destination volume. Conflicts were resolved by taking upstream's AdbDeviceOutput, AdbProvider, their tests and adbCli tests, and the following parts of this branch were dropped as superseded or contrary to upstream's design: the portable APK name pattern, the case-fold alias check applied on every host, the shared Windows reserved-name helper, the format/default-ignorable character rejection, the fake adb fixture, and the adb shell -T / LF-only framing (upstream deliberately treats CRLF as framing and accepts any valid POSIX name). Kept as the remaining delta: AnalysisOutputError carries an optional caller message, remediation and structured diagnostics that the error projection publishes under details.diagnostics. pull_adb_package uses them for upstream's three pm path refusals (unsafe_device_path, duplicate_local_destination, local_destination_unavailable with the filesystem error code), so callers get the refused raw device paths and actionable guidance instead of the generic unreadable-output message, and refusal prose escapes invisible and bidi code points.
|
Upstream main (55b6148, 1d4c4eb) now validates |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c3a5cf18f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@greptileai review |
[Medium impact] The PR appears safe to merge, with no outstanding findings. SummaryThis PR gives callers useful details when
Reviews (10) · Last reviewed commit: "test(managed): split operand coverage gr..." · Reviewed by Greptile |
Preserve LF-framed Package Manager paths, refuse hidden/control path characters and oversized host filenames before pulls, preserve output-error fields through explicit redaction, and escape the blank braille cell in display. Existing destination reservation owns case/Unicode alias detection. Source inspection and git diff --check; tests/builds/typechecks/CI reruns skipped at explicit user request.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a53a80e9a9
ℹ️ 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".
Merge pinned main and preserve its common error context owner. Update package-pull stub argv and refusal assertions, enforce host-specific filename length, and parse the exact Package Manager payload after LF framing. Source inspection and git diff --check only. Tests, builds and typechecks skipped by explicit user request. GitHub review writes paused globally.
Merge pinned main and preserve its common error context owner. Update package-pull stub argv and refusal assertions, enforce host-specific filename length, and parse the exact Package Manager payload after LF framing. Source inspection and git diff --check only. Tests, builds and typechecks skipped by explicit user request. GitHub review writes paused globally.
|
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. Malformed UTF-8 previously became a generic protocol error with no stable public reason. The producer now returns an invalid_utf8 AnalysisOutputError with explicit remediation and base64-preserved source bytes; adapters retain the tagged reason. Source inspection followed error projection and captured output; git diff --check passed. Regression source was added but not run. Rejected paths were fully escaped into caller-facing prose, expanding a bounded adb response into a large error. The shared display owner now limits the excerpt to 160 source characters while structured diagnostics retain the complete path. Source inspection followed parser, display helper, and CLI/MCP error projection; git diff --check passed. Regression source was added but not run. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c5b8a6b4a
ℹ️ 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".
|
Thanks a lot for picking this up and for the follow-up commits. I'll leave the branch in your hands from here and won't push anything else to it unless you ask me to. Happy to help with any of the open threads if that would be useful. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a03ffac072
ℹ️ 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".
|
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. Status: Source fix pushed; public head verified with gh pr view. Validation is source-only; no tests/builds/checks/CI reruns were run. Root cause, owner-level fix, and any residual cleanup are recorded in the per-PR result. This is not a claim of exact CI reproduction. |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
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. The refusal chose its remediation based on whether any entry had a protocol violation, while the message described only the first entry. A mixed listing could therefore conceal the second policy that also prevents the pull. The producer now classifies protocol and host filename refusal classes across the complete rejected set and reports combined user guidance when both occur; a source regression covers host-first mixed input and verifies that no pull runs. Targeted formatting and |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 814e3e6f25
ℹ️ 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: Main already explains why a file name is refused. That came in with d4bd65c. So head 814e3e6 adds less than the title says. What is left is new: head refuses paths with a space, a tab or a bidi character, which main still tries to pull. The PR description says the accepted paths do not change, so it needs an update. Edit (7 Nov): I ran this PR at head 5f68b2a in a VM, and the results are here. I used a fake adb script, not a real device. Head conflicts with main af6a998 today, so I tested head as pushed and main separately. ResultsEach row ran
On main, the space, tab and bidi rows reach PR test files (5 files, 144 tests): on head, 143 pass and 1 fails on both Nodes. On main, the same 5 files pass (151 tests). The failing test is "reports both path policies for mixed host and protocol refusals". The test has a bug, not the code: with one line fixed in a scratch copy, all 63 tests in its file pass on Node 24. The format check also flags Not run
Thanks, larinyo, for the PR, and thanks, morluto, for the follow-up commits. Test file detailsThe failing test uses a variable before it exists. Node says "Cannot access 'root' before initialization" at line 602 of
The CI run on this head also failed test shards 1 and 4 and the Static checks job. Those match the failures I reproduced here. I read that from the CI logs and did not rerun CI. The author said in a comment that the Test setupCommandsThe build and test runs sat under 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
TL;DR: I ran head 814e3e6 and main on a real tablet. Both found the same APK paths and pulled byte-identical files. No real path on this tablet hit a refusal. So the new refusals only matter for odd paths. This follows my earlier comment, which used a fake adb. Main has moved since then. This run used main 4692bb3, not af6a998. ResultsI ran
What matched the fake adb runPlain paths pull the same on head and main, as the fake run showed. The fake run showed one more thing: head sends What the fake run could not showA split app and a system app both pull on head and on main. The fake run had no split app. The tablet reports the same paths with Still not run
Test setupCommands
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f68b2ac73
ℹ️ 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".
| it("refuses a payload CR without treating it as transport framing", () => { | ||
| const devicePath = "/data/app/base.apk\r"; | ||
| expect(parsePmPathOutput(`package:${devicePath}\n`).rejectedPaths).toEqual([ | ||
| { device_path: devicePath, reason: "unsupported_protocol_character" }, |
There was a problem hiding this comment.
Make the CR rejection expectation platform-aware
When this source test runs on Windows, adbHostFileName also rejects the trailing CR as unsupported_character, so parsePmPathOutput correctly includes additional_reasons: ["unsupported_character"] in the rejected entry. This unguarded, exact toEqual assertion omits that field and therefore fails on Windows despite correct parser behavior. Account for the Windows host-validation reason in the expected record rather than assuming the POSIX result.
Useful? React with 👍 / 👎.
|
TL;DR: I ran head 5f68b2a in a VM. The 5 changed test files pass on Node 22, 24 and 26, including the file whose test failed on 814e3e6. This follows my review above. I used a fake adb script, not a real device. No test job ran in CI on this head. Only three checks ran. Greptile passed. PR readiness and the author check both failed. GitHub still shows the branch as conflicting with main 015a02d, and I did not merge it. Results
The format check (oxfmt) on the 13 changed files passes on Node 24. Each fake row ran
Thanks, morluto, for the two new commits. The dot segment now shows in the details. The test and format failures I saw are gone. Still not run
Test setupCommandsThe fake adb answers 🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊 |
|
Thank you for this fix! Actionable |
Summary
pull_adb_packagealready refuses unsafe or collidingpm pathentries onmain(55b6148, 1d4c4eb), but every refusal reaches CLI and MCP callers as the generic "unreadable result / runrea doctor" message, becauseAnalysisOutputErrormessages are replaced during projection. A caller cannot see which device path was refused or why, even though the provider knows.The original three refusal diagnostics are already on current main. This branch additionally uses strict UTF-8 decoding and LF framing, and rejects protocol characters including whitespace; current main preserves whitespace in POSIX paths. That admission difference and its evidence need reconciliation before integration.
Behaviour change
For the three existing
pm pathrefusals (unrepresentable host file name, duplicate local destination, destination reservation failure), the projected error now carries:details.reason:unsafe_device_path,duplicate_local_destinationorlocal_destination_unavailable;details.diagnosticswith the raw refuseddevice_pathvalues, the derivedfile_name, a per-entry reason and, for reservation failures, the filesystem error code;details.diagnosticsanddetails.captured_outputinstead of "retry / runrea doctor".codestaysunreadable_output,retryablestaysfalse, andcaptured_outputis retained. Device paths in the human-readable message are escaped (\u{202E}and similar) so bidi or invisible code points cannot reorder the rendered text;detailskeeps the raw values.Change and scope
src/domain/analysisErrorCore.ts,analysisErrorProjection.ts,analysisErrorPresentation.ts:AnalysisOutputErroraccepts optionaluserMessage,remediationActionanddiagnostics, following the existing pattern ofProviderAdapterErrorandAnalysisUnsupportedTargetError. The error schema is unchanged becausedetailsis an open record.src/adb/AdbProvider.ts: the three refusals use those fields.src/adb/AdbDeviceOutput.ts:displayDevicePathescaping helper.docs/adb-device-analysis.md: documents the projected fields.History note: earlier commits on this branch added their own name validation, case-fold and reserved-name checks, control-character rejection and
adb shell -Tframing.mainhas since solved the same problem with host-specific rules and destination reservations, so the merge ofmaindrops all of that in favour of upstream's design. Thanks to @dandgabr and the Codex reviews for the findings along the way.Validation
After
b1eab18542and5f68b2ac73: 84 ADB source tests, 4 MCP boundary tests, 72 managed tests, typecheck, targeted formatting and the fullcheck:fastpre-push gate passed with this branch's locked dependencies. One path can now retain both protocol and host filename refusals. A pre-existing managed test group was split to clear the gate without removing cases. No real Android device was used.New domain projection tests for the
AnalysisOutputErrorfields.Provider tests assert the projected reason, diagnostics and messages for each refusal, with no pull and no host directory created.
tests/boundary/mcp/adbMcp.test.tsasserts the details reach MCP callers.npx vitest run src/adb src/domain tests/boundary/mcp/adbMcp.test.ts tests/boundary/cli/adbCli.test.ts: 2213 tests pass.tsc,oxlint, module boundaries, format anddocs:checkare clean.Limits
No real Android device was used. The branch's whitespace rejection differs from current main and is not established by real Package Manager evidence; strict decoding and framing also remain separate from the diagnostics already on main.