[PR #4670] [CLOSED] fix(adb): report unknown requested permissions when package details are unavailable #6354

Closed
opened 2026-10-31 01:13:48 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4670
Author: @akram1089
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: fix/4654-adb-package-unavailable-permissions


📝 Commits (2)

  • bec00a4 fix(adb): report unknown requested permissions when package details are unavailable
  • af32b3c fix(adb): deduplicate pkg=null match in dumpsys parser

📊 Changes

4 files changed (+105 additions, -4 deletions)

View changed files

📝 src/adb/AdbProvider.test.ts (+30 -0)
📝 src/adb/AdbProvider.ts (+10 -2)
📝 src/adb/AdbShellOutput.test.ts (+55 -0)
📝 src/adb/AdbShellOutput.ts (+10 -2)

📄 Description

Summary

Fixes #4654.

When inspecting an Android package whose parsed package is unavailable in Package Manager (pkg=null in dumpsys package output, such as when an adopted storage volume is ejected), inspect-adb-package / inspect_adb_package previously asserted a known-zero requested_permissions_count: 0 and coverage: "complete". This PR parses pkg=null as an unavailable package definition, returning requested_permissions_count: null, coverage: "partial", and an explicit limitation explaining that package details are unavailable on the device.

Problem and expected behavior

  • Prior behavior: parseDumpsysPackageOutput initialized permissions = 0 and only checked for the requested permissions: header. When Android skipped the section because ps.pkg == null, the parser reported requestedPermissions: 0 and coverage: "complete", conflating an unavailable package record with a known-empty permission list.
  • Expected behavior: Unresolved applicability and unknowns must survive normalization. If pkg=null is reported and no requested permissions section exists, requested_permissions_count must be reported as null with coverage: "partial" and an explanatory limitation, while retaining 0 for loaded packages with empty requested permissions.

Change and scope

  • src/adb/AdbShellOutput.ts: in parseDumpsysPackageOutput, track parsedPackageUnavailable on pkg=null and seenPermissionsSection. If the parsed package is unavailable and no permissions section is present, return requestedPermissions: null.
  • src/adb/AdbProvider.ts: in the inspect_adb_package handler, treat details.requestedPermissions === null as coverage: "partial" and replace the listed-section limitation with "Package details are unavailable on device; requested_permissions_count is unknown".
  • src/adb/AdbShellOutput.test.ts: added test suite for parseDumpsysPackageOutput covering the pkg=null unavailable case, loaded-empty case (0), and populated permissions case (2).
  • src/adb/AdbProvider.test.ts: added provider test asserting requested_permissions_count: null, coverage: "partial", and the limitation when pkg=null.

Contract and boundary impact

  • Semantic owner and earliest changed stage: ADB shell dumpsys package parser (src/adb/AdbShellOutput.ts) and provider projection (src/adb/AdbProvider.ts)
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing provider boundaries)
  • CLI and MCP/tool-catalog contract: none (requested_permissions_count in adbDeviceAnalysis.ts already allows z.number().int().nonnegative().nullable())
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: preserves explicit null unknown for unavailable records
  • Target selection, authority, upstream behavior, and cleanup details: not applicable
  • Generated metadata (docs/public/product-catalog.json), 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.

Evidence and regression coverage

  • Tests added or updated:
    • parseDumpsysPackageOutput > reports requestedPermissions as null when package details are unavailable (pkg=null)
    • parseDumpsysPackageOutput > reports requestedPermissions as 0 for a loaded package with an empty requested permissions section
    • parseDumpsysPackageOutput > counts requested permissions when present in dumpsys output
    • reports requested_permissions_count as null and coverage as partial when pkg=null in AdbProvider.test.ts
  • Base reproduction: verified reproduction in Vitest where the unavailable fixture failed with requestedPermissions: 0 instead of null.
  • User-visible CLI/MCP output:
    {
      "version_code": "45",
      "version_name": null,
      "requested_permissions_count": null,
      "coverage": "partial"
    }
    
  • Remaining proof gaps: none

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

  • npm run test:local -- src/adb/AdbShellOutput.test.ts — passed (13 passed)
  • npm run check:fast — passed (turbo typecheck and lint clean)

Compatibility, safety, and release

  • Breaking changes or migration steps: none (requested_permissions_count was already declared nullable in the output schema)
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (ADB output parser & provider boundary)
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: no new external access or execution; preserves device output provenance

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4670 **Author:** [@akram1089](https://github.com/akram1089) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/4654-adb-package-unavailable-permissions` --- ### 📝 Commits (2) - [`bec00a4`](https://github.com/morluto/rea/commit/bec00a417fc27e9172ebed7aaa3885fd301ebca0) fix(adb): report unknown requested permissions when package details are unavailable - [`af32b3c`](https://github.com/morluto/rea/commit/af32b3c9a1cd4a84ac6e7f1f9f2e2d617a5916ed) fix(adb): deduplicate pkg=null match in dumpsys parser ### 📊 Changes **4 files changed** (+105 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/adb/AdbProvider.test.ts` (+30 -0) 📝 `src/adb/AdbProvider.ts` (+10 -2) 📝 `src/adb/AdbShellOutput.test.ts` (+55 -0) 📝 `src/adb/AdbShellOutput.ts` (+10 -2) </details> ### 📄 Description ## Summary Fixes #4654. When inspecting an Android package whose parsed package is unavailable in Package Manager (`pkg=null` in `dumpsys package` output, such as when an adopted storage volume is ejected), `inspect-adb-package` / `inspect_adb_package` previously asserted a known-zero `requested_permissions_count: 0` and `coverage: "complete"`. This PR parses `pkg=null` as an unavailable package definition, returning `requested_permissions_count: null`, `coverage: "partial"`, and an explicit limitation explaining that package details are unavailable on the device. ## Problem and expected behavior - **Prior behavior**: `parseDumpsysPackageOutput` initialized `permissions = 0` and only checked for the `requested permissions:` header. When Android skipped the section because `ps.pkg == null`, the parser reported `requestedPermissions: 0` and `coverage: "complete"`, conflating an unavailable package record with a known-empty permission list. - **Expected behavior**: Unresolved applicability and unknowns must survive normalization. If `pkg=null` is reported and no requested permissions section exists, `requested_permissions_count` must be reported as `null` with `coverage: "partial"` and an explanatory limitation, while retaining `0` for loaded packages with empty requested permissions. ## Change and scope - `src/adb/AdbShellOutput.ts`: in `parseDumpsysPackageOutput`, track `parsedPackageUnavailable` on `pkg=null` and `seenPermissionsSection`. If the parsed package is unavailable and no permissions section is present, return `requestedPermissions: null`. - `src/adb/AdbProvider.ts`: in the `inspect_adb_package` handler, treat `details.requestedPermissions === null` as `coverage: "partial"` and replace the listed-section limitation with `"Package details are unavailable on device; requested_permissions_count is unknown"`. - `src/adb/AdbShellOutput.test.ts`: added test suite for `parseDumpsysPackageOutput` covering the `pkg=null` unavailable case, loaded-empty case (`0`), and populated permissions case (`2`). - `src/adb/AdbProvider.test.ts`: added provider test asserting `requested_permissions_count: null`, `coverage: "partial"`, and the limitation when `pkg=null`. ## Contract and boundary impact - Semantic owner and earliest changed stage: ADB shell dumpsys package parser (`src/adb/AdbShellOutput.ts`) and provider projection (`src/adb/AdbProvider.ts`) - Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing provider boundaries) - CLI and MCP/tool-catalog contract: none (`requested_permissions_count` in `adbDeviceAnalysis.ts` already allows `z.number().int().nonnegative().nullable()`) - Provider, bridge, target-format, or platform compatibility: none - Evidence, artifact, provenance, or reconstruction contract: preserves explicit null unknown for unavailable records - Target selection, authority, upstream behavior, and cleanup details: not applicable - Generated metadata (`docs/public/product-catalog.json`), 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. - [x] 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. ## Evidence and regression coverage - Tests added or updated: - `parseDumpsysPackageOutput > reports requestedPermissions as null when package details are unavailable (pkg=null)` - `parseDumpsysPackageOutput > reports requestedPermissions as 0 for a loaded package with an empty requested permissions section` - `parseDumpsysPackageOutput > counts requested permissions when present in dumpsys output` - `reports requested_permissions_count as null and coverage as partial when pkg=null` in `AdbProvider.test.ts` - Base reproduction: verified reproduction in Vitest where the unavailable fixture failed with `requestedPermissions: 0` instead of `null`. - User-visible CLI/MCP output: ```json { "version_code": "45", "version_name": null, "requested_permissions_count": null, "coverage": "partial" } ``` - Remaining proof gaps: none For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- src/adb/AdbShellOutput.test.ts` — passed (13 passed) - `npm run check:fast` — passed (turbo typecheck and lint clean) ## Compatibility, safety, and release - Breaking changes or migration steps: none (`requested_permissions_count` was already declared nullable in the output schema) - Real Hopper/Ghidra, browser, or OS coverage: not applicable (ADB output parser & provider boundary) - Package or release metadata impact: none - Security, privacy, process, or containment review: no new external access or execution; preserves device output provenance ## Before merge <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:13:48 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6354
No description provided.