Skip to content

fix(apktool): resolve Windows PATH launchers before invocation - #2802

Merged
morluto merged 3 commits into
mainfrom
codex/fix-apktool-windows-launcher-review
Oct 13, 2026
Merged

morluto merged 3 commits into
mainfrom
codex/fix-apktool-windows-launcher-review

Conversation

@morluto

@morluto morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

When REA_APKTOOL_COMMAND is unset on Windows, the documented PATH fallback retained the bare apktool name. The invocation boundary could not see a Chocolatey .bat/.cmd launcher and tried to launch it directly with execFile.

Resolve the Windows fallback through the selected PATH/PATHEXT before choosing process creation. Both version probing and decoding reuse the resolved selection and the provider's canonical environment snapshot. Explicit launcher paths retain their source spelling; native executables retain direct argv handling. Missing candidates, inaccessible candidates, malformed extension values and cancellation retain distinct outcomes.

Added unrun regressions for PATH/PATHEXT ordering, mixed-case environment keys, quoted PATH directories, batch version/decode invocations, native arguments, explicit paths, missing/directory/inaccessible candidates, malformed extensions and cancellation. Source inspection, formatting with two threads, and git diff --check only: tests, builds, check reruns and real Windows/Apktool verification were skipped at the maintainer's explicit request. Performance was not measured.

Follow-up to the release review thread. This completes the PATH case of the Windows batch-launcher work contributed by @kaoru0822-kitauji in #1777, originally reported by @psipher in #1774. The release thread remains open pending integration and verification.

References: Node's Windows batch-launcher contract, Windows PATH search, current-directory search control.

Resolve the default launcher through the selected PATH/PATHEXT before choosing native process creation or the existing conservative cmd.exe wrapper. Reuse the resulting selection and one canonical environment for the version probe and decode.

Follow-up to the release #1693 review of #1777. Source inspected and formatted; tests, builds, check reruns and real Windows Apktool execution were skipped at maintainer request.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T13:37:42.525030Z 3e58af6 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High impact] The PR appears safe to merge based on the reviewed code, with both previous findings addressed.

Summary

Resolves Windows PATH launchers before choosing direct execution or cmd.exe.

  • Windows Apktool finds PATH launchers before probing or decoding.
  • Each Apktool operation uses its own environment snapshot.
  • Analysis, Ghidra, and IDA use the shared wait helper from the process layer.

Source review only. Tests, builds, and real Windows verification were not run. A superseding PR could not be checked because GitHub access was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Capture operation environment] --> B{Explicit launcher?}
  B -->|Yes| C[Preserve launcher path]
  B -->|No, Windows| D[Search PATH and PATHEXT]
  B -->|No, POSIX| E[Use bare apktool name]
  D -->|Cancel or deadline| F[Return interruption]
  D -->|Found| C
  C --> G{Batch launcher?}
  G -->|Yes| H[Use guarded cmd.exe arguments]
  G -->|No| I[Use direct arguments]
  E --> I
  H --> J[Probe version]
  I --> J
  J --> K[Decode with same selection and environment]
Loading

Reviews (2) · Last reviewed commit: "fix(apktool): use supported timeout diag..." · Reviewed by Greptile

Comment thread src/apktool/ApktoolProvider.ts Resolved
Comment thread src/apktool/ApktoolConfiguration.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0ea32d3a3

ℹ️ 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".

Comment thread src/apktool/ApktoolProvider.ts Resolved
Source inspection and targeted formatting only. Tests, builds, lint, typechecks and provider workloads were not run at the user's explicit request.
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e58af6cec

ℹ️ 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".

Comment on lines +109 to +110
if (metadata.isFile())
return { command: candidate, commandSource: "path" };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip PATHEXT entries the launcher cannot execute

When a Windows PATHEXT includes another script type such as .PS1 ahead of .BAT, and both files exist in the same PATH directory, this returns the .PS1 candidate. apktoolInvocation only routes .bat/.cmd through an interpreter; every other suffix reaches execFileOutput directly, while execFile() spawns directly without a shell. The probe therefore fails on the first unsupported script instead of continuing to the runnable batch launcher; restrict selection to supported native/batch suffixes or explicitly model the other interpreter types.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

Retain lookup phase through AnalysisErrorOptions diagnostics while preserving the operation and timeout identity. Source inspection and targeted formatting only; tests, checks, builds and provider workloads were skipped at the user request.
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner Author

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.

  1. thread 1

The constructor had combined host settings with the caller map before launcher selection, restoring an omitted REA_APKTOOL_COMMAND. Fixed in 3e58af6: provider state now owns only the selected map. Each operation samples current child inheritance and explicitly preserves the selected launcher value, including omission selecting PATH. The same operation environment and resolved command feed probe and decode, so consumers do not reinterpret the launcher. Added unrun regressions for an explicit empty map versus an ambient launcher and for changing/removed inherited values. Removed the former selection wrapper and stored merged environment. Validation was source inspection only; the touched files were formatted with the pinned toolchain (two formatter threads). Tests, builds, lint, typechecks, provider workloads and CI reruns were not run, as explicitly requested.

  1. thread 1

