fix(ssh): make --json actually emit JSON for remote scans - #64
Merged
Merged
Conversation
With portview installed on the far end the flag was fatal: --json is also the transport this side parses back, so the user's flag was appended to the injected one and the remote clap rejected it twice. Without portview there, agentless collection ignored the flag and printed a table. Both paths now emit JSON, and an empty result is [] rather than prose.
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.
Found while testing #63.
portview ssh <host> --jsonhas never worked, and it fails differently depending on the far end.With portview installed remotely — fatal
--jsonis also the transport this side parses back, so it is injected into the remote command. The user's own flag was then appended to it:The remote clap rejects the repeat and the whole command dies. This is the common case — anyone scripting against a host that has portview installed.
Without portview remotely — silently ignored
Agentless collection succeeded and then rendered a table anyway, because
run_ssh_scanunconditionally calleddisplay_port_tableand never looked at the flag.The fix
The injected flag and a user-typed one are indistinguishable once they are in the same list, so intent is captured first and the duplicate filtered out:
An empty result is now
[]rather thanNo ports found on remote host.— this output gets piped, so prose on stdout is a parse error waiting to happen.Verification
Both remote modes, against the same host, with the
ss/portview availability on the far end varied deliberately:Byte-identical between the two paths apart from the timestamp. Three regression tests cover the arg construction, including the
--json --jsoncase that was fatal.172 tests, fmt/clippy clean, macOS + Windows type-check.