fix: consume and report CryptographyDeprecationWarning, detect encrypted PKCS#8 keys - #45
Open
ai-anant wants to merge 1 commit into
Open
fix: consume and report CryptographyDeprecationWarning, detect encrypted PKCS#8 keys#45ai-anant wants to merge 1 commit into
ai-anant wants to merge 1 commit into
Conversation
…ted PKCS#8 keys - Capture CryptographyDeprecationWarning raised while loading/serializing keys (e.g. DSA) and surface them in the analysis output instead of leaking raw Python warnings to stderr. - Recognize 'BEGIN ENCRYPTED PRIVATE KEY' (OpenSSL PKCS#8 encrypted) headers so such keys report type pkcs8 instead of unknown. - Add tests covering deprecation warning capture, encrypted PKCS#8 detection, and clean warnings for normal keys. Fixes cyfinoid#11
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
Addresses #11 (Consume specific warnings / errors and report accordingly).
Changes
warnings.catch_warnings(record=True)and collectCryptographyDeprecationWarningmessages (e.g. the "SSH DSA key support is deprecated" warning emitted bypublic_bytes(Encoding.OpenSSH)when serializing DSA keys). Warnings are surfaced in the analysis result under a newwarningskey instead of leaking to stderr as raw Python warnings.BEGIN ENCRYPTED PRIVATE KEY(OpenSSL PKCS#8 encrypted format) headers in_analyze_encrypted_key, so such keys reporttype: pkcs8instead ofunknown.Verification
pytest tests/→ 9 passedblack --check keychecker/ tests/→ cleanflake8 keychecker/ tests/→ clean⚠️ SSH DSA key support is deprecated and will be removed in a future releasein the output and produces no stderr warning trace; an OpenSSLgenpkey -aes256key reportsType: pkcs8.Fixes #11