The filesystem await was outside cancellation and timeout ownership. Fixed in 3e58af6: one 20-second selection deadline bounds the entire Windows PATH search, and each pending stat races the deadline/caller signal through the shared abortable-promise primitive. Cancellation and timeout remain tagged analysis failures; listeners/timer are disposed and late filesystem rejection remains observed. The underlying OS metadata operation can still finish later, but requests and close no longer wait for it. Moved the generic primitive from binary application code into src/process and updated every consumer (binary evaluation/lazy loading, Ghidra and IDA), retaining a single implementation. Added unrun pending-stat cancellation/late rejection and deadline regressions. Validation was source inspection only; the touched files were formatted with the pinned toolchain (two formatter threads). Tests, builds, lint, typechecks, provider workloads and CI reruns were not run, as explicitly requested.

  1. thread 1

The provider retained a constructor-time copy of the whole ambient environment, which could preserve removed or rotated values. Fixed in 3e58af6: long-lived state contains only caller-selected variables. Ambient inheritance is sampled at each operation boundary and retained only for that operation; version and decode share the resulting snapshot. An explicit caller map remains authoritative for launcher selection. Added unrun regressions exercising rotated and removed inherited values and a default launcher changed after construction. The stored merged environment and selection wrapper were removed; no ambient snapshot is added to Evidence. Validation was source inspection only; the touched files were formatted with the pinned toolchain (two formatter threads). Tests, builds, lint, typechecks, provider workloads and CI reruns were not run, as explicitly requested.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner Author

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.

  1. thread 1

The constructor had combined host settings with the caller map before launcher selection, restoring an omitted REA_APKTOOL_COMMAND. Fixed in 3e58af6: provider state now owns only the selected map. Each operation samples current child inheritance and explicitly preserves the selected launcher value, including omission selecting PATH. The same operation environment and resolved command feed probe and decode, so consumers do not reinterpret the launcher. Added unrun regressions for an explicit empty map versus an ambient launcher and for changing/removed inherited values. Removed the former selection wrapper and stored merged environment. Validation was source inspection only; the touched files were formatted with the pinned toolchain (two formatter threads). Tests, builds, lint, typechecks, provider workloads and CI reruns were not run, as explicitly requested. Follow-up e31e1fc corrects the confirmed TS2353 from the existing remote logs: timeout phase context now uses supported AnalysisErrorOptions.diagnostics rather than userMessage. The standard timeout operation/tag/duration remain unchanged. Source inspection/formatting only; no CI rerun or post-push result was requested or claimed.

  1. thread 1

The filesystem await was outside cancellation and timeout ownership. Fixed in 3e58af6: one 20-second selection deadline bounds the entire Windows PATH search, and each pending stat races the deadline/caller signal through the shared abortable-promise primitive. Cancellation and timeout remain tagged analysis failures; listeners/timer are disposed and late filesystem rejection remains observed. The underlying OS metadata operation can still finish later, but requests and close no longer wait for it. Moved the generic primitive from binary application code into src/process and updated every consumer (binary evaluation/lazy loading, Ghidra and IDA), retaining a single implementation. Added unrun pending-stat cancellation/late rejection and deadline regressions. Validation was source inspection only; the touched files were formatted with the pinned toolchain (two formatter threads). Tests, builds, lint, typechecks, provider workloads and CI reruns were not run, as explicitly requested. Follow-up e31e1fc corrects the confirmed TS2353 from the existing remote logs: timeout phase context now uses supported AnalysisErrorOptions.diagnostics rather than userMessage. The standard timeout operation/tag/duration remain unchanged. Source inspection/formatting only; no CI rerun or post-push result was requested or claimed.

  1. thread 1

The provider retained a constructor-time copy of the whole ambient environment, which could preserve removed or rotated values. Fixed in 3e58af6: long-lived state contains only caller-selected variables. Ambient inheritance is sampled at each operation boundary and retained only for that operation; version and decode share the resulting snapshot. An explicit caller map remains authoritative for launcher selection. Added unrun regressions exercising rotated and removed inherited values and a default launcher changed after construction. The stored merged environment and selection wrapper were removed; no ambient snapshot is added to Evidence. Validation was source inspection only; the touched files were formatted with the pinned toolchain (two formatter threads). Tests, builds, lint, typechecks, provider workloads and CI reruns were not run, as explicitly requested. Follow-up e31e1fc corrects the confirmed TS2353 from the existing remote logs: timeout phase context now uses supported AnalysisErrorOptions.diagnostics rather than userMessage. The standard timeout operation/tag/duration remain unchanged. Source inspection/formatting only; no CI rerun or post-push result was requested or claimed.

@morluto
morluto merged commit 1eca600 into main Oct 13, 2026
4 checks passed
@morluto
morluto deleted the codex/fix-apktool-windows-launcher-review branch October 13, 2026 14:00
@morluto morluto added the bug Something isn't working label Oct 14, 2026
@morluto morluto added the provider: apktool Analysis provider / engine: apktool label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: apktool Analysis provider / engine: apktool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant