You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for working on this — we ran into the same scanner class of problem on a downstream container image and tracked it back to Crypto/SelfTest/.
One small note in case it's useful while you're already in there: scanners that look at X.509 specifically also trip on the certificate PEM blocks in the same files, not just the private-key markers. In pycryptodome 3.23.0 our scan flagged these four embedded test certs (all expired in 2017):
Subject CN
File
notAfter (UTC)
latvia
Crypto/SelfTest/PublicKey/test_import_RSA.py
2017-04-06 19:57:24
Test Server
Crypto/SelfTest/PublicKey/test_import_RSA.py
2017-04-07 09:35:12
poland
Crypto/SelfTest/PublicKey/test_import_DSA.py
2017-04-06 20:38:43
austria
Crypto/SelfTest/PublicKey/test_import_DSA.py
2017-04-08 20:53:20
Would it be in scope to extend the same make_pem() reconstruction to -----BEGIN CERTIFICATE----- blocks here too? That would let downstream images keep Crypto/SelfTest/ intact and still satisfy cert-aware scanners. Happy to send a follow-up patch if you'd prefer to keep this PR focused on private-key markers.
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
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.
Closes #904.
This keeps
Crypto.SelfTestinstalled and runnable, but avoids embedding full PEM private-key markers directly in the installed self-test source files.Changes:
make_pem()helper for self-test fixtures.Validation:
rg -n -- '-----BEGIN (RSA |DSA |EC |ENCRYPTED )?PRIVATE KEY-----' lib/Crypto/SelfTest build/.../Crypto/SelfTestPYTHONPYCACHEPREFIX=/private/tmp/pycryptodome-pyc python3 -m compileall -q lib/Crypto/SelfTestPYTHONPYCACHEPREFIX=/private/tmp/pycryptodome-pyc python3 setup.py test -m PublicKeyPYTHONPYCACHEPREFIX=/private/tmp/pycryptodome-pyc python3 setup.py test -m CipherPYTHONPYCACHEPREFIX=/private/tmp/pycryptodome-pyc python3 setup.py test -m SignaturePYTHONPYCACHEPREFIX=/private/tmp/pycryptodome-pyc python3 setup.py test -m ProtocolPYTHONPYCACHEPREFIX=/private/tmp/pycryptodome-pyc PYTHONPATH=build/lib.macosx-10.9-universal2-3.9 python3 -m Crypto.SelfTest PublicKey