Repository navigation
policy: keep legacy CA key sizes independent of host key sizes - #386
Open
liangzaihuanyv wants to merge 1 commit into
Open
liangzaihuanyv wants to merge 1 commit into
liangzaihuanyv wants to merge 1 commit into
Conversation
The cakey_size_* parser referenced hostkey_size, a local assigned only in the sibling hostkey_size_* branch. CA-first policies raised UnboundLocalError; an earlier directive for another type instead supplied an unintended size. A later same-type host-key directive also discarded earlier CA constraints. Merge each directive into its key-type entry, preserving host and CA constraints in either order. CA-only entries omit hostkey_size, so evaluation skips only that unspecified comparison while keeping CA checks and exact or allow_larger_keys semantics. Optional-host-key subset logic is unchanged.
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.
Problem
The supported, deprecated
cakey_size_*directives refer tohostkey_size, a local variable assigned only in the separatehostkey_size_*parser branch. This has two consequences:UnboundLocalErrorwhile loading the policy.There is also an ordering problem for the same key type: a later
hostkey_size_*directive replaces the whole entry, discarding an earlier CA constraint.Change
hostkey_size; do not infer it from another directive or invent a default.allow_larger_keyscomparisons remain enforced.This is a focused policy-loading/evaluation bug fix, not a new option or algorithm. The optional-host-key subset/reordering logic is unchanged; this does not address or reimplement #385.
Testing
Windows, Python 3.12.10, pytest 9.1.1, with
PYTHONDONTWRITEBYTECODE=1. The focused command was run withPYTHONPATHselecting the actual source tree under test:UnboundLocalError, not an import/collection failure.The added regressions use product
WriteBuf/SSH2_Kex.parse()fixtures andset_host_key()without network connections. They cover CA-only policies, foreign-type isolation, both same-type directive orders, multiple certificate types, CA type/size mismatches, exact/larger key semantics, and the existinghost_key_sizesformat.Additional existing-suite command:
Result: 132 passed, 1 failed, exit 1. The failure is the existing
test_audit_conf_process_commandlinecolor assertion under the ambientNO_COLOR=1environment variable. The same failure occurs with the original module. Independent point-runs oftest/test_auditconf.pyproduced 7 passed withNO_COLORremoved and 1 failed, 6 passed with it set. A supplemental suite run deselecting the affected node produced 131 passed, 2 deselected; pytest's prefix matching also deselected its passing SOCKS5 sibling.No all-green full-suite or upstream-CI claim is made. flake8, pylint, and mypy were unavailable and were not run. No live SSH server/client audit or end-to-end network test was performed.
Assistance
AI assistance was used for investigation, implementation, testing, and review. The changes and test evidence were reviewed before submission.