Skip to content

fix(adb): count requested permissions that the device marks restricted - #2359

Merged
morluto merged 1 commit into
morluto:mainfrom
huiq777:fix/adb-restricted-permission-count
Oct 13, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
huiq777:fix/adb-restricted-permission-count

Conversation

@huiq777

@huiq777 huiq777 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Summary

inspect_adb_package undercounts requested_permissions_count on Android 10 and 11 devices, and still reports coverage: "complete". The count stops at the first permission the device marks as restricted.

No issue is linked: I found this while reading the dumpsys package parser, and it is an ordinary fix inside the existing ADB provider.

Problem and expected behavior

Smallest trigger: dumpsys package output in which a requested permission carries the restricted marker.

    requested permissions:
      android.permission.INTERNET
      android.permission.WRITE_EXTERNAL_STORAGE: restricted=true
      android.permission.CAMERA
    install permissions:

On Android 10 and 11, Settings.dumpPackageLPr appends : restricted=true to every hard- or soft-restricted entry of that list (android11-release Settings.java; android10-release prints it too). The android12-release, android13-release and android14-release branches no longer print it.

parseDumpsysPackageOutput accepted only bare names (/^\s{2,}[A-Za-z0-9._]+$/), so the marked line ended the section and the permissions after it were not counted. The example above gives 1; the list holds 3. The provider's own limitation text says "requested_permissions_count counts the listed requested permissions section only".

Expected: every entry of the section is counted, with or without the marker.

Change and scope

The entry pattern in src/adb/AdbShellOutput.ts now also accepts the exact : restricted=true suffix. Nothing else about section detection changes, so the following install permissions: lines (NAME: granted=true) are still outside the count.

Not included: the parser adds up every requested permissions: section it meets. I did not verify whether real output repeats that header for one package, so I left that alone.

Follow the contribution scope.
Scope decision: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: parseDumpsysPackageOutput in src/adb/AdbShellOutput.ts.
  • Contribution scope fit and linked maintainer decision: parser fix within the existing ADB provider; not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. requested_permissions_count is higher on affected devices.
  • Provider, bridge, target-format, or platform compatibility: ADB provider; changes results only for output that contains the marker (Android 10 and 11).
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): 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: one case in src/adb/AdbProvider.test.ts that runs the output above through inspect_adb_package with the existing adb stub and expects a count of 3.

  • Base reproduction or other evidence (executed): without the fix the new test gets 1. The output format is source-derived from the AOSP branches named above.

  • User-visible CLI/MCP output (executed with REA_ADB_PATH pointing at a stand-in adb that prints the output above), for rea inspect-adb-package emulator-5554 com.example:

    before (4dd44dd):  requested_permissions_count: 1, coverage: complete
    after:             requested_permissions_count: 3, coverage: complete
    
  • Remaining proof gaps: not run against a real Android 10 or 11 device; the fixture follows the AOSP printing code.

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

macOS 15.6.1 arm64, Node 24.18.0, npm 11.16.0.

  • npm run test:local -- src/adb/AdbProvider.test.ts — 48 passed
  • npx vitest run src/adb — 5 files, 104 tests passed
  • npm run test:focused -- tests/boundary/cli/adbCli.test.ts tests/boundary/mcp/adbMcp.test.ts tests/boundary/mcp/adbStartMcp.test.ts tests/boundary/process/adbDirectoryListing.test.ts tests/boundary/providers/adb/adbBugreportPublication.test.ts — 5 files, 21 tests passed
  • npm run check — passed
  • npm run check:fast — passed

Not run: npm run check:pr, npm run docs:check (no contract or generated metadata changes), and no real-device lane.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; parsing only.

This touches src/adb/AdbProvider.test.ts like #2344 and #2354, in a different place; I will rebase whichever lands later.

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.

AI assistance (Claude Code, model Claude Opus 5.5) was used for investigation, implementation and running the tests locally.

🤖 Generated with Claude Code

Android 10 and 11 print restricted entries of the requested-permissions
list as "NAME: restricted=true". The parser took the first such line as
the end of the list, so the count stopped there while coverage still
read complete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

parseDumpsysPackageOutput now counts requested permissions with the exact : restricted=true suffix without skipping later entries.

  • Package inspection counts restricted requested permissions.

Tests were inspected, not run.

Reviews (1) · Last reviewed commit: "fix(adb): count requested permissions th..." · Reviewed by Greptile

@morluto
morluto merged commit 15463bd into morluto:main Oct 13, 2026
3 checks passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants