Skip to content

fix(cli): reject empty native and managed targets before resolution - #7956

Merged
morluto merged 1 commit into
morluto:mainfrom
Plastic-time:claude/fix-empty-binary-targets
Oct 29, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
Plastic-time:claude/fix-empty-binary-targets

Conversation

@Plastic-time

@Plastic-time Plastic-time commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7436. Fixes #7404.

Local file commands in the core binary, native, managed and native-tool CLI groups declared their positional target as z.string(). An empty argument therefore passed CLI validation and reached path admission, which resolved it to the working directory. docs/cli.md (lines 42–45) says local inspection commands reject empty paths before resolution and that an empty string never selects the working directory. analyze and inspect-artifact already behave that way; their siblings did not.

Problem and expected behavior

On base 07dfd1261, the compiled CLI on Windows runs each command with an empty target from a plain directory. The issue's cases all resolved "" to that directory and failed later with a misleading target error. The control inspect-artifact "" was rejected at validation:

{"command":"inspect","args":[""],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"inspect-managed-artifact","args":[""],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"inspect-managed-members","args":[""],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"list-architectures","args":[""],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"search-bytes","args":["","00"],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"address-to-file-offset","args":["","0x1000"],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"inspect-native-instruction","args":["","0x1000"],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"compare-managed-members","args":["","."],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"compare-managed-members","args":[".",""],"exit":1,"code":"target_unavailable","constraint":"directory_requires_file","reported_path":"<cwd>"}
{"command":"inspect-artifact","args":[""],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}

list-architectures shares one registration with inspect-macho and inspect-signature, so they cannot be fixed apart. Those two commands and inspect-plist (same file) are #7404. I swept every other command with a positional target in the same four files. Each resolved "" to the working directory the same way: decompile, xrefs, trace, function, instructions, search, inspect-native-load-image, read-bytes, trace-native-values, resolve-native-call-targets, inspect-native-dispatch-metadata, inspect-native-api and inspect-managed-native-boundaries. trace-native-ui-action, annotate-native-function, observe-native-ui, capture-native-ui-scenario and demangle-swift take the same z.string() target and are covered by the regression test below.

Change and scope

  • coreBinaryCommands.ts, coreNativeCommands.ts, managedCommands.ts, utilityCommands.ts: each positional local target (path, and leftPath/rightPath for compare-managed-members) now uses the shared localPathStringSchema from src/domain/localPath.ts. That schema is nonempty and NUL-free, and analyze already uses it in the same file. This follows the pattern of fix(cli): reject empty native-call targets #7464 and fix(cli): reject empty decompile-all targets #7284. No runtime path handling changed. Explicit . is still admitted.

Intentionally not included:

Follow the contribution scope.
Ordinary fix within existing boundaries; a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI argument validation for these commands, before any analysis runner or path resolution.
  • Contribution scope fit and linked maintainer decision: routine fix; not applicable.
  • CLI and MCP/tool-catalog contract: an empty target now fails with VALIDATION_ERROR naming path, leftPath or rightPath (too_small) instead of a later target_unavailable for the working directory. The advertised CLI argument schema changes, for example inspect-managed-artifact --schema --format json from {"type":"string",…} to {"type":"string","minLength":1,"pattern":"^[^\\x00]*$",…}. MCP request schemas are not changed.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none; the rejected requests never produced Evidence for an intended target.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): an empty selection can no longer select the working directory or an app bundle there. Before this change, [Bug] inspect-plist, inspect-macho and inspect-signature return working-directory Evidence for an empty target #7404 reports successful Evidence for that case on macOS.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none; npm run docs:check passes.

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

