Repository navigation
fix(cli): reject empty native and managed targets before resolution - #7956
Merged
morluto merged 1 commit intoOct 29, 2026
Merged
Conversation
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
Codex Review SummaryThis 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. |
Contributor
[Medium impact] The PR appears safe to merge. SummaryThe PR applies the existing
Reviews (1) · Last reviewed commit: "fix(cli): reject empty native and manage..." · Reviewed by Greptile |
This was referenced Oct 29, 2026
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.
4 of 19 tasks
12 of 19 tasks
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
This was referenced Nov 11, 2026
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.analyzeandinspect-artifactalready 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 controlinspect-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-architecturesshares one registration withinspect-machoandinspect-signature, so they cannot be fixed apart. Those two commands andinspect-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-apiandinspect-managed-native-boundaries.trace-native-ui-action,annotate-native-function,observe-native-ui,capture-native-ui-scenarioanddemangle-swifttake the samez.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, andleftPath/rightPathforcompare-managed-members) now uses the sharedlocalPathStringSchemafromsrc/domain/localPath.ts. That schema is nonempty and NUL-free, andanalyzealready 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:
inspect-native-data-typekeeps its current declaration because fix(cli): admit native data type selectors before opening a target #7360 is editing that command's admission.inspect-native-dispatch-metadatacommand is covered here. Itsinspect-apple-ipscommand lives inbinaryDiagnosticsCommands.ts, which several open PRs edit, so that issue should stay open.artifactCommands.ts, [Bug] extract-artifact and three artifact inspections select the working directory for an empty target #7406 and [Bug] inspect-keyed-archive accepts an empty target and reads the working-directory bundle #7377) are left for separate changes.Follow the contribution scope.
Ordinary fix within existing boundaries; a maintainer scope decision is not applicable.
Contract and boundary impact
VALIDATION_ERRORnamingpath,leftPathorrightPath(too_small) instead of a latertarget_unavailablefor the working directory. The advertised CLI argument schema changes, for exampleinspect-managed-artifact --schema --format jsonfrom{"type":"string",…}to{"type":"string","minLength":1,"pattern":"^[^\\x00]*$",…}. MCP request schemas are not changed.docs/public/product-catalog.json), package, or installation impact: none;npm run docs:checkpasses.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
All evidence below was executed.
New test:
tests/boundary/cli/emptyLocalTargetAdmission.test.ts. It followssearchBytesAdmission.test.ts: it registers the four command groups in-process with mocked analysis runners. Each of the 28 commands must reject""with aVALIDATION_ERRORonpath(too_small) without calling either runner. Each must then pass explicit.to the runner unchanged. Two more cases check that an emptyleftPathorrightPathofcompare-managed-membersis 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-signatureandinspect-plistnow give the sameVALIDATION_ERRORonpath.Remaining proof gaps: Windows only. On this host
inspect-plist,inspect-machoandinspect-signaturereturncapability_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:
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.npm run test:focused -- tests/boundary/cli/emptyLocalTargetAdmission.test.ts: base 30 failed / 0 passed; with the fix 30/30 passed.npm run test:focused --over all 200 files intests/boundary/cli/(there are nosrc/cli/*.test.tsfiles), in six batches: 1205 passed, 174 skipped, 48 failed in 23 files.07dfd1261. Base and fix both gave 48 failed / 94 passed / 20 skipped, and the failing test names were identical.npm run check:fast: typecheck and lint 2/2 passed.npm run docs:check: 9/9 passed.oxfmtandoxlint --fixran through the pre-commit hook.git merge-treeagainst the 14 open PRs that edit one of the four files (feat(ghidra): open M-profile raw images at a separate load base #7951, fix(native-ui): explain why both capture sources are disabled #7589, feat(ghidra): admit caller-selected matching dSYM companions #2025, fix(cli): admit native data type selectors before opening a target #7360, feat(cli): expose caller-selected reference-source path exclusions #2630, feat(ghidra): persistent project cache with cross-session identity #3531, feat(cli): expose caller-selected reference-source exclusions #5472, feat(config): persist provider settings in a user config file #3023, feat(ghidra): support Cortex-M raw images with separate load base #4927, feat(ghidra): support raw SH-4 binaries #4678, feat(windows): capture selected windows through owned helpers #4143, feat(managed): bind Portable PDB sequence points to selected methods #2435) or follow this pattern (fix(cli): reject empty native-call targets #7464, fix(cli): reject empty decompile-all targets #7284):mainstill merge cleanly with this change.maingain no newly conflicted file.utilityCommands.tsis placed apart from the import lines that fix(native-ui): explain why both capture sources are disabled #7589 and feat(config): persist provider settings in a user config file #3023 edit.Compatibility, safety, and release
""to mean the working directory must pass., asdocs/cli.mdalready documents.Author readiness
Human owner: @Plastic-time
Before merge
type(scope): outcome.