Repository navigation
Conversation
When paramiko encounters an unknown Match criterion in ssh_config (e.g. `localnetwork`, a valid OpenSSH keyword that paramiko doesn't support), it silently treats the criterion as matching. This causes Match blocks with unsupported criteria to be incorrectly applied. Fix by logging a warning and setting `passed = False` for any unknown Match criterion, so the Match block is treated as not matching — matching OpenSSH's own behavior for unsupported keywords. Also restructures the `if type_ == "canonical"` block from a standalone `if` to match `elif` consistency so the new `else` clause correctly only catches truly unknown types. Adds a test config file and two test methods covering the case where an unknown criterion causes the block to be skipped while other blocks are unaffected. Fixes paramiko#2632. Signed-off-by: kaizeenn <[email protected]>
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 #2632.
When paramiko encounters an unknown Match criterion in
ssh_config(e.g.localnetwork, a valid OpenSSH keyword that paramiko doesn't support), it silently treats the criterion as matching. This causes Match blocks with unsupported criteria to be incorrectly applied.Root cause
The
_does_matchmethod inconfig.pyhas anif/elifchain for each known Match type (canonical,final,all,host,originalhost,user,localuser,exec). Unknown types likelocalnetworkfall through without settingpassed, sopassedstaysNoneand the candidate is silently added to the matched list.Fix
passed = Falseso the Match block is treated as not matching (matching OpenSSH behavior)canonicalhandling from a standaloneifinto theelifchain to ensure the newelseclause only catches truly unknown typesTest evidence
Added
match-unknown-criteriatest config andTestMatchUnknownCriteriaclass with two tests:The new warning is emitted at runtime when unknown criteria are encountered: