Conversation
plaintext_login() only caught AuthenticationException and SSHException before falling through to the generic Exception handler, which logs via logger.exception() and dumps a full traceback. A connection timing out mid-login is routine on a target sweep, not something that needs a stack trace, and smb.py already treats TimeoutError this way elsewhere in the codebase. Fixes Pennyw0rth#358
MRX-72
requested review from
Marshall-Hallenbeck,
NeffIsBack,
mpgn and
zblurx
as code owners
September 18, 2026 08:16
|
It looks like the PR template may not have been filled out. The following sections appear to be missing:
Please edit your PR description to include them. The template helps reviewers understand and test your changes. Thanks! |
Author
|
Template filled in — the bot comment above is stale (the check re-ran green on the edit, it just doesn't clear its own comment). AI usage is disclosed in the description per AI_POLICY.md, and #358 was opened by a maintainer. One thing worth flagging for the reviewer: I verified the timeout path with real paramiko against a blackholed host, but not through the full |
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.
Description
plaintext_login()innxc/protocols/ssh.pycaughtAuthenticationExceptionandSSHException, then fell through to the bareexcept Exceptionhandler, which callslogger.exception()and dumps a full traceback. A connection timing out mid-login is routine on a sweep, not something that warrants a stack trace on the console — this is the noise shown in the screenshot on #358.This adds one
except TimeoutErrorarm before the generic handler, logging a singlefailline instead.smb.pyalready handles timeouts this way (nxc/protocols/smb.py:976), so this follows the existing pattern rather than inventing one.No new dependencies.
AI disclosure: written with Claude Code (Opus 5), heavily AI-assisted — the model located the handler chain, wrote the one-line change and the verification harness below. I reviewed the diff myself, chose to match the existing
smb.pypattern rather than a new one, and ran the before/after verification. Fixes an issue opened by a maintainer (#358), not a drive-by.Type of change
Setup guide for the review
Environment: macOS 26.3, Python 3.13, paramiko 5.0.0.
Reproducing the bug needs nothing more than an SSH target that swallows packets. Point nxc at a non-routable address so the connect times out rather than being refused:
A refused connection (
ECONNREFUSED) will not reproduce it — that path raisesSSHException, which was already handled. It has to be a genuine timeout.What I ran. Full
nxcdoes not install on my machine —aardwolfneeds a Rust toolchain to build — so I drove the realplaintext_login()directly instead: extracted the function fromnxc/protocols/ssh.pyand executed it with a realparamiko.SSHClientagainst10.255.255.1:22, with a 3 s timeout. The timeout is genuine paramiko behaviour, not a raise I stubbed in, and it runs through the actual except-chain in the source file. The same harness run againstorigin/mainand against this branch:Both return
False, as before.To be straight about the limits of that: I have verified the timeout path end-to-end with real paramiko, but I have not run the full
netexec sshCLI against a live SSH server, so the surrounding sweep output is unconfirmed on my side. Everything else in the function is untouched.Screenshots (if appropriate):
None — the before/after output is quoted above rather than screenshotted.
Checklist:
poetry run ruff check ., use--fixto automatically fix what it can)tests/e2e_commands.txtfile if necessary (new modules or features are required to be added to the e2e tests)Notes on the unchecked boxes: no
e2e_commands.txtentry since this adds no command or module, only changes how an existing failure is reported; no third-party deps; no wiki change, as no documented behaviour changes. The one-line handler needed no comment beyond the message itself — "linked relevant sources" is the existingsmb.py:976precedent cited above.Fixes #358