All evidence below was executed.

  • New test: tests/boundary/cli/emptyLocalTargetAdmission.test.ts. It follows searchBytesAdmission.test.ts: it registers the four command groups in-process with mocked analysis runners. Each of the 28 commands must reject "" with a VALIDATION_ERROR on path (too_small) without calling either runner. Each must then pass explicit . to the runner unchanged. Two more cases check that an empty leftPath or rightPath of compare-managed-members is named.

  • Base reproduction: with only the new test on 07dfd1261, 30 failed / 0 passed. With the fix, 30/30 passed.

  • User-visible CLI output after the fix, same script as above:

    {"command":"inspect","args":[""],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}
    {"command":"inspect-managed-artifact","args":[""],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}
    {"command":"inspect-managed-members","args":[""],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}
    {"command":"list-architectures","args":[""],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}
    {"command":"search-bytes","args":["","00"],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}
    {"command":"address-to-file-offset","args":["","0x1000"],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}
    {"command":"inspect-native-instruction","args":["","0x1000"],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}
    {"command":"compare-managed-members","args":["","."],"exit":1,"code":"VALIDATION_ERROR","field":"leftPath","issue":"too_small"}
    {"command":"compare-managed-members","args":[".",""],"exit":1,"code":"VALIDATION_ERROR","field":"rightPath","issue":"too_small"}
    {"command":"inspect-artifact","args":[""],"exit":1,"code":"VALIDATION_ERROR","field":"path","issue":"too_small"}

    The 13 swept siblings and inspect-macho, inspect-signature and inspect-plist now give the same VALIDATION_ERROR on path.

  • Remaining proof gaps: Windows only. On this host inspect-plist, inspect-macho and inspect-signature return capability_unavailable, so I could not reproduce [Bug] inspect-plist, inspect-macho and inspect-signature return working-directory Evidence for an empty target #7404's macOS success case through those providers. The in-process test covers their argument admission, which is platform-independent. The native-UI, UI-action and annotation commands were exercised only through that test. Hosted CI is pending.

For boundary fixes: the boundary is CLI argument admission for local targets; the sibling sweep above lists every positional target in the four changed files.

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

Windows 11 x64 (10.0.26200), Node 24.22.1, npm 11.19.1, base 07dfd1261. The Windows native addon and manifest came from the [email protected] tarball, as CONTRIBUTING describes.

Compatibility, safety, and release

  • Breaking changes or migration steps: none expected. An empty target was never valid; it now fails earlier and names the field. A script that passed "" to mean the working directory must pass ., as docs/cli.md already documents.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; Windows only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new execution, network access or file writes. Rejecting an empty target before resolution keeps an unset variable from selecting the working directory.

Author readiness

Human owner: @Plastic-time

  • 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.

Local file commands in the core binary, native, managed and native-tool
CLI groups declared their positional target as a plain string. An empty
argument therefore reached path admission, where it resolved to the
working directory, as docs/cli.md says it never should.

Declare those targets with the shared nonempty, NUL-free local path
schema already used by analyze, so the CLI rejects them as a
VALIDATION_ERROR naming the field before any analysis runner is called.
Explicit "." is unchanged.

Fixes morluto#7436
Fixes morluto#7404
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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 ⚠️ Failed 2026-10-29T00:17:34.255137Z
We couldn’t complete this review. Comment @codex review to try again.
2305ec6 PR opened
ℹ️ 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 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR applies the existing localPathStringSchema to local targets across four CLI command groups.

  • Local-target commands reject empty paths before resolving them.

Reviews (1) · Last reviewed commit: "fix(cli): reject empty native and manage..." · Reviewed by Greptile

@morluto
morluto merged commit 6db024d into morluto:main Oct 29, 2026
4 of 12 checks passed
viniciusdsandrade added a commit to viniciusdsandrade/rea that referenced this pull request Oct 30, 2026
inspect-native-data-type still declared its positional target as a plain
string after morluto#7956 moved its sibling local-file commands to
localPathStringSchema, so an empty target passed validation and resolved
to the working directory. Use the shared schema and cover the command in
the empty-target admission table.
morluto pushed a commit that referenced this pull request Nov 9, 2026
…7360)

* fix(cli): admit native data type selectors before opening a target

* fix(cli): advertise the native data type selector choice

* test(cli): reject invalid native data type selectors before target access

* test(cli): cover native data type selector discovery

* fix(cli): reject an empty native data type target before resolution

inspect-native-data-type still declared its positional target as a plain
string after #7956 moved its sibling local-file commands to
localPathStringSchema, so an empty target passed validation and resolved
to the working directory. Use the shared schema and cover the command in
the empty-target admission table.

* refactor(cli): share native data type selector guidance owner

* test(cli): bind native data type selector checks to owning contracts
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

2 